From 8397e7dccd05f8f1ae26b6428722081daf42fd2c Mon Sep 17 00:00:00 2001 From: Christophe Alexandre Date: Sun, 19 Oct 2008 22:07:32 +0000 Subject: [PATCH] PyCollections implementation --- hurricane/src/isobar/CMakeLists.txt | 16 ++--- hurricane/src/isobar/PyCellCollection.cpp | 52 ++++++++++++++ .../src/isobar/PyComponentCollection.cpp | 52 ++++++++++++++ hurricane/src/isobar/PyHurricane.cpp | 2 - hurricane/src/isobar/PyInstance.cpp | 5 +- hurricane/src/isobar/PyInstanceCollection.cpp | 52 ++++++++++++++ .../src/isobar/PyOccurrenceCollection.cpp | 69 +++++++++++++++++++ hurricane/src/isobar/PyPinCollection.cpp | 52 ++++++++++++++ hurricane/src/isobar/PyPlugCollection.cpp | 52 ++++++++++++++ .../src/isobar/PyReferenceCollection.cpp | 52 ++++++++++++++ hurricane/src/isobar/PySegmentCollection.cpp | 52 ++++++++++++++ .../src/isobar/hurricane/isobar/PyHurricane.h | 17 ++++- 12 files changed, 458 insertions(+), 15 deletions(-) create mode 100644 hurricane/src/isobar/PyCellCollection.cpp create mode 100644 hurricane/src/isobar/PyComponentCollection.cpp create mode 100644 hurricane/src/isobar/PyInstanceCollection.cpp create mode 100644 hurricane/src/isobar/PyOccurrenceCollection.cpp create mode 100644 hurricane/src/isobar/PyPinCollection.cpp create mode 100644 hurricane/src/isobar/PyPlugCollection.cpp create mode 100644 hurricane/src/isobar/PyReferenceCollection.cpp create mode 100644 hurricane/src/isobar/PySegmentCollection.cpp diff --git a/hurricane/src/isobar/CMakeLists.txt b/hurricane/src/isobar/CMakeLists.txt index 48220fa1..6bf10cee 100644 --- a/hurricane/src/isobar/CMakeLists.txt +++ b/hurricane/src/isobar/CMakeLists.txt @@ -6,9 +6,9 @@ set ( sources ProxyProperty.cpp PyBox.cpp PyCell.cpp -#PyCellCollection.cpp + PyCellCollection.cpp PyComponent.cpp -# PyComponentLocator.cpp + PyComponentCollection.cpp PyContact.cpp PyDataBase.cpp PyEntity.cpp @@ -16,24 +16,24 @@ PyHurricane.cpp PyHyperNet.cpp PyInstance.cpp -#PyInstanceLocator.cpp + PyInstanceCollection.cpp PyLayer.cpp PyLibrary.cpp PyName.cpp PyNet.cpp PyNetCollection.cpp PyOccurrence.cpp - #PyOccurrenceLocator.cpp + PyOccurrenceCollection.cpp PyPath.cpp PyPin.cpp - #PyPinLocator.cpp + PyPinCollection.cpp PyPlug.cpp - #PyPlugLocator.cpp + PyPlugCollection.cpp PyPoint.cpp PyReference.cpp - #PyReferenceLocator.cpp + PyReferenceCollection.cpp PySegment.cpp - #PySegmentLocator.cpp + PySegmentCollection.cpp PyTechnology.cpp PyTransformation.cpp PyDbU.cpp diff --git a/hurricane/src/isobar/PyCellCollection.cpp b/hurricane/src/isobar/PyCellCollection.cpp new file mode 100644 index 00000000..05500926 --- /dev/null +++ b/hurricane/src/isobar/PyCellCollection.cpp @@ -0,0 +1,52 @@ +#include "hurricane/isobar/PyInstanceCollection.h" +#include "hurricane/isobar/PyInstance.h" + +namespace Isobar { + +using namespace Hurricane; + + +extern "C" { + + +// x=================================================================x +// | "PyInstanceCollection" Python Module Code Part | +// x=================================================================x + +#if defined(__PYTHON_MODULE__) + + + // x-------------------------------------------------------------x + // | "PyInstanceCollection" Attribute Methods | + // x-------------------------------------------------------------x + + + DirectDeleteMethod(PyInstanceCollection_DeAlloc, PyInstanceCollection) + + + LocatorNextMethod(Instance) + CollectionMethods(Instance) + + + + +#else // End of Python Module Code Part. + + +// x=================================================================x +// | "PyInstanceCollection" Shared Library Code Part | +// x=================================================================x + + + // --------------------------------------------------------------- + // PyInstanceCollection Object Definitions. + + PyTypeCollectionObjectDefinitions(InstanceCollection) + PyTypeCollectionObjectDefinitions(InstanceCollectionLocator) + +#endif // End of Shared Library Code Part. + + +} // End of extern "C". + +} // End of Isobar namespace. diff --git a/hurricane/src/isobar/PyComponentCollection.cpp b/hurricane/src/isobar/PyComponentCollection.cpp new file mode 100644 index 00000000..ded8596c --- /dev/null +++ b/hurricane/src/isobar/PyComponentCollection.cpp @@ -0,0 +1,52 @@ +#include "hurricane/isobar/PyComponentCollection.h" +#include "hurricane/isobar/PyComponent.h" + +namespace Isobar { + +using namespace Hurricane; + + +extern "C" { + + +// x=================================================================x +// | "PyComponentCollection" Python Module Code Part | +// x=================================================================x + +#if defined(__PYTHON_MODULE__) + + + // x-------------------------------------------------------------x + // | "PyComponentCollection" Attribute Methods | + // x-------------------------------------------------------------x + + + DirectDeleteMethod(PyComponentCollection_DeAlloc, PyComponentCollection) + + + EntityLocatorNextMethod(Component) + CollectionMethods(Component) + + + + +#else // End of Python Module Code Part. + + +// x=================================================================x +// | "PyComponentCollection" Shared Library Code Part | +// x=================================================================x + + + // --------------------------------------------------------------- + // PyComponentCollection Object Definitions. + + PyTypeCollectionObjectDefinitions(ComponentCollection) + PyTypeCollectionObjectDefinitions(ComponentCollectionLocator) + +#endif // End of Shared Library Code Part. + + +} // End of extern "C". + +} // End of Isobar namespace. diff --git a/hurricane/src/isobar/PyHurricane.cpp b/hurricane/src/isobar/PyHurricane.cpp index c2f39c10..ad3b861f 100644 --- a/hurricane/src/isobar/PyHurricane.cpp +++ b/hurricane/src/isobar/PyHurricane.cpp @@ -702,8 +702,6 @@ extern "C" { NetLoadConstants ( dictionnary ); InstanceLoadConstants ( dictionnary ); PinLoadConstants ( dictionnary ); - - trace_on(); } diff --git a/hurricane/src/isobar/PyInstance.cpp b/hurricane/src/isobar/PyInstance.cpp index c402edaa..cdb725b0 100644 --- a/hurricane/src/isobar/PyInstance.cpp +++ b/hurricane/src/isobar/PyInstance.cpp @@ -481,7 +481,7 @@ extern "C" { PyTypeObjectConstructor(Instance) -# else // End of Python Module Code Part. +#else // End of Python Module Code Part. // x=================================================================x @@ -489,9 +489,6 @@ extern "C" { // x=================================================================x - - - // Link/Creation Method. DBoLinkCreateMethod(Instance) diff --git a/hurricane/src/isobar/PyInstanceCollection.cpp b/hurricane/src/isobar/PyInstanceCollection.cpp new file mode 100644 index 00000000..9694a574 --- /dev/null +++ b/hurricane/src/isobar/PyInstanceCollection.cpp @@ -0,0 +1,52 @@ +#include "hurricane/isobar/PyCellCollection.h" +#include "hurricane/isobar/PyCell.h" + +namespace Isobar { + +using namespace Hurricane; + + +extern "C" { + + +// x=================================================================x +// | "PyCellCollection" Python Module Code Part | +// x=================================================================x + +#if defined(__PYTHON_MODULE__) + + + // x-------------------------------------------------------------x + // | "PyCellCollection" Attribute Methods | + // x-------------------------------------------------------------x + + + DirectDeleteMethod(PyCellCollection_DeAlloc, PyCellCollection) + + + LocatorNextMethod(Cell) + CollectionMethods(Cell) + + + + +#else // End of Python Module Code Part. + + +// x=================================================================x +// | "PyCellCollection" Shared Library Code Part | +// x=================================================================x + + + // --------------------------------------------------------------- + // PyCellCollection Object Definitions. + + PyTypeCollectionObjectDefinitions(CellCollection) + PyTypeCollectionObjectDefinitions(CellCollectionLocator) + +#endif // End of Shared Library Code Part. + + +} // End of extern "C". + +} // End of Isobar namespace. diff --git a/hurricane/src/isobar/PyOccurrenceCollection.cpp b/hurricane/src/isobar/PyOccurrenceCollection.cpp new file mode 100644 index 00000000..b49ae14b --- /dev/null +++ b/hurricane/src/isobar/PyOccurrenceCollection.cpp @@ -0,0 +1,69 @@ +#include "hurricane/isobar/PyOccurrenceCollection.h" +#include "hurricane/isobar/PyOccurrence.h" + +namespace Isobar { + +using namespace Hurricane; + + +extern "C" { + + +// x=================================================================x +// | "PyOccurrenceCollection" Python Module Code Part | +// x=================================================================x + +#if defined(__PYTHON_MODULE__) + + + // x-------------------------------------------------------------x + // | "PyOccurrenceCollection" Attribute Methods | + // x-------------------------------------------------------------x + + + DirectDeleteMethod(PyOccurrenceCollection_DeAlloc, PyOccurrenceCollection) + + static PyObject* PyOccurrenceLocatorNext(PyOccurrenceCollectionLocator* pyLocator) { + Locator* locator = pyLocator->_object; + + HTRY + if (locator->isValid()) { + Occurrence occurrence = locator->getElement(); + PyOccurrence* pyOccurrence = PyObject_NEW(PyOccurrence, &PyTypeOccurrence); + if (pyOccurrence == NULL) { + return NULL; + } + pyOccurrence->_object = new Occurrence(occurrence); + + locator->progress(); + return (PyObject*)pyOccurrence; + } + HCATCH + return NULL; + } + + CollectionMethods(Occurrence) + + + + +#else // End of Python Module Code Part. + + +// x=================================================================x +// | "PyOccurrenceCollection" Shared Library Code Part | +// x=================================================================x + + + // --------------------------------------------------------------- + // PyOccurrenceCollection Object Definitions. + + PyTypeCollectionObjectDefinitions(OccurrenceCollection) + PyTypeCollectionObjectDefinitions(OccurrenceCollectionLocator) + +#endif // End of Shared Library Code Part. + + +} // End of extern "C". + +} // End of Isobar namespace. diff --git a/hurricane/src/isobar/PyPinCollection.cpp b/hurricane/src/isobar/PyPinCollection.cpp new file mode 100644 index 00000000..96c4cef4 --- /dev/null +++ b/hurricane/src/isobar/PyPinCollection.cpp @@ -0,0 +1,52 @@ +#include "hurricane/isobar/PyPinCollection.h" +#include "hurricane/isobar/PyPin.h" + +namespace Isobar { + +using namespace Hurricane; + + +extern "C" { + + +// x=================================================================x +// | "PyPinCollection" Python Module Code Part | +// x=================================================================x + +#if defined(__PYTHON_MODULE__) + + + // x-------------------------------------------------------------x + // | "PyPinCollection" Attribute Methods | + // x-------------------------------------------------------------x + + + DirectDeleteMethod(PyPinCollection_DeAlloc, PyPinCollection) + + + LocatorNextMethod(Pin) + CollectionMethods(Pin) + + + + +#else // End of Python Module Code Part. + + +// x=================================================================x +// | "PyPinCollection" Shared Library Code Part | +// x=================================================================x + + + // --------------------------------------------------------------- + // PyPinCollection Object Definitions. + + PyTypeCollectionObjectDefinitions(PinCollection) + PyTypeCollectionObjectDefinitions(PinCollectionLocator) + +#endif // End of Shared Library Code Part. + + +} // End of extern "C". + +} // End of Isobar namespace. diff --git a/hurricane/src/isobar/PyPlugCollection.cpp b/hurricane/src/isobar/PyPlugCollection.cpp new file mode 100644 index 00000000..02d46dcd --- /dev/null +++ b/hurricane/src/isobar/PyPlugCollection.cpp @@ -0,0 +1,52 @@ +#include "hurricane/isobar/PyPlugCollection.h" +#include "hurricane/isobar/PyPlug.h" + +namespace Isobar { + +using namespace Hurricane; + + +extern "C" { + + +// x=================================================================x +// | "PyPlugCollection" Python Module Code Part | +// x=================================================================x + +#if defined(__PYTHON_MODULE__) + + + // x-------------------------------------------------------------x + // | "PyPlugCollection" Attribute Methods | + // x-------------------------------------------------------------x + + + DirectDeleteMethod(PyPlugCollection_DeAlloc, PyPlugCollection) + + + LocatorNextMethod(Plug) + CollectionMethods(Plug) + + + + +#else // End of Python Module Code Part. + + +// x=================================================================x +// | "PyPlugCollection" Shared Library Code Part | +// x=================================================================x + + + // --------------------------------------------------------------- + // PyPlugCollection Object Definitions. + + PyTypeCollectionObjectDefinitions(PlugCollection) + PyTypeCollectionObjectDefinitions(PlugCollectionLocator) + +#endif // End of Shared Library Code Part. + + +} // End of extern "C". + +} // End of Isobar namespace. diff --git a/hurricane/src/isobar/PyReferenceCollection.cpp b/hurricane/src/isobar/PyReferenceCollection.cpp new file mode 100644 index 00000000..8f073dc9 --- /dev/null +++ b/hurricane/src/isobar/PyReferenceCollection.cpp @@ -0,0 +1,52 @@ +#include "hurricane/isobar/PyReferenceCollection.h" +#include "hurricane/isobar/PyReference.h" + +namespace Isobar { + +using namespace Hurricane; + + +extern "C" { + + +// x=================================================================x +// | "PyReferenceCollection" Python Module Code Part | +// x=================================================================x + +#if defined(__PYTHON_MODULE__) + + + // x-------------------------------------------------------------x + // | "PyReferenceCollection" Attribute Methods | + // x-------------------------------------------------------------x + + + DirectDeleteMethod(PyReferenceCollection_DeAlloc, PyReferenceCollection) + + + LocatorNextMethod(Reference) + CollectionMethods(Reference) + + + + +#else // End of Python Module Code Part. + + +// x=================================================================x +// | "PyReferenceCollection" Shared Library Code Part | +// x=================================================================x + + + // --------------------------------------------------------------- + // PyReferenceCollection Object Definitions. + + PyTypeCollectionObjectDefinitions(ReferenceCollection) + PyTypeCollectionObjectDefinitions(ReferenceCollectionLocator) + +#endif // End of Shared Library Code Part. + + +} // End of extern "C". + +} // End of Isobar namespace. diff --git a/hurricane/src/isobar/PySegmentCollection.cpp b/hurricane/src/isobar/PySegmentCollection.cpp new file mode 100644 index 00000000..b4da5796 --- /dev/null +++ b/hurricane/src/isobar/PySegmentCollection.cpp @@ -0,0 +1,52 @@ +#include "hurricane/isobar/PySegmentCollection.h" +#include "hurricane/isobar/PySegment.h" + +namespace Isobar { + +using namespace Hurricane; + + +extern "C" { + + +// x=================================================================x +// | "PySegmentCollection" Python Module Code Part | +// x=================================================================x + +#if defined(__PYTHON_MODULE__) + + + // x-------------------------------------------------------------x + // | "PySegmentCollection" Attribute Methods | + // x-------------------------------------------------------------x + + + DirectDeleteMethod(PySegmentCollection_DeAlloc, PySegmentCollection) + + + EntityLocatorNextMethod(Segment) + CollectionMethods(Segment) + + + + +#else // End of Python Module Code Part. + + +// x=================================================================x +// | "PySegmentCollection" Shared Library Code Part | +// x=================================================================x + + + // --------------------------------------------------------------- + // PySegmentCollection Object Definitions. + + PyTypeCollectionObjectDefinitions(SegmentCollection) + PyTypeCollectionObjectDefinitions(SegmentCollectionLocator) + +#endif // End of Shared Library Code Part. + + +} // End of extern "C". + +} // End of Isobar namespace. diff --git a/hurricane/src/isobar/hurricane/isobar/PyHurricane.h b/hurricane/src/isobar/hurricane/isobar/PyHurricane.h index f168b95f..dcbe391e 100644 --- a/hurricane/src/isobar/hurricane/isobar/PyHurricane.h +++ b/hurricane/src/isobar/hurricane/isobar/PyHurricane.h @@ -415,12 +415,27 @@ extern "C" { #define LocatorNextMethod(TYPE) \ static PyObject* Py##TYPE##LocatorNext(Py##TYPE##CollectionLocator* pyLocator) { \ Locator* locator = pyLocator->_object; \ - \ + HTRY \ if (locator->isValid()) { \ TYPE* object = locator->getElement(); \ locator->progress(); \ return Py##TYPE##_Link(object); \ } \ + HCATCH \ + return NULL; \ + } + + +#define EntityLocatorNextMethod(TYPE) \ + static PyObject* Py##TYPE##LocatorNext(Py##TYPE##CollectionLocator* pyLocator) { \ + Locator* locator = pyLocator->_object; \ + HTRY \ + if (locator->isValid()) { \ + TYPE* object = locator->getElement(); \ + locator->progress(); \ + return PyEntity_NEW(object); \ + } \ + HCATCH \ return NULL; \ }