2014-06-09 17:17:41 -05:00
|
|
|
// -*- C++ -*-
|
|
|
|
//
|
|
|
|
// This file is part of the Coriolis Software.
|
2016-01-20 17:41:19 -06:00
|
|
|
// Copyright (c) UPMC 2013-2016, All Rights Reserved
|
2014-06-09 17:17:41 -05:00
|
|
|
//
|
|
|
|
// +-----------------------------------------------------------------+
|
2008-03-06 10:46:43 -06:00
|
|
|
// | C O R I O L I S |
|
|
|
|
// | I s o b a r - Hurricane / Python Interface |
|
|
|
|
// | |
|
|
|
|
// | Author : Jean-Paul CHAPUT |
|
|
|
|
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
|
|
|
// | =============================================================== |
|
|
|
|
// | C++ Module : "./PyOccurrence.cpp" |
|
2014-06-09 17:17:41 -05:00
|
|
|
// +-----------------------------------------------------------------+
|
|
|
|
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-05-21 17:46:29 -05:00
|
|
|
#include "hurricane/isobar/PyBox.h"
|
|
|
|
#include "hurricane/isobar/PyTransformation.h"
|
|
|
|
#include "hurricane/isobar/PyPath.h"
|
|
|
|
#include "hurricane/isobar/PyOccurrence.h"
|
|
|
|
#include "hurricane/isobar/PyCell.h"
|
|
|
|
#include "hurricane/isobar/PySegment.h"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
namespace Isobar {
|
|
|
|
|
2008-03-28 04:48:47 -05:00
|
|
|
using namespace Hurricane;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
|
|
|
|
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Occurrence,occurrence,function)
|
|
|
|
|
|
|
|
|
|
|
|
// x=================================================================x
|
|
|
|
// | "PyOccurrence" Python Module Code Part |
|
|
|
|
// x=================================================================x
|
|
|
|
|
|
|
|
#if defined(__PYTHON_MODULE__)
|
|
|
|
|
|
|
|
|
|
|
|
// x-------------------------------------------------------------x
|
|
|
|
// | "PyOccurrence" Attribute Methods |
|
|
|
|
// x-------------------------------------------------------------x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Standart Accessors (Attributes).
|
|
|
|
|
|
|
|
|
|
|
|
// Standart Predicates (Attributes).
|
2013-03-13 08:38:15 -05:00
|
|
|
DirectGetBoolAttribute (PyOccurrence_isValid ,isValid ,PyOccurrence,Occurrence)
|
|
|
|
DirectGetBoolAttribute (PyOccurrence_hasProperty ,hasProperty ,PyOccurrence,Occurrence)
|
|
|
|
DirectGetStringAttribute(PyOccurrence_getCompactString,getCompactString,PyOccurrence,Occurrence)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
// Standart destroy (Attribute).
|
|
|
|
DirectDestroyAttribute(PyOccurrence_destroy, PyOccurrence)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
Make the Python interface closely mirroring the C++ one.
* Change: In Isobar, the Python interface was not exactly mirroring the
C++ one, now it is the case. The Python code should look likes almost
exactly like the C++ one, the only differences remaining being due
to the languages respective syntaxes. Note that in the case of
constructor functions, it leads to a slightly longer notation in
Python that it could have been (mimic the ".create()" static
member). Main modifications:
1. Mirror the static constructor syntax with create():
Cell( ... ) ==> Cell.create( ... )
2. Correct hierarchy for constants in Instance, Net, Pin
& Transformation. For example:
Hurricane.PlacementStatusFIXED
==> Hurricane.Instance.PlacementStatus.FIXED
Hurricane.OrientationID
==> Hurricane.Transformation.Orientation.ID
Hurricane.TypeLOGICAL ==> Hurricane.Net.Type.LOGICAL
Hurricane.DirectionIN ==> Hurricane.Net.Direction.IN
* Change: In CRL Core, correction to match the improved Python API
in the configutation helpers.
* Change: In Cumulus, correction to match the improved Python API.
* Change: In Stratus, correction to match the improved Python API.
* Change: In Documenation, update for the new Python interface
(both user's guide & examples).
* Note: We must port those changes into Chams for it to continue
to run.
* Change: In Documenation, update the Python script support part.
2014-06-28 10:37:59 -05:00
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// Attribute Method : "PyOccurrence_NEW ()"
|
|
|
|
|
|
|
|
PyObject* PyOccurrence_NEW ( PyObject *module, PyObject *args ) {
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(20,0) << "PyOccurrence_NEW()" << endl;
|
Make the Python interface closely mirroring the C++ one.
* Change: In Isobar, the Python interface was not exactly mirroring the
C++ one, now it is the case. The Python code should look likes almost
exactly like the C++ one, the only differences remaining being due
to the languages respective syntaxes. Note that in the case of
constructor functions, it leads to a slightly longer notation in
Python that it could have been (mimic the ".create()" static
member). Main modifications:
1. Mirror the static constructor syntax with create():
Cell( ... ) ==> Cell.create( ... )
2. Correct hierarchy for constants in Instance, Net, Pin
& Transformation. For example:
Hurricane.PlacementStatusFIXED
==> Hurricane.Instance.PlacementStatus.FIXED
Hurricane.OrientationID
==> Hurricane.Transformation.Orientation.ID
Hurricane.TypeLOGICAL ==> Hurricane.Net.Type.LOGICAL
Hurricane.DirectionIN ==> Hurricane.Net.Direction.IN
* Change: In CRL Core, correction to match the improved Python API
in the configutation helpers.
* Change: In Cumulus, correction to match the improved Python API.
* Change: In Stratus, correction to match the improved Python API.
* Change: In Documenation, update for the new Python interface
(both user's guide & examples).
* Note: We must port those changes into Chams for it to continue
to run.
* Change: In Documenation, update the Python script support part.
2014-06-28 10:37:59 -05:00
|
|
|
|
|
|
|
Occurrence* occurrence;
|
|
|
|
PyObject* arg0;
|
|
|
|
PyObject* arg1;
|
|
|
|
|
|
|
|
__cs.init ("Occurrence.Occurrence");
|
|
|
|
if ( ! PyArg_ParseTuple(args,"|O&O&:Occurrence.Occurrence"
|
|
|
|
,Converter,&arg0
|
|
|
|
,Converter,&arg1
|
|
|
|
)) {
|
|
|
|
PyErr_SetString ( ConstructorError, "invalid number of parameters for Occurrence constructor. " );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyOccurrence* pyOccurrence = NULL;
|
|
|
|
HTRY
|
|
|
|
if ( __cs.getObjectIds() == NO_ARG ) { occurrence = new Occurrence (); }
|
|
|
|
else if ( __cs.getObjectIds() == ENT_ARG ) { occurrence = new Occurrence ( PYENTITY_O(arg0) ); }
|
|
|
|
else if ( __cs.getObjectIds() == COMP_PATH_ARG) { occurrence = new Occurrence ( PYSEGMENT_O(arg0)
|
|
|
|
, *PYPATH_O(arg1) ); }
|
|
|
|
else if ( __cs.getObjectIds() == ENT_PATH_ARG ) { occurrence = new Occurrence ( PYENTITY_O(arg0)
|
|
|
|
, *PYPATH_O(arg1) ); }
|
|
|
|
else {
|
|
|
|
PyErr_SetString ( ConstructorError, "invalid number of parameters for Occurrence constructor. " );
|
|
|
|
return ( NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
pyOccurrence = PyObject_NEW(PyOccurrence, &PyTypeOccurrence);
|
|
|
|
if (pyOccurrence == NULL) return NULL;
|
|
|
|
|
|
|
|
pyOccurrence->_object = occurrence;
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
return ( (PyObject*)pyOccurrence );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int PyOccurrence_Init ( PyOccurrence* self, PyObject* args, PyObject* kwargs )
|
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(20,0) << "PyOccurrence_Init(): " << (void*)self << endl;
|
Make the Python interface closely mirroring the C++ one.
* Change: In Isobar, the Python interface was not exactly mirroring the
C++ one, now it is the case. The Python code should look likes almost
exactly like the C++ one, the only differences remaining being due
to the languages respective syntaxes. Note that in the case of
constructor functions, it leads to a slightly longer notation in
Python that it could have been (mimic the ".create()" static
member). Main modifications:
1. Mirror the static constructor syntax with create():
Cell( ... ) ==> Cell.create( ... )
2. Correct hierarchy for constants in Instance, Net, Pin
& Transformation. For example:
Hurricane.PlacementStatusFIXED
==> Hurricane.Instance.PlacementStatus.FIXED
Hurricane.OrientationID
==> Hurricane.Transformation.Orientation.ID
Hurricane.TypeLOGICAL ==> Hurricane.Net.Type.LOGICAL
Hurricane.DirectionIN ==> Hurricane.Net.Direction.IN
* Change: In CRL Core, correction to match the improved Python API
in the configutation helpers.
* Change: In Cumulus, correction to match the improved Python API.
* Change: In Stratus, correction to match the improved Python API.
* Change: In Documenation, update for the new Python interface
(both user's guide & examples).
* Note: We must port those changes into Chams for it to continue
to run.
* Change: In Documenation, update the Python script support part.
2014-06-28 10:37:59 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
// Attribute Method : "PyOccurrence_getEntity ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
static PyObject* PyOccurrence_getEntity ( PyOccurrence *self ) {
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(20,0) << "PyOccurrence_getEntity()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
METHOD_HEAD ( "Occurrence.getEntity()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
PyObject* pyEntity = NULL;
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
Entity* entity = occurrence->getEntity();
|
2008-03-06 10:46:43 -06:00
|
|
|
if ( entity == NULL )
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
|
|
|
pyEntity = PyEntity_NEW ( entity );
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
return pyEntity;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
// Attribute Method : "PyOccurrence_getOwnerCell ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
static PyObject* PyOccurrence_getOwnerCell ( PyOccurrence *self ) {
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(20,0) << "PyOccurrence_getOwnerCell()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
METHOD_HEAD ( "Occurernce.getOwnerCell()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
Cell* cell = NULL;
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
cell = occurrence->getOwnerCell();
|
2008-03-06 10:46:43 -06:00
|
|
|
HCATCH
|
|
|
|
|
|
|
|
return PyCell_Link ( cell );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
// Attribute Method : "PyOccurrence_getMasterCell ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
static PyObject* PyOccurrence_getMasterCell ( PyOccurrence *self )
|
2008-03-06 10:46:43 -06:00
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(20,0) << "PyOccurrence_getMasterCell()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
METHOD_HEAD ( "Occurrence.getMasterCell()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
Cell* cell = NULL;
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
cell = occurrence->getMasterCell();
|
2008-03-06 10:46:43 -06:00
|
|
|
HCATCH
|
|
|
|
|
|
|
|
return PyCell_Link ( cell );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
// Attribute Method : "PyOccurrence_getPath ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
static PyObject* PyOccurrence_getPath ( PyOccurrence *self )
|
2008-03-06 10:46:43 -06:00
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(20,0) << "PyOccurrence_getPath ()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
METHOD_HEAD ( "Occurrence.getPath()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
PyPath* pyPath = PyObject_NEW ( PyPath, &PyTypePath );
|
|
|
|
if ( pyPath == NULL ) { return NULL; }
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
pyPath->_object = new Path ( occurrence->getPath() );
|
2008-03-06 10:46:43 -06:00
|
|
|
HCATCH
|
|
|
|
|
|
|
|
return ( (PyObject*)pyPath );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
// Attribute Method : "PyOccurrence_getName ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-12-11 06:25:02 -06:00
|
|
|
GetNameMethod(Occurrence, occurrence)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
// Attribute Method : "PyOccurrence_getBoundingBox ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
static PyObject* PyOccurrence_getBoundingBox ( PyOccurrence *self )
|
2008-03-06 10:46:43 -06:00
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(20,0) << "PyOccurrence_getBoundingBox ()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
METHOD_HEAD ( "Occurrence.getBoundingBox()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
PyBox* pyBox = PyObject_NEW ( PyBox, &PyTypeBox );
|
|
|
|
if ( pyBox == NULL ) { return NULL; }
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
pyBox->_object = new Box ( occurrence->getBoundingBox() );
|
2008-03-06 10:46:43 -06:00
|
|
|
HCATCH
|
|
|
|
|
|
|
|
return ( (PyObject*)pyBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// PyOccurrence Attribute Method table.
|
|
|
|
|
|
|
|
PyMethodDef PyOccurrence_Methods[] =
|
2013-03-13 08:38:15 -05:00
|
|
|
{ { "getEntity" , (PyCFunction)PyOccurrence_getEntity , METH_NOARGS, "Returns the referenced entity." }
|
|
|
|
, { "getPath" , (PyCFunction)PyOccurrence_getPath , METH_NOARGS, "Returns the hierarchical instaciation path." }
|
|
|
|
, { "getName" , (PyCFunction)PyOccurrence_getName , METH_NOARGS, "Returns the occurrence name (concatenation of path and entity name." }
|
|
|
|
, { "getCompactString", (PyCFunction)PyOccurrence_getCompactString, METH_NOARGS, "Returns the occurrence name (compact format)." }
|
|
|
|
, { "getOwnerCell" , (PyCFunction)PyOccurrence_getOwnerCell , METH_NOARGS, "Returns the occurrence owner cell." }
|
|
|
|
, { "getMasterCell" , (PyCFunction)PyOccurrence_getMasterCell , METH_NOARGS, "Returns the cell owning the referenced entity." }
|
|
|
|
, { "getBoundingBox" , (PyCFunction)PyOccurrence_getBoundingBox , METH_NOARGS, "Returns the occurrence bounding box." }
|
|
|
|
, { "isValid" , (PyCFunction)PyOccurrence_isValid , METH_NOARGS, "Returns true if the occurrence is valid." }
|
|
|
|
, { "hasProperty" , (PyCFunction)PyOccurrence_hasProperty , METH_NOARGS, "Returns true if the occurrence owns some properties." }
|
|
|
|
, { "destroy" , (PyCFunction)PyOccurrence_destroy , METH_NOARGS
|
|
|
|
, "Destroy associated hurricane object, the python object remains." }
|
2008-03-06 10:46:43 -06:00
|
|
|
, {NULL, NULL, 0, NULL} /* sentinel */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// x-------------------------------------------------------------x
|
|
|
|
// | "PyOccurrence" Object Methods |
|
|
|
|
// x-------------------------------------------------------------x
|
|
|
|
|
2009-09-30 10:11:49 -05:00
|
|
|
|
|
|
|
|
|
|
|
DirectDeleteMethod(PyOccurrence_DeAlloc,PyOccurrence)
|
Make the Python interface closely mirroring the C++ one.
* Change: In Isobar, the Python interface was not exactly mirroring the
C++ one, now it is the case. The Python code should look likes almost
exactly like the C++ one, the only differences remaining being due
to the languages respective syntaxes. Note that in the case of
constructor functions, it leads to a slightly longer notation in
Python that it could have been (mimic the ".create()" static
member). Main modifications:
1. Mirror the static constructor syntax with create():
Cell( ... ) ==> Cell.create( ... )
2. Correct hierarchy for constants in Instance, Net, Pin
& Transformation. For example:
Hurricane.PlacementStatusFIXED
==> Hurricane.Instance.PlacementStatus.FIXED
Hurricane.OrientationID
==> Hurricane.Transformation.Orientation.ID
Hurricane.TypeLOGICAL ==> Hurricane.Net.Type.LOGICAL
Hurricane.DirectionIN ==> Hurricane.Net.Direction.IN
* Change: In CRL Core, correction to match the improved Python API
in the configutation helpers.
* Change: In Cumulus, correction to match the improved Python API.
* Change: In Stratus, correction to match the improved Python API.
* Change: In Documenation, update for the new Python interface
(both user's guide & examples).
* Note: We must port those changes into Chams for it to continue
to run.
* Change: In Documenation, update the Python script support part.
2014-06-28 10:37:59 -05:00
|
|
|
PyTypeObjectLinkPyTypeNewInit(Occurrence)
|
|
|
|
//PyTypeObjectLinkPyType(Occurrence)
|
2009-09-30 10:11:49 -05:00
|
|
|
|
|
|
|
|
|
|
|
#else // End of Python Module Code Part.
|
|
|
|
|
|
|
|
|
|
|
|
// x=================================================================x
|
|
|
|
// | "PyOccurrence" Shared Library Code Part |
|
|
|
|
// x=================================================================x
|
|
|
|
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// PyOccurrence Object Definitions.
|
|
|
|
|
2008-10-12 08:37:33 -05:00
|
|
|
PyTypeObjectDefinitions(Occurrence)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
#endif // End of Shared Library Code Part.
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
} // End of extern "C".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // End of Isobar namespace.
|