coriolis/hurricane/src/isobar/PyNet.cpp

555 lines
18 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 : Sophie BELLOEIL |
// | E-mail : Sophie.Belloeil@asim.lip6.fr |
// | =============================================================== |
// | C++ Module : "./PyNet.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/isobar/PyNet.h"
#include "hurricane/isobar/PyCell.h"
#include "hurricane/isobar/PyPoint.h"
2008-10-17 12:27:20 -05:00
#include "hurricane/isobar/PyPlugCollection.h"
#include "hurricane/isobar/PySegmentCollection.h"
#include "hurricane/isobar/PyComponentCollection.h"
#include "hurricane/isobar/PyPinCollection.h"
2008-11-30 14:33:42 -06:00
#include "hurricane/Cell.h"
#include "hurricane/NetExternalComponents.h"
2008-03-28 04:48:47 -05:00
using namespace Hurricane;
2008-03-06 10:46:43 -06:00
2008-03-28 04:48:47 -05:00
namespace Isobar {
2008-03-06 10:46:43 -06:00
extern "C" {
2008-10-17 12:27:20 -05:00
#undef ACCESS_OBJECT
#undef ACCESS_CLASS
#define ACCESS_OBJECT _baseObject._object
#define ACCESS_CLASS(_pyObject) &(_pyObject->_baseObject)
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Net,net,function)
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
#define LOAD_CONSTANT(CONSTANT_VALUE,CONSTANT_NAME) \
constant = PyInt_FromLong ( (long)CONSTANT_VALUE ); \
PyDict_SetItemString ( dictionnary, CONSTANT_NAME, constant ); \
Py_DECREF ( constant );
2008-03-06 10:46:43 -06:00
// x=================================================================x
// | "PyNet" Python Module Code Part |
// x=================================================================x
2008-10-17 12:27:20 -05:00
#if defined(__PYTHON_MODULE__)
2008-03-06 10:46:43 -06:00
// x-------------------------------------------------------------x
// | "PyNet" Local Functions |
// x-------------------------------------------------------------x
// ---------------------------------------------------------------
// Local Function : "PyInt_AsType ()"
static Net::Type PyInt_AsType ( PyObject* object ) {
2008-03-06 10:46:43 -06:00
switch ( PyInt_AsLong(object) ) {
case Net::Type::UNDEFINED : return ( Net::Type(Net::Type::UNDEFINED) );
case Net::Type::LOGICAL : return ( Net::Type(Net::Type::LOGICAL) );
case Net::Type::CLOCK : return ( Net::Type(Net::Type::CLOCK) );
case Net::Type::POWER : return ( Net::Type(Net::Type::POWER) );
case Net::Type::GROUND : return ( Net::Type(Net::Type::GROUND) );
}
return ( Net::Type(Net::Type::UNDEFINED) );
}
// ---------------------------------------------------------------
// Local Function : "PyInt_AsDirection ()"
static Net::Direction PyInt_AsDirection ( PyObject* object )
{
switch ( PyInt_AsLong(object) ) {
case Net::Direction::UNDEFINED : return ( Net::Direction(Net::Direction::UNDEFINED) );
case Net::Direction::IN : return ( Net::Direction(Net::Direction::IN) );
case Net::Direction::OUT : return ( Net::Direction(Net::Direction::OUT) );
case Net::Direction::INOUT : return ( Net::Direction(Net::Direction::INOUT) );
case Net::Direction::TRISTATE : return ( Net::Direction(Net::Direction::TRISTATE) );
}
return ( Net::Direction(Net::Direction::UNDEFINED) );
}
// x-------------------------------------------------------------x
// | Global Constants Loading |
// x-------------------------------------------------------------x
2008-10-17 12:27:20 -05:00
extern void NetLoadConstants ( PyObject* dictionnary ) {
2008-03-06 10:46:43 -06:00
PyObject* constant;
LOAD_CONSTANT ( Net::Type::UNDEFINED , "TypeUNDEFINED" )
LOAD_CONSTANT ( Net::Type::LOGICAL , "TypeLOGICAL" )
LOAD_CONSTANT ( Net::Type::CLOCK , "TypeCLOCK" )
LOAD_CONSTANT ( Net::Type::POWER , "TypePOWER" )
LOAD_CONSTANT ( Net::Type::GROUND , "TypeGROUND" )
LOAD_CONSTANT ( Net::Direction::UNDEFINED , "DirectionUNDEFINED" )
LOAD_CONSTANT ( Net::Direction::IN , "DirectionIN" )
LOAD_CONSTANT ( Net::Direction::OUT , "DirectionOUT" )
LOAD_CONSTANT ( Net::Direction::INOUT , "DirectionINOUT" )
LOAD_CONSTANT ( Net::Direction::TRISTATE , "DirectionTRISTATE" )
}
// x-------------------------------------------------------------x
// | "PyNet" Attribute Methods |
// x-------------------------------------------------------------x
// Standart Accessors (Attributes).
2008-03-17 08:54:33 -05:00
DirectGetLongAttribute(PyNet_getX,getX,PyNet,Net)
DirectGetLongAttribute(PyNet_getY,getY,PyNet,Net)
2008-03-06 10:46:43 -06:00
// Standart Predicates (Attributes).
2008-04-02 07:11:31 -05:00
DirectGetBoolAttribute(PyNet_isGlobal ,isGlobal ,PyNet,Net)
DirectGetBoolAttribute(PyNet_isExternal,isExternal,PyNet,Net)
DirectGetBoolAttribute(PyNet_isLogical ,isLogical ,PyNet,Net)
DirectGetBoolAttribute(PyNet_isClock ,isClock ,PyNet,Net)
DirectGetBoolAttribute(PyNet_isGround ,isGround ,PyNet,Net)
DirectGetBoolAttribute(PyNet_isPower ,isPower ,PyNet,Net)
DirectGetBoolAttribute(PyNet_isSupply ,isSupply ,PyNet,Net)
2008-03-06 10:46:43 -06:00
GetBoundStateAttribute(PyNet_IsPyBound ,PyNet,Net)
2008-03-17 08:54:33 -05:00
// Standart destroy (Attribute).
DBoDestroyAttribute(PyNet_destroy, PyNet)
2008-03-06 10:46:43 -06:00
// ---------------------------------------------------------------
2008-03-17 08:54:33 -05:00
// Attribute Method : "PyNet_getName ()"
2008-03-06 10:46:43 -06:00
2008-03-17 08:54:33 -05:00
static PyObject* PyNet_getName ( PyNet *self ) {
trace << "PyNet_getName ()" << endl;
2008-03-06 10:46:43 -06:00
HTRY
METHOD_HEAD("Net.getName()")
return PyString_FromString(getString(net->getName()).c_str());
2008-03-06 10:46:43 -06:00
HCATCH
return NULL;
2008-03-06 10:46:43 -06:00
}
// ---------------------------------------------------------------
2008-03-17 08:54:33 -05:00
// Attribute Method : "PyNet_getType ()"
2008-03-06 10:46:43 -06:00
2008-03-17 08:54:33 -05:00
static PyObject* PyNet_getType ( PyNet *self )
2008-03-06 10:46:43 -06:00
{
2008-03-17 08:54:33 -05:00
trace << "PyNet_getType ()" << endl;
2008-03-06 10:46:43 -06:00
2008-03-17 08:54:33 -05:00
METHOD_HEAD ( "Net.getType()" )
2008-03-06 10:46:43 -06:00
2008-03-17 08:54:33 -05:00
return ( (PyObject*)Py_BuildValue("i",(long)net->getType().getCode()) );
2008-03-06 10:46:43 -06:00
}
// ---------------------------------------------------------------
2008-03-17 08:54:33 -05:00
// Attribute Method : "PyNet_getDirection ()"
2008-03-06 10:46:43 -06:00
2008-03-17 08:54:33 -05:00
static PyObject* PyNet_getDirection ( PyNet *self )
2008-03-06 10:46:43 -06:00
{
2008-03-17 08:54:33 -05:00
trace << "PyNet_getDirection ()" << endl;
2008-03-06 10:46:43 -06:00
2008-03-17 08:54:33 -05:00
METHOD_HEAD ( "Net.getDirection()" )
2008-03-06 10:46:43 -06:00
2008-03-17 08:54:33 -05:00
return ( (PyObject*)Py_BuildValue("i",(long)net->getDirection().getCode()) );
2008-03-06 10:46:43 -06:00
}
// ---------------------------------------------------------------
2008-10-17 12:27:20 -05:00
// Attribute Method : "PyNet_getPlugs()"
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
static PyObject* PyNet_getPlugs(PyNet *self) {
trace << "PyNet_getPlugs()" << endl;
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
METHOD_HEAD("Net.getPlugs()")
PyPlugCollection* pyPlugCollection = NULL;
2008-03-06 10:46:43 -06:00
HTRY
2008-10-17 12:27:20 -05:00
Plugs* plugs = new Plugs(net->getPlugs());
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
pyPlugCollection = PyObject_NEW(PyPlugCollection, &PyTypePlugCollection);
if (pyPlugCollection == NULL) {
return NULL;
}
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
pyPlugCollection->_object = plugs;
2008-03-06 10:46:43 -06:00
HCATCH
2008-10-17 12:27:20 -05:00
return (PyObject*)pyPlugCollection;
2008-03-06 10:46:43 -06:00
}
// ---------------------------------------------------------------
2008-10-17 12:27:20 -05:00
// Attribute Method : "PyNet_getSegments()"
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
static PyObject* PyNet_getSegments(PyNet *self) {
trace << "PyNet_getSegments()" << endl;
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
METHOD_HEAD ("Net.getSegments()")
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
PySegmentCollection* pySegmentCollection = NULL;
2008-03-06 10:46:43 -06:00
HTRY
2008-10-17 12:27:20 -05:00
Segments* nets = new Segments(net->getSegments());
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
pySegmentCollection = PyObject_NEW(PySegmentCollection, &PyTypeSegmentCollection);
if (pySegmentCollection == NULL) {
return NULL;
}
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
pySegmentCollection->_object = nets;
2008-03-06 10:46:43 -06:00
HCATCH
2008-10-17 12:27:20 -05:00
return (PyObject*)pySegmentCollection;
2008-03-06 10:46:43 -06:00
}
// ---------------------------------------------------------------
2008-10-17 12:27:20 -05:00
// Attribute Method : "PyNet_getPins()"
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
static PyObject* PyNet_getPins(PyNet *self) {
trace << "PyNet_getPins()" << endl;
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
METHOD_HEAD ("Net.getPins()")
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
PyPinCollection* pyPinCollection = NULL;
2008-03-06 10:46:43 -06:00
HTRY
2008-10-17 12:27:20 -05:00
Pins* pins = new Pins(net->getPins());
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
pyPinCollection = PyObject_NEW(PyPinCollection, &PyTypePinCollection);
if (pyPinCollection == NULL) {
return NULL;
}
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
pyPinCollection->_object = pins;
2008-03-06 10:46:43 -06:00
HCATCH
2008-10-17 12:27:20 -05:00
return (PyObject*)pyPinCollection;
2008-03-06 10:46:43 -06:00
}
// ---------------------------------------------------------------
2008-10-17 12:27:20 -05:00
// Attribute Method : "PyNet_getExternalComponents()"
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
static PyObject* PyNet_getExternalComponents(PyNet *self) {
trace << "PyNet_getExternalComponents()" << endl;
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
METHOD_HEAD ( "Net.getExternalcomponents()" )
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
PyComponentCollection* pyComponentCollection = NULL;
2008-03-06 10:46:43 -06:00
HTRY
2008-10-17 12:27:20 -05:00
Components* components = new Components(NetExternalComponents::get(net));
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
pyComponentCollection = PyObject_NEW(PyComponentCollection, &PyTypeComponentCollection);
if (pyComponentCollection == NULL) {
return NULL;
}
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
pyComponentCollection->_object = components;
2008-03-06 10:46:43 -06:00
HCATCH
2008-10-17 12:27:20 -05:00
return (PyObject*)pyComponentCollection;
2008-03-06 10:46:43 -06:00
}
// ---------------------------------------------------------------
2008-04-02 07:11:31 -05:00
// Attribute Method : "PyNet_setName ()"
2008-03-06 10:46:43 -06:00
2008-04-02 07:11:31 -05:00
static PyObject* PyNet_setName ( PyNet *self, PyObject* args )
2008-03-06 10:46:43 -06:00
{
2008-04-02 07:11:31 -05:00
trace << "PyNet_setName()" << endl;
2008-03-06 10:46:43 -06:00
HTRY
METHOD_HEAD("Net.setName()")
char* name = NULL;
if (PyArg_ParseTuple(args,"s:Net.setName", &name)) {
net->setName(Name(name));
} else {
PyErr_SetString(ConstructorError, "invalid number of parameters for Net.setName.");
return NULL;
}
2008-03-06 10:46:43 -06:00
HCATCH
Py_RETURN_NONE;
}
// ---------------------------------------------------------------
2008-04-02 07:11:31 -05:00
// Attribute Method : "PyNet_setGlobal ()"
2008-03-06 10:46:43 -06:00
2008-04-02 07:11:31 -05:00
static PyObject* PyNet_setGlobal ( PyNet *self, PyObject* args )
2008-03-06 10:46:43 -06:00
{
2008-04-02 07:11:31 -05:00
trace << "PyNet_setGlobal()" << endl;
2008-03-06 10:46:43 -06:00
HTRY
2008-04-02 07:11:31 -05:00
METHOD_HEAD ( "Net.setGlobal()" )
2008-03-06 10:46:43 -06:00
PyObject* arg0;
2008-04-02 07:11:31 -05:00
if ( ! ParseOneArg ( "Net.setGlobal", args, INT_ARG, (PyObject**)&arg0 ) ) return ( NULL );
2008-03-06 10:46:43 -06:00
2008-04-02 07:11:31 -05:00
net->setGlobal ( PyInt_AsLong(arg0) != 0 );
2008-03-06 10:46:43 -06:00
HCATCH
Py_RETURN_NONE;
}
// ---------------------------------------------------------------
2008-04-02 07:11:31 -05:00
// Attribute Method : "PyNet_setExternal ()"
2008-03-06 10:46:43 -06:00
2008-04-02 07:11:31 -05:00
static PyObject* PyNet_setExternal ( PyNet *self, PyObject* args )
2008-03-06 10:46:43 -06:00
{
2008-04-02 07:11:31 -05:00
trace << "PyNet_setExternal()" << endl;
2008-03-06 10:46:43 -06:00
HTRY
2008-04-02 07:11:31 -05:00
METHOD_HEAD ( "Net.setExternal()" )
2008-03-06 10:46:43 -06:00
PyObject* arg0;
2008-04-02 07:11:31 -05:00
if ( ! ParseOneArg ( "Net.setExternal", args, INT_ARG, (PyObject**)&arg0 ) ) return ( NULL );
2008-03-06 10:46:43 -06:00
2008-04-02 07:11:31 -05:00
net->setExternal ( PyInt_AsLong(arg0) != 0 );
2008-03-06 10:46:43 -06:00
HCATCH
Py_RETURN_NONE;
}
// ---------------------------------------------------------------
2008-04-02 07:11:31 -05:00
// Attribute Method : "PyNet_setType ()"
2008-03-06 10:46:43 -06:00
2008-04-02 07:11:31 -05:00
static PyObject* PyNet_setType ( PyNet *self, PyObject* args )
2008-03-06 10:46:43 -06:00
{
2008-04-02 07:11:31 -05:00
trace << "PyNet_setType()" << endl;
2008-03-06 10:46:43 -06:00
HTRY
2008-04-02 07:11:31 -05:00
METHOD_HEAD ( "Net.setType()" )
2008-03-06 10:46:43 -06:00
PyObject* arg0;
if (!ParseOneArg("Net.setType", args, INT_ARG, (PyObject**)&arg0)) {
PyErr_SetString(ConstructorError, "wrong parameter for NetType.");
return NULL;
}
2008-03-06 10:46:43 -06:00
net->setType(PyInt_AsType(arg0));
2008-03-06 10:46:43 -06:00
HCATCH
Py_RETURN_NONE;
}
// ---------------------------------------------------------------
2008-04-02 07:11:31 -05:00
// Attribute Method : "PyNet_setDirection ()"
2008-03-06 10:46:43 -06:00
2008-04-02 07:11:31 -05:00
static PyObject* PyNet_setDirection ( PyNet *self, PyObject* args )
2008-03-06 10:46:43 -06:00
{
2008-04-02 07:11:31 -05:00
trace << "PyNet_setDirection()" << endl;
2008-03-06 10:46:43 -06:00
HTRY
2008-04-02 07:11:31 -05:00
METHOD_HEAD ( "Net.setDirection()" )
2008-03-06 10:46:43 -06:00
PyObject* arg0;
2008-04-02 07:11:31 -05:00
if ( ! ParseOneArg ( "Net.setDirection", args, INT_ARG, (PyObject**)&arg0 ) ) return ( NULL );
2008-03-06 10:46:43 -06:00
2008-04-02 07:11:31 -05:00
net->setDirection ( PyInt_AsDirection(arg0) );
2008-03-06 10:46:43 -06:00
HCATCH
Py_RETURN_NONE;
}
// ---------------------------------------------------------------
2008-04-02 07:11:31 -05:00
// Attribute Method : "PyNet_setPosition ()"
2008-03-06 10:46:43 -06:00
2008-04-02 07:11:31 -05:00
static PyObject* PyNet_setPosition ( PyNet *self, PyObject* args )
2008-03-06 10:46:43 -06:00
{
2008-04-02 07:11:31 -05:00
trace << "PyNet_setPosition()" << endl;
2008-03-06 10:46:43 -06:00
HTRY
2008-04-02 07:11:31 -05:00
METHOD_HEAD ( "Net.setPosition()" )
2008-03-06 10:46:43 -06:00
PyObject* arg0;
2008-04-02 07:11:31 -05:00
if ( ! ParseOneArg ( "Net.setPosition", args, POINT_ARG, (PyObject**)&arg0 ) ) return ( NULL );
2008-03-06 10:46:43 -06:00
2008-04-02 07:11:31 -05:00
net->setPosition ( *PYPOINT_O(arg0) );
2008-03-06 10:46:43 -06:00
HCATCH
Py_RETURN_NONE;
}
// ---------------------------------------------------------------
2008-04-02 07:11:31 -05:00
// Attribute Method : "PyNet_merge ()"
2008-03-06 10:46:43 -06:00
2008-04-02 07:11:31 -05:00
static PyObject* PyNet_merge ( PyNet *self, PyObject* args ) {
trace << "PyNet_merge()" << endl;
2008-03-06 10:46:43 -06:00
HTRY
2008-04-02 07:11:31 -05:00
METHOD_HEAD ( "Net.merge()" )
2008-03-06 10:46:43 -06:00
PyObject* arg0;
2008-04-02 07:11:31 -05:00
if ( ! ParseOneArg ( "Net.merge", args, NET_ARG, (PyObject**)&arg0 ) ) return ( NULL );
2008-03-06 10:46:43 -06:00
2008-04-02 07:11:31 -05:00
net->merge ( PYNET_O(arg0) );
2008-03-06 10:46:43 -06:00
HCATCH
Py_RETURN_NONE;
}
// ---------------------------------------------------------------
// PyNet Attribute Method table.
PyMethodDef PyNet_Methods[] =
2008-03-17 08:54:33 -05:00
{ { "getName" , (PyCFunction)PyNet_getName , METH_NOARGS , "Returns the net name." }
, { "getType" , (PyCFunction)PyNet_getType , METH_NOARGS
2008-03-06 10:46:43 -06:00
, "Returns the signal type (by default set to UNDEFINED)." }
2008-03-17 08:54:33 -05:00
, { "getDirection" , (PyCFunction)PyNet_getDirection , METH_NOARGS
2008-03-06 10:46:43 -06:00
, "Returns the signal direction (by default set to UNDEFINED)." }
2008-03-17 08:54:33 -05:00
, { "getX" , (PyCFunction)PyNet_getX , METH_NOARGS , "Returns net abscissa." }
, { "getY" , (PyCFunction)PyNet_getY , METH_NOARGS , "Returns net ordinate." }
2008-10-17 12:27:20 -05:00
, { "getExternalComponents", (PyCFunction)PyNet_getExternalComponents , METH_NOARGS , "Returns the collection of net's external components. (only for an external net)" }
, { "getPlugs" , (PyCFunction)PyNet_getPlugs , METH_NOARGS , "Returns the collection of net's plugs." }
, { "getPins" , (PyCFunction)PyNet_getPins , METH_NOARGS , "Returns the collection of net's pins." }
, { "getSegments" , (PyCFunction)PyNet_getSegments , METH_NOARGS , "Returns the collection of net's segments." }
2008-04-02 07:11:31 -05:00
, { "isGlobal" , (PyCFunction)PyNet_isGlobal , METH_NOARGS, "return true if the net is global" }
, { "isExternal" , (PyCFunction)PyNet_isExternal , METH_NOARGS, "return true if the the net is external." }
, { "isLogical" , (PyCFunction)PyNet_isLogical , METH_NOARGS, "return true if the net is logical ." }
, { "isClock" , (PyCFunction)PyNet_isClock , METH_NOARGS, "return true if the net is a clock" }
, { "isPower" , (PyCFunction)PyNet_isPower , METH_NOARGS, "return true if the net is a power" }
, { "isGround" , (PyCFunction)PyNet_isGround , METH_NOARGS, "return true if the net is a ground" }
, { "isSupply" , (PyCFunction)PyNet_isSupply , METH_NOARGS, "return true if the net is a supply" }
, { "isBound" , (PyCFunction)PyNet_IsPyBound , METH_NOARGS, "return true if the net is bounded to the hurricane net" }
, { "setName" , (PyCFunction)PyNet_setName , METH_VARARGS, "Allows to change net name." }
, { "setGlobal" , (PyCFunction)PyNet_setGlobal , METH_VARARGS, "set the net global." }
, { "setExternal" , (PyCFunction)PyNet_setExternal , METH_VARARGS, "set the net external." }
, { "setType" , (PyCFunction)PyNet_setType , METH_VARARGS, "set the type of the net." }
, { "setDirection" , (PyCFunction)PyNet_setDirection , METH_VARARGS, "set the direction of the net." }
, { "setPosition" , (PyCFunction)PyNet_setPosition , METH_VARARGS, "set the X,Y location of the net." }
, { "merge" , (PyCFunction)PyNet_merge , METH_VARARGS
2008-03-06 10:46:43 -06:00
, "Merges the net <net> to the net <this> which keeps its characteristics (arity, global, external and direction)." }
2008-03-17 08:54:33 -05:00
, { "destroy" , (PyCFunction)PyNet_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
// | "PyNet" Object Methods |
// x-------------------------------------------------------------x
// ---------------------------------------------------------------
// Attribute Method : "PyNet_new ()"
static PyObject* PyNet_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
trace << "PyNet_new()" << endl;
char* name = NULL;
PyCell* pyCell = NULL;
Net* net = NULL;
2008-03-06 10:46:43 -06:00
HTRY
if (PyArg_ParseTuple(args,"O!s:Net.new", &PyTypeCell, &pyCell, &name)) {
net = Net::create(PYCELL_O(pyCell), Name(name));
} else {
PyErr_SetString ( ConstructorError, "invalid number of parameters for Net constructor." );
return NULL;
}
2008-03-06 10:46:43 -06:00
HCATCH
return PyNet_Link(net);
2008-03-06 10:46:43 -06:00
}
DBoDeleteMethod(Net)
PyTypeObjectLinkPyType(Net)
PyTypeObjectConstructor(Net)
#else // End of Python Module Code Part.
// x=================================================================x
// | "PyNet" Shared Library Code Part |
// x=================================================================x
// Link/Creation Method.
DBoLinkCreateMethod(Net)
2008-03-06 10:46:43 -06:00
// ---------------------------------------------------------------
// PyNet Object Definitions.
PyTypeObjectDefinitions(Net)
2008-03-06 10:46:43 -06:00
# endif // End of Shared Library Code Part.
} // End of extern "C".
} // End of Isobar namespace.