coriolis/hurricane/src/isobar/PyTechnology.cpp

163 lines
4.9 KiB
C++
Raw Normal View History

2008-03-06 10:46:43 -06:00
// x-----------------------------------------------------------------x
// | |
// | C O R I O L I S |
// | I s o b a r - Hurricane / Python Interface |
// | |
// | Author : Damien DUPUIS |
// | E-mail : Damien.Dupuis@asim.lip6.fr |
// | =============================================================== |
// | C++ Module : "./PyTechnology.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/isobar/PyDataBase.h"
#include "hurricane/isobar/PyLayer.h"
#include "hurricane/isobar/PyTechnology.h"
2008-03-06 10:46:43 -06:00
namespace Isobar {
2008-03-28 04:48:47 -05:00
using namespace Hurricane;
2008-03-06 10:46:43 -06:00
extern "C" {
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Technology,techno,function)
// x=================================================================x
// | "PyTechnology" Python Module Code Part |
// x=================================================================x
#if defined(__PYTHON_MODULE__)
// x-------------------------------------------------------------x
// | "PyTechnology" Attribute Methods |
// x-------------------------------------------------------------x
// ---------------------------------------------------------------
2008-03-17 08:54:33 -05:00
// Attribute Method : "PyTechnology_getName ()"
2008-03-06 10:46:43 -06:00
static PyObject* PyTechnology_getName(PyTechnology *self) {
2008-03-17 08:54:33 -05:00
trace << "PyTechnology_getName ()" << endl;
2008-03-06 10:46:43 -06:00
HTRY
METHOD_HEAD("Technology.getName()")
return PyString_FromString(getString(techno->getName()).c_str());
2008-03-06 10:46:43 -06:00
HCATCH
return NULL;
2008-03-06 10:46:43 -06:00
}
// ---------------------------------------------------------------
2008-04-13 05:12:19 -05:00
// Attribute Method : "PyTechnology_setName ()"
2008-03-06 10:46:43 -06:00
static PyObject* PyTechnology_setName(PyTechnology *self, PyObject* args) {
2008-04-13 05:12:19 -05:00
trace << "Technology.setName()" << endl;
2008-03-06 10:46:43 -06:00
HTRY
METHOD_HEAD ( "Technology.setName()" )
char* name = NULL;
if (PyArg_ParseTuple(args,"s:Technology.setName", &name)) {
techno->setName(Name(name));
} else {
PyErr_SetString(ConstructorError, "invalid number of parameters for Technology.setName.");
return NULL;
}
2008-03-06 10:46:43 -06:00
HCATCH
Py_RETURN_NONE;
}
// ---------------------------------------------------------------
2008-03-17 08:54:33 -05:00
// Attribute Method : "PyTechnology_getLayer ()"
2008-03-06 10:46:43 -06:00
static PyObject* PyTechnology_getLayer ( PyTechnology *self, PyObject* args ) {
2008-03-17 08:54:33 -05:00
trace << "Technology.getLayer()" << endl;
METHOD_HEAD("Technology.getLayer()")
2008-03-06 10:46:43 -06:00
Layer* layer = NULL;
HTRY
char* name = NULL;
if (PyArg_ParseTuple(args,"s:Technology.getLayer", &name)) {
layer = techno->getLayer(Name(name));
} else {
PyErr_SetString(ConstructorError, "invalid number of parameters for getLayer.");
return NULL;
}
2008-03-06 10:46:43 -06:00
HCATCH
return PyLayer_Link(layer);
2008-03-06 10:46:43 -06:00
}
// Standart Accessors (Attributes).
2008-03-17 08:54:33 -05:00
// Standard destroy (Attribute).
DBoDestroyAttribute(PyTechnology_destroy, PyTechnology)
2008-03-06 10:46:43 -06:00
// ---------------------------------------------------------------
// PyTechnology Attribute Method table.
PyMethodDef PyTechnology_Methods[] =
2008-03-17 08:54:33 -05:00
{ { "getName" , (PyCFunction)PyTechnology_getName , METH_NOARGS , "Returns the name of the technology." }
2008-04-13 05:12:19 -05:00
, { "setName" , (PyCFunction)PyTechnology_setName , METH_VARARGS, "Allows to change the technology name." }
2008-03-17 08:54:33 -05:00
, { "getLayer" , (PyCFunction)PyTechnology_getLayer , METH_VARARGS, "Returns the layer named name." }
, { "destroy" , (PyCFunction)PyTechnology_destroy , METH_NOARGS
, "Destroy associated hurricane object The python object remains." }
2008-03-06 10:46:43 -06:00
, {NULL, NULL, 0, NULL} /* sentinel */
};
// x-------------------------------------------------------------x
// | "PyTechnology" Object Methods |
// x-------------------------------------------------------------x
DBoDeleteMethod(Technology)
PyTypeObjectLinkPyType(Technology)
#else // End of Python Module Code Part.
// x=================================================================x
// | "PyTechnology" Shared Library Code Part |
// x=================================================================x
// Link/Creation Method.
DBoLinkCreateMethod(Technology)
2008-03-06 10:46:43 -06:00
// ---------------------------------------------------------------
// PyTechnology Object Definitions.
PyTypeObjectDefinitions(Technology)
2008-03-06 10:46:43 -06:00
#endif // End of Shared Library Code Part.
} // End of extern "C".
} // End of Isobar namespace.