net collections in progress

This commit is contained in:
Christophe Alexandre 2008-10-14 10:48:53 +00:00
parent a102abdb8e
commit 0f46cfdb7f
5 changed files with 255 additions and 10 deletions

View File

@ -22,6 +22,7 @@
PyName.cpp PyName.cpp
PyNet.cpp PyNet.cpp
PyNetLocator.cpp PyNetLocator.cpp
PyNetCollection.cpp
PyOccurrence.cpp PyOccurrence.cpp
PyOccurrenceLocator.cpp PyOccurrenceLocator.cpp
PyPath.cpp PyPath.cpp

View File

@ -58,6 +58,7 @@
#include "hurricane/isobar/ProxyProperty.h" #include "hurricane/isobar/ProxyProperty.h"
#include "hurricane/isobar/PyNet.h" #include "hurricane/isobar/PyNet.h"
#include "hurricane/isobar/PyNetLocator.h" #include "hurricane/isobar/PyNetLocator.h"
#include "hurricane/isobar/PyNetCollection.h"
#include "hurricane/isobar/PyReferenceLocator.h" #include "hurricane/isobar/PyReferenceLocator.h"
#include "hurricane/isobar/PyInstanceLocator.h" #include "hurricane/isobar/PyInstanceLocator.h"
#include "hurricane/isobar/PyOccurrenceLocator.h" #include "hurricane/isobar/PyOccurrenceLocator.h"
@ -377,25 +378,25 @@ extern "C" {
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Attribute Method : "PyCell_getNetsLocator ()" // Attribute Method : "PyCell_getNets ()"
static PyObject* PyCell_getNetsLocator ( PyCell *self ) { static PyObject* PyCell_getNets ( PyCell *self ) {
trace << "PyCell_getNetsLocator ()" << endl; trace << "PyCell_getNets()" << endl;
METHOD_HEAD ( "Cell.getNetsLocator()" ) METHOD_HEAD ( "Cell.getNets()" )
PyNetLocator* pyNetLocator = NULL; PyNetCollection* pyNetCollection = NULL;
HTRY HTRY
Nets nets = cell->getNets (); Nets nets = cell->getNets ();
pyNetLocator = PyObject_NEW ( PyNetLocator, &PyTypeNetLocator ); pyNetCollection = PyObject_NEW ( PyNetCollection, &PyTypeNetCollection);
if (pyNetLocator == NULL) { return NULL; } if (pyNetCollection == NULL) { return NULL; }
pyNetLocator->_object = nets.getLocator (); pyNetCollection->_object = nets;
HCATCH HCATCH
return ( (PyObject*)pyNetLocator ); return ( (PyObject*)pyNetCollection);
} }
@ -612,7 +613,7 @@ extern "C" {
, { "getReferencesLocator" , (PyCFunction)PyCell_getReferencesLocator , METH_VARARGS, "Returns the collection of all references belonging to the cell." } , { "getReferencesLocator" , (PyCFunction)PyCell_getReferencesLocator , METH_VARARGS, "Returns the collection of all references belonging to the cell." }
, { "getHyperNetsLocator" , (PyCFunction)PyCell_getHyperNetsLocator , METH_VARARGS, "Returns the collection of all hyperNets belonging to the cell." } , { "getHyperNetsLocator" , (PyCFunction)PyCell_getHyperNetsLocator , METH_VARARGS, "Returns the collection of all hyperNets belonging to the cell." }
, { "getNet" , (PyCFunction)PyCell_getNet , METH_VARARGS, "Returns the net of name <name> if it exists, else NULL." } , { "getNet" , (PyCFunction)PyCell_getNet , METH_VARARGS, "Returns the net of name <name> if it exists, else NULL." }
, { "getNetsLocator" , (PyCFunction)PyCell_getNetsLocator , METH_NOARGS , "Returns the collection of all nets of the cell." } , { "getNets" , (PyCFunction)PyCell_getNets , METH_NOARGS , "Returns the collection of all nets of the cell." }
, { "getExternalNetsLocator", (PyCFunction)PyCell_getExternalNetsLocator, METH_NOARGS , "Returns the collection of all external nets of the cell." } , { "getExternalNetsLocator", (PyCFunction)PyCell_getExternalNetsLocator, METH_NOARGS , "Returns the collection of all external nets of the cell." }
, { "getClockNetsLocator" , (PyCFunction)PyCell_getClockNetsLocator , METH_NOARGS , "Returns the collection of all clock nets of the cell." } , { "getClockNetsLocator" , (PyCFunction)PyCell_getClockNetsLocator , METH_NOARGS , "Returns the collection of all clock nets of the cell." }
, { "getSupplyNetsLocator", (PyCFunction)PyCell_getSupplyNetsLocator, METH_NOARGS , "Returns the collection of all supply nets of the cell." } , { "getSupplyNetsLocator", (PyCFunction)PyCell_getSupplyNetsLocator, METH_NOARGS , "Returns the collection of all supply nets of the cell." }

View File

@ -84,6 +84,7 @@
#include "hurricane/isobar/PyComponentLocator.h" #include "hurricane/isobar/PyComponentLocator.h"
#include "hurricane/isobar/PyOccurrenceLocator.h" #include "hurricane/isobar/PyOccurrenceLocator.h"
#include "hurricane/isobar/PyNetLocator.h" #include "hurricane/isobar/PyNetLocator.h"
#include "hurricane/isobar/PyNetCollection.h"
#include "hurricane/isobar/PyCellLocator.h" #include "hurricane/isobar/PyCellLocator.h"
#include "hurricane/isobar/PyReferenceLocator.h" #include "hurricane/isobar/PyReferenceLocator.h"
#include "hurricane/isobar/PyTechnology.h" #include "hurricane/isobar/PyTechnology.h"
@ -555,6 +556,7 @@ extern "C" {
PyInstanceLocator_LinkPyType (); PyInstanceLocator_LinkPyType ();
PyPlugLocator_LinkPyType (); PyPlugLocator_LinkPyType ();
PyNetLocator_LinkPyType (); PyNetLocator_LinkPyType ();
PyNetCollection_LinkPyType ();
PyCellLocator_LinkPyType (); PyCellLocator_LinkPyType ();
PyPinLocator_LinkPyType (); PyPinLocator_LinkPyType ();
PySegmentLocator_LinkPyType (); PySegmentLocator_LinkPyType ();
@ -607,6 +609,8 @@ extern "C" {
PYTYPE_READY ( InstanceLocator ) PYTYPE_READY ( InstanceLocator )
PYTYPE_READY ( PlugLocator ) PYTYPE_READY ( PlugLocator )
PYTYPE_READY ( NetLocator ) PYTYPE_READY ( NetLocator )
PYTYPE_READY ( NetCollection )
PYTYPE_READY ( NetCollectionLocator )
PYTYPE_READY ( CellLocator ) PYTYPE_READY ( CellLocator )
PYTYPE_READY ( PinLocator ) PYTYPE_READY ( PinLocator )
PYTYPE_READY ( SegmentLocator ) PYTYPE_READY ( SegmentLocator )
@ -656,6 +660,7 @@ extern "C" {
__cs.AddType ( "refLoc" , &PyTypeReferenceLocator , "<ReferenceLocator>" , false ); __cs.AddType ( "refLoc" , &PyTypeReferenceLocator , "<ReferenceLocator>" , false );
__cs.AddType ( "net" , &PyTypeNet , "<Net>" , false, "ent" ); __cs.AddType ( "net" , &PyTypeNet , "<Net>" , false, "ent" );
__cs.AddType ( "netLoc" , &PyTypeNetLocator , "<NetLocator>" , false ); __cs.AddType ( "netLoc" , &PyTypeNetLocator , "<NetLocator>" , false );
__cs.AddType ( "netCol" , &PyTypeNetCollection , "<NetCollection>" , false );
__cs.AddType ( "hyperNet" , &PyTypeHyperNet , "<HyperNet>" , false ); __cs.AddType ( "hyperNet" , &PyTypeHyperNet , "<HyperNet>" , false );
__cs.AddType ( "pin" , &PyTypePin , "<Pin>" , false, "contact" ); __cs.AddType ( "pin" , &PyTypePin , "<Pin>" , false, "contact" );
__cs.AddType ( "pinLoc" , &PyTypePinLocator , "<PinLocator>" , false ); __cs.AddType ( "pinLoc" , &PyTypePinLocator , "<PinLocator>" , false );

View File

@ -0,0 +1,192 @@
#include "hurricane/isobar/PyNetCollection.h"
#include "hurricane/isobar/PyNet.h"
namespace Isobar {
using namespace Hurricane;
extern "C" {
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Collection<Net*>,collection,function)
// x=================================================================x
// | "PyNetCollection" Python Module Code Part |
// x=================================================================x
#if defined(__PYTHON_MODULE__)
// x-------------------------------------------------------------x
// | "PyNetCollection" Attribute Methods |
// x-------------------------------------------------------------x
#if 0
// Standart Predicates (Attributes).
DirectGetBoolAttribute(PyNetLocator_isValid,isValid,PyNetLocator,Locator<Net*>)
// Standart Locator Accessors (Attributes).
LocatorProgressAttribute(Net)
LocatorGetElementAttribute(Net)
LocatorGetCloneAttribute(Net)
// Standart destroy (Attribute).
DirectDestroyAttribute(PyNetLocator_destroy, PyNetLocator)
// ---------------------------------------------------------------
// PyNetLocator Attribute Method table.
PyMethodDef PyNetLocator_Methods[] =
{ { "isValid" , (PyCFunction)PyNetLocator_isValid , METH_NOARGS , "Returns true while the walk has not exhausted the set of elements, else false." }
, { "progress" , (PyCFunction)PyNetLocator_progress , METH_NOARGS , "Moves forward the locator to the following element." }
, { "getElement" , (PyCFunction)PyNetLocator_getElement , METH_NOARGS , "Returns the current element (or the value Type() when the locator is not or no longer valid)." }
, { "getClone" , (PyCFunction)PyNetLocator_getClone , METH_NOARGS , "This function allocates and returns a new locator that will have the same visiting course than the remaining one of the locator being cloned." }
, { "destroy" , (PyCFunction)PyNetLocator_destroy , METH_NOARGS
, "Destroy associated hurricane object, the python object remains." }
, {NULL, NULL, 0, NULL} /* sentinel */
};
// x-------------------------------------------------------------x
// | "PyNetLocator" Object Methods |
// x-------------------------------------------------------------x
DirectDeleteMethod(PyNetLocator_DeAlloc,PyNetLocator)
LocatorPyTypeObjectLinkPyType(Net, Net*)
#endif
static PyObject* GetNetLocator(PyNetCollection *collection) {
PyNetCollectionLocator* nl = PyObject_New(PyNetCollectionLocator, &PyTypeNetCollectionLocator);
if (nl == NULL) {
return NULL;
}
Py_INCREF(nl);
nl->_object = collection->_object.getLocator();
return (PyObject *)nl;
}
static PyObject* NetLocatorNext(PyNetCollectionLocator* pyLocator) {
Locator<Net*>* locator = pyLocator->_object;
if (locator->isValid()) {
cerr << "akecoucou" << endl;
Net* net = locator->getElement();
locator->progress();
return PyNet_Link(net);
}
cerr << "end" << endl;
return NULL;
}
extern void PyNetCollection_LinkPyType () {
trace << "PyNetCollection_LinkType()" << endl;
PyTypeNetCollection.tp_iter = (getiterfunc)GetNetLocator; /* tp_iter */
PyTypeNetCollectionLocator.tp_iter = PyObject_SelfIter;
PyTypeNetCollectionLocator.tp_iternext = (iternextfunc)NetLocatorNext;
}
#else // End of Python Module Code Part.
// x=================================================================x
// | "PyNetCollection" Shared Library Code Part |
// x=================================================================x
// ---------------------------------------------------------------
// PyNetCollection Object Definitions.
PyTypeObject PyTypeNetCollection =
{ PyObject_HEAD_INIT(NULL)
0 /* ob_size. */
, "Hurricane.NetCollection" /* tp_name. */
, sizeof(PyNetCollection) /* tp_basicsize. */
, 0 /* tp_itemsize. */
/* methods. */
, 0 /* tp_dealloc. */
, 0 /* tp_print. */
, 0 /* tp_getattr. */
, 0 /* tp_setattr. */
, 0 /* tp_compare. */
, 0 /* tp_repr. */
, 0 /* tp_as_number. */
, 0 /* tp_as_sequence. */
, 0 /* tp_as_mapping. */
, 0 /* tp_hash. */
, 0 /* tp_call. */
, 0 /* tp_str */
, 0 /* tp_getattro. */
, 0 /* tp_setattro. */
, 0 /* tp_as_buffer. */
, Py_TPFLAGS_DEFAULT /* tp_flags. */
, "NetCollection objects" /* tp_doc. */
, 0 /* tp_traverse */
, 0 /* tp_clear */
, 0 /* tp_richcompare */
, 0 /* tp_weaklistoffset */
, 0 /* tp_iter */
, 0 /* tp_iternext */
, 0 /* tp_methods */
, 0
};
PyTypeObject PyTypeNetCollectionLocator =
{ PyObject_HEAD_INIT(NULL)
0 /* ob_size. */
, "Hurricane.NetLocator" /* tp_name. */
, sizeof(PyNetCollectionLocator) /* tp_basicsize. */
, 0 /* tp_itemsize. */
/* methods. */
, 0 /* tp_dealloc. */
, 0 /* tp_print. */
, 0 /* tp_getattr. */
, 0 /* tp_setattr. */
, 0 /* tp_compare. */
, 0 /* tp_repr. */
, 0 /* tp_as_number. */
, 0 /* tp_as_sequence. */
, 0 /* tp_as_mapping. */
, 0 /* tp_hash. */
, 0 /* tp_call. */
, 0 /* tp_str */
, 0 /* tp_getattro. */
, 0 /* tp_setattro. */
, 0 /* tp_as_buffer. */
, Py_TPFLAGS_DEFAULT /* tp_flags. */
, "NetLocator objects" /* tp_doc. */
, 0 /* tp_traverse */
, 0 /* tp_clear */
, 0 /* tp_richcompare */
, 0 /* tp_weaklistoffset */
, 0 /* tp_iter */
, 0 /* tp_iternext */
, 0 /* tp_methods */
, 0
};
#endif // End of Shared Library Code Part.
} // End of extern "C".
} // End of Isobar namespace.

View File

@ -0,0 +1,46 @@
#ifndef __PYNETCOLLECTION__
#define __PYNETCOLLECTION__
#include "hurricane/isobar/PyHurricane.h"
#include "hurricane/Net.h"
#include "hurricane/Nets.h"
namespace Isobar {
extern "C" {
// -------------------------------------------------------------------
// Python Object : "PyNetCollection".
typedef struct {
PyObject_HEAD
Hurricane::Nets _object;
} PyNetCollection;
typedef struct {
PyObject_HEAD
Hurricane::Locator<Hurricane::Net*>* _object;
} PyNetCollectionLocator;
// -------------------------------------------------------------------
// Functions & Types exported to "PyHurricane.ccp".
extern PyTypeObject PyTypeNetCollection;
extern PyTypeObject PyTypeNetCollectionLocator;
extern void PyNetCollection_LinkPyType();
extern void PyNetCollectionLocator_LinkPyType();
} // End of extern "C".
} // End of Isobar namespace.
#endif