collections still in progress
This commit is contained in:
parent
e7df77f51d
commit
07a1213ad8
|
@ -23,36 +23,11 @@ extern "C" {
|
|||
|
||||
DirectDeleteMethod(PyNetCollection_DeAlloc, PyNetCollection)
|
||||
|
||||
static void PyNetCollectionLocator_DeAlloc(PyNetCollectionLocator* pyLocator) {
|
||||
Py_XDECREF(pyLocator->_collection);
|
||||
if (pyLocator->_object) {
|
||||
delete pyLocator->_object;
|
||||
}
|
||||
PyObject_Del(pyLocator);
|
||||
}
|
||||
|
||||
GetLocatorMethod(Net)
|
||||
LocatorNextMethod(Net)
|
||||
CollectionMethods(Net)
|
||||
|
||||
static PyObject* NetLocatorNext(PyNetCollectionLocator* pyLocator) {
|
||||
Locator<Net*>* locator = pyLocator->_object;
|
||||
|
||||
if (locator->isValid()) {
|
||||
Net* net = locator->getElement();
|
||||
locator->progress();
|
||||
return PyNet_Link(net);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern void PyNetCollection_LinkPyType () {
|
||||
trace << "PyNetCollection_LinkType()" << endl;
|
||||
PyTypeNetCollection.tp_iter = (getiterfunc)GetLocator; /* tp_iter */
|
||||
PyTypeNetCollection.tp_dealloc = (destructor)PyNetCollection_DeAlloc;
|
||||
PyTypeNetCollectionLocator.tp_dealloc = (destructor)PyNetCollectionLocator_DeAlloc;
|
||||
PyTypeNetCollectionLocator.tp_iter = PyObject_SelfIter;
|
||||
PyTypeNetCollectionLocator.tp_iternext = (iternextfunc)NetLocatorNext;
|
||||
PyTypeNetCollection.tp_dealloc = (destructor)PyNetCollection_DeAlloc;
|
||||
}
|
||||
|
||||
|
||||
#else // End of Python Module Code Part.
|
||||
|
|
|
@ -382,7 +382,7 @@ extern "C" {
|
|||
// Collection and Locator macros
|
||||
|
||||
|
||||
#define GetLocatorMethod(TYPE) \
|
||||
#define CollectionMethods(TYPE) \
|
||||
static PyObject* GetLocator(Py##TYPE##Collection* collection) { \
|
||||
Py##TYPE##CollectionLocator* cl = \
|
||||
PyObject_New(Py##TYPE##CollectionLocator, &PyType##TYPE##CollectionLocator); \
|
||||
|
@ -393,8 +393,38 @@ extern "C" {
|
|||
cl->_object = collection->_object->getLocator(); \
|
||||
Py_INCREF(collection); \
|
||||
return (PyObject *)cl; \
|
||||
} \
|
||||
\
|
||||
static void Py##TYPE##CollectionLocatorDeAlloc(Py##TYPE##CollectionLocator* locator) { \
|
||||
Py_XDECREF(locator->_collection); \
|
||||
if (locator->_object) { \
|
||||
delete locator->_object; \
|
||||
} \
|
||||
PyObject_Del(locator); \
|
||||
} \
|
||||
\
|
||||
extern void Py##TYPE##Collection_LinkPyType () { \
|
||||
trace << "Py"#TYPE"Collection_LinkType()" << endl; \
|
||||
PyType##TYPE##Collection.tp_iter = (getiterfunc)GetLocator; /* tp_iter */ \
|
||||
PyType##TYPE##Collection.tp_dealloc = (destructor)Py##TYPE##Collection_DeAlloc; \
|
||||
PyType##TYPE##CollectionLocator.tp_dealloc = (destructor)Py##TYPE##CollectionLocatorDeAlloc; \
|
||||
PyType##TYPE##CollectionLocator.tp_iter = PyObject_SelfIter; \
|
||||
PyType##TYPE##CollectionLocator.tp_iternext = (iternextfunc)Py##TYPE##LocatorNext; \
|
||||
}
|
||||
|
||||
#define LocatorNextMethod(TYPE) \
|
||||
static PyObject* Py##TYPE##LocatorNext(Py##TYPE##CollectionLocator* pyLocator) { \
|
||||
Locator<TYPE*>* locator = pyLocator->_object; \
|
||||
\
|
||||
if (locator->isValid()) { \
|
||||
TYPE* object = locator->getElement(); \
|
||||
locator->progress(); \
|
||||
return Py##TYPE##_Link(object); \
|
||||
} \
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Attribute Method For Repr.
|
||||
|
|
Loading…
Reference in New Issue