Added support to map vectors of Entity into Python lists of PyEntity.

This commit is contained in:
Jean-Paul Chaput 2022-09-21 17:30:30 +02:00
parent 16428ffaa9
commit 3f1148b105
3 changed files with 21 additions and 5 deletions

View File

@ -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.

View File

@ -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 )

View File

@ -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