From 3f1148b1059de5996e2677c04fd2825155510267 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Wed, 21 Sep 2022 17:30:30 +0200 Subject: [PATCH] Added support to map vectors of Entity into Python lists of PyEntity. --- hurricane/src/isobar/PyEntity.cpp | 13 +++++++++++++ hurricane/src/isobar/PyHurricane.cpp | 3 +++ hurricane/src/isobar/hurricane/isobar/PyEntity.h | 10 +++++----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/hurricane/src/isobar/PyEntity.cpp b/hurricane/src/isobar/PyEntity.cpp index cf2fa6d7..b1f4fb39 100644 --- a/hurricane/src/isobar/PyEntity.cpp +++ b/hurricane/src/isobar/PyEntity.cpp @@ -151,6 +151,10 @@ extern "C" { DBoDeleteMethod(Entity) PyTypeObjectLinkPyType(Entity) + IteratorNextMethod(Entity) + VectorMethods (Entity) + + #else // End of Python Module Code Part. // +=================================================================+ @@ -214,9 +218,18 @@ extern "C" { } + PyObject* PyEntity_Link ( Entity* entity ) + { return PyEntity_NEW( entity ); } + + PyTypeRootObjectDefinitions(Entity) + PyTypeVectorObjectDefinitions(EntityVector) + PyTypeVectorObjectDefinitions(EntityVectorIterator) + + + // --------------------------------------------------------------- // PyEntity Object Definitions. diff --git a/hurricane/src/isobar/PyHurricane.cpp b/hurricane/src/isobar/PyHurricane.cpp index b7e2ed0b..3abe04ce 100644 --- a/hurricane/src/isobar/PyHurricane.cpp +++ b/hurricane/src/isobar/PyHurricane.cpp @@ -553,6 +553,7 @@ extern "C" { PyEntity_LinkPyType (); PyTypeEntity.tp_getattro = PyEntity_getattro; PyTypeEntity.tp_setattro = PyEntity_setattro; + PyEntityVector_LinkPyType (); PyLayer_LinkPyType (); PyLayerMask_LinkPyType (); PyBasicLayer_LinkPyType (); @@ -630,6 +631,8 @@ extern "C" { PYTYPE_READY( Technology ) PYTYPE_READY( Library ) PYTYPE_READY( Entity ) + PYTYPE_READY( EntityVector ) + PYTYPE_READY( EntityVectorIterator ) PYTYPE_READY( Hook ) PYTYPE_READY( HookCollection ) PYTYPE_READY( Material ) diff --git a/hurricane/src/isobar/hurricane/isobar/PyEntity.h b/hurricane/src/isobar/hurricane/isobar/PyEntity.h index 2abe5325..7a6a0761 100644 --- a/hurricane/src/isobar/hurricane/isobar/PyEntity.h +++ b/hurricane/src/isobar/hurricane/isobar/PyEntity.h @@ -14,9 +14,7 @@ // +-----------------------------------------------------------------+ -#ifndef ISOBAR_PY_ENTITY_H -#define ISOBAR_PY_ENTITY_H - +#pragma once #include "hurricane/isobar/PyHurricane.h" #include "hurricane/Entity.h" @@ -39,6 +37,7 @@ namespace Isobar { // Functions & Types exported to "PyHurricane.ccp". extern PyObject* PyEntity_NEW ( Hurricane::Entity* entity ); + extern PyObject* PyEntity_Link ( Hurricane::Entity* entity ); extern PyObject* PyEntity_getattro ( PyObject* self, PyObject* attrName ); extern int32_t PyEntity_setattro ( PyObject* self, PyObject* attrName, PyObject* value ); extern void PyEntity_LinkPyType (); @@ -51,6 +50,9 @@ namespace Isobar { #define PYENTITY(v) ( (PyEntity*)(v) ) #define PYENTITY_O(v) ( PYENTITY(v)->_object ) +declareVectorObject(Entity); + + } // extern "C". @@ -59,5 +61,3 @@ namespace Isobar { } // Isobar namespace. - -#endif // ISOBAR_PY_ENTITY_H