In Entity, add Python bindings for "isBound()" and "getId()".
This commit is contained in:
parent
0c1a6def56
commit
ea94175eb4
|
@ -1,14 +1,14 @@
|
||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// This file is part of the Coriolis Software.
|
// This file is part of the Coriolis Software.
|
||||||
// Copyright (c) UPMC 2010-2018, All Rights Reserved
|
// Copyright (c) SU 2010-2020, All Rights Reserved
|
||||||
//
|
//
|
||||||
// +-----------------------------------------------------------------+
|
// +-----------------------------------------------------------------+
|
||||||
// | C O R I O L I S |
|
// | C O R I O L I S |
|
||||||
// | I s o b a r - Hurricane / Python Interface |
|
// | I s o b a r - Hurricane / Python Interface |
|
||||||
// | |
|
// | |
|
||||||
// | Author : Jean-Paul Chaput |
|
// | Author : Jean-Paul Chaput |
|
||||||
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||||
// | =============================================================== |
|
// | =============================================================== |
|
||||||
// | C++ Module : "./PyEntity.cpp" |
|
// | C++ Module : "./PyEntity.cpp" |
|
||||||
// +-----------------------------------------------------------------+
|
// +-----------------------------------------------------------------+
|
||||||
|
@ -47,55 +47,38 @@ extern "C" {
|
||||||
|
|
||||||
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Entity,entity,function)
|
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Entity,entity,function)
|
||||||
|
|
||||||
|
GetBoundStateAttribute(PyEntity_isPyBound, PyEntity,Entity)
|
||||||
// +-------------------------------------------------------------+
|
DirectGetUIntAttribute(PyEntity_getId ,getId,PyEntity,Entity)
|
||||||
// | "PyEntity" Attribute Methods |
|
|
||||||
// +-------------------------------------------------------------+
|
|
||||||
|
|
||||||
DirectGetUIntAttribute(PyEntity_getId, getId, PyEntity, Entity)
|
|
||||||
DBoDestroyAttribute(PyEntity_destroy ,PyEntity)
|
DBoDestroyAttribute(PyEntity_destroy ,PyEntity)
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
static PyObject* PyEntity_getCell ( PyEntity *self )
|
||||||
// Attribute Method : "PyEntity_getCell ()"
|
{
|
||||||
|
cdebug_log(20,0) << "PyEntity_getCell()" << endl;
|
||||||
static PyObject* PyEntity_getCell ( PyEntity *self ) {
|
|
||||||
cdebug_log(20,0) << "PyEntity_getCell ()" << endl;
|
|
||||||
|
|
||||||
Cell* cell = NULL;
|
Cell* cell = NULL;
|
||||||
|
|
||||||
HTRY
|
HTRY
|
||||||
METHOD_HEAD ( "Entity.getCell()" )
|
METHOD_HEAD( "Entity.getCell()" )
|
||||||
cell = entity->getCell ();
|
cell = entity->getCell();
|
||||||
HCATCH
|
HCATCH
|
||||||
|
return PyCell_Link( cell );
|
||||||
return PyCell_Link ( cell );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// PyEntity Attribute Method table.
|
|
||||||
|
|
||||||
PyMethodDef PyEntity_Methods[] =
|
PyMethodDef PyEntity_Methods[] =
|
||||||
{ { "getCell" , (PyCFunction)PyEntity_getCell , METH_NOARGS , "Returns the entity cell." }
|
{ { "getCell" , (PyCFunction)PyEntity_getCell , METH_NOARGS , "Returns the entity cell." }
|
||||||
, { "getId" , (PyCFunction)PyEntity_getId , METH_NOARGS , "Returns unique object (DBo) identifier." }
|
, { "getId" , (PyCFunction)PyEntity_getId , METH_NOARGS , "Returns unique object (DBo) identifier." }
|
||||||
|
, { "isBound" , (PyCFunction)PyEntity_isPyBound , METH_NOARGS , "Returns true if the Entity is bounded to it's Hurricane counterpart." }
|
||||||
, { "destroy" , (PyCFunction)PyEntity_destroy , METH_NOARGS
|
, { "destroy" , (PyCFunction)PyEntity_destroy , METH_NOARGS
|
||||||
, "Destroy associated hurricane object, the python object remains." }
|
, "Destroy associated hurricane object, the python object remains." }
|
||||||
, {NULL, NULL, 0, NULL} /* sentinel */
|
, {NULL, NULL, 0, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// +-------------------------------------------------------------+
|
|
||||||
// | "PyEntity" Object Methods |
|
|
||||||
// +-------------------------------------------------------------+
|
|
||||||
|
|
||||||
DBoDeleteMethod(Entity)
|
DBoDeleteMethod(Entity)
|
||||||
PyTypeObjectLinkPyType(Entity)
|
PyTypeObjectLinkPyType(Entity)
|
||||||
|
|
||||||
|
|
||||||
#else // End of Python Module Code Part.
|
#else // End of Python Module Code Part.
|
||||||
|
|
||||||
|
|
||||||
// +=================================================================+
|
// +=================================================================+
|
||||||
// | "PyEntity" Shared Library Code Part |
|
// | "PyEntity" Shared Library Code Part |
|
||||||
// +=================================================================+
|
// +=================================================================+
|
||||||
|
@ -107,44 +90,45 @@ extern "C" {
|
||||||
// No PyEntity should ever be created, it's not a terminal object
|
// No PyEntity should ever be created, it's not a terminal object
|
||||||
// of the class hierarchy. Instead create the real underlying PyObject.
|
// of the class hierarchy. Instead create the real underlying PyObject.
|
||||||
|
|
||||||
PyObject* PyEntity_NEW ( Entity* entity ) {
|
PyObject* PyEntity_NEW ( Entity* entity )
|
||||||
if ( !entity ) {
|
{
|
||||||
PyErr_SetString ( HurricaneError, "Invalid Entity (bad occurrence)" ); \
|
if (not entity) {
|
||||||
|
PyErr_SetString( HurricaneError, "Invalid Entity (bad occurrence)" );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cell* cell = dynamic_cast<Cell*>(entity);
|
Cell* cell = dynamic_cast<Cell*>( entity );
|
||||||
if ( cell ) return PyCell_Link ( cell );
|
if (cell) return PyCell_Link( cell );
|
||||||
|
|
||||||
Instance* instance = dynamic_cast<Instance*>(entity);
|
Instance* instance = dynamic_cast<Instance*>( entity );
|
||||||
if ( instance ) return PyInstance_Link ( instance );
|
if (instance) return PyInstance_Link( instance );
|
||||||
|
|
||||||
Reference* reference = dynamic_cast<Reference*>(entity);
|
Reference* reference = dynamic_cast<Reference*>( entity );
|
||||||
if ( reference ) return PyReference_Link ( reference );
|
if (reference) return PyReference_Link( reference );
|
||||||
|
|
||||||
RoutingPad* rp = dynamic_cast<RoutingPad*>(entity);
|
RoutingPad* rp = dynamic_cast<RoutingPad*>( entity );
|
||||||
if ( rp ) return PyRoutingPad_Link ( rp );
|
if (rp) return PyRoutingPad_Link( rp );
|
||||||
|
|
||||||
Horizontal* horizontal = dynamic_cast<Horizontal*>(entity);
|
Horizontal* horizontal = dynamic_cast<Horizontal*>( entity );
|
||||||
if ( horizontal ) return PyHorizontal_Link ( horizontal );
|
if (horizontal) return PyHorizontal_Link( horizontal );
|
||||||
|
|
||||||
Vertical* vertical = dynamic_cast<Vertical*>(entity);
|
Vertical* vertical = dynamic_cast<Vertical*>( entity );
|
||||||
if ( vertical ) return PyVertical_Link ( vertical );
|
if (vertical) return PyVertical_Link( vertical );
|
||||||
|
|
||||||
Pad* pad = dynamic_cast<Pad*>(entity);
|
Pad* pad = dynamic_cast<Pad*>( entity );
|
||||||
if ( pad ) return PyPad_Link ( pad );
|
if (pad) return PyPad_Link( pad );
|
||||||
|
|
||||||
Contact* contact = dynamic_cast<Contact*>(entity);
|
Contact* contact = dynamic_cast<Contact*>( entity );
|
||||||
if ( contact ) return PyContact_Link ( contact );
|
if (contact) return PyContact_Link( contact );
|
||||||
|
|
||||||
Plug* plug = dynamic_cast<Plug*>(entity);
|
Plug* plug = dynamic_cast<Plug*>( entity );
|
||||||
if ( plug ) return PyPlug_Link ( plug );
|
if (plug) return PyPlug_Link( plug );
|
||||||
|
|
||||||
Pin* pin = dynamic_cast<Pin*>(entity);
|
Pin* pin = dynamic_cast<Pin*>( entity );
|
||||||
if ( pin ) return PyPin_Link ( pin );
|
if (pin) return PyPin_Link( pin );
|
||||||
|
|
||||||
Net* net = dynamic_cast<Net*>(entity);
|
Net* net = dynamic_cast<Net*>( entity );
|
||||||
if ( net ) return PyNet_Link ( net );
|
if (net) return PyNet_Link( net );
|
||||||
|
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue