2013-04-18 05:55:34 -05:00
|
|
|
// -*- C++ -*-
|
2008-03-06 10:46:43 -06:00
|
|
|
//
|
2013-04-18 05:55:34 -05:00
|
|
|
// This file is part of the Coriolis Software.
|
2016-01-20 17:41:19 -06:00
|
|
|
// Copyright (c) UPMC 2008-2016, All Rights Reserved
|
2008-03-06 10:46:43 -06:00
|
|
|
//
|
2013-04-18 05:55:34 -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 |
|
|
|
|
// | |
|
2013-04-18 05:55:34 -05:00
|
|
|
// | Author : Jean-Paul CHAPUT |
|
|
|
|
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
2008-03-06 10:46:43 -06:00
|
|
|
// | =============================================================== |
|
2013-04-18 05:55:34 -05:00
|
|
|
// | C++ Module : "./PyComponents.cpp" |
|
|
|
|
// +-----------------------------------------------------------------+
|
|
|
|
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-05-21 17:46:29 -05:00
|
|
|
#include "hurricane/isobar/PyNet.h"
|
|
|
|
#include "hurricane/isobar/PyLayer.h"
|
|
|
|
#include "hurricane/isobar/PyPoint.h"
|
|
|
|
#include "hurricane/isobar/PyBox.h"
|
2013-04-17 11:14:41 -05:00
|
|
|
#include "hurricane/isobar/PyBasicLayer.h"
|
2013-05-04 09:03:21 -05:00
|
|
|
#include "hurricane/isobar/PyHook.h"
|
2008-05-21 17:46:29 -05:00
|
|
|
#include "hurricane/isobar/PyComponent.h"
|
|
|
|
#include "hurricane/isobar/PyPlug.h"
|
|
|
|
#include "hurricane/isobar/PyHorizontal.h"
|
|
|
|
#include "hurricane/isobar/PyVertical.h"
|
|
|
|
#include "hurricane/isobar/PyContact.h"
|
|
|
|
#include "hurricane/isobar/PyPin.h"
|
2013-04-18 05:55:34 -05:00
|
|
|
#include "hurricane/isobar/PyComponentCollection.h"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
2013-04-18 05:55:34 -05:00
|
|
|
namespace Isobar {
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-28 04:48:47 -05:00
|
|
|
using namespace Hurricane;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
2008-11-20 04:56:11 -06:00
|
|
|
#undef ACCESS_OBJECT
|
|
|
|
#undef ACCESS_CLASS
|
|
|
|
#define ACCESS_OBJECT _baseObject._object
|
|
|
|
#define ACCESS_CLASS(_pyObject) &(_pyObject->_baseObject)
|
|
|
|
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Component,component,function)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
2013-04-18 05:55:34 -05:00
|
|
|
// +=================================================================+
|
2008-03-06 10:46:43 -06:00
|
|
|
// | "PyComponent" Python Module Code Part |
|
2013-04-18 05:55:34 -05:00
|
|
|
// +=================================================================+
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-11-20 04:56:11 -06:00
|
|
|
#if defined(__PYTHON_MODULE__)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
// Standart Accessors (Attributes).
|
2008-03-17 08:54:33 -05:00
|
|
|
DirectGetLongAttribute(PyComponent_getX,getX,PyComponent,Component)
|
|
|
|
DirectGetLongAttribute(PyComponent_getY,getY,PyComponent,Component)
|
2013-05-04 09:03:21 -05:00
|
|
|
accessorHook(getBodyHook,PyComponent,Component)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
// Standart Destroy (Attribute).
|
|
|
|
DBoDestroyAttribute(PyComponent_destroy,PyComponent)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
2013-04-18 05:55:34 -05:00
|
|
|
static PyObject* PyComponent_getPosition ( PyComponent *self )
|
|
|
|
{
|
2008-03-17 08:54:33 -05:00
|
|
|
trace << "PyComponent_getPosition ()" << endl;
|
|
|
|
METHOD_HEAD ( "Component.getPosition()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
PyPoint* pyPoint = PyObject_NEW ( PyPoint, &PyTypePoint );
|
|
|
|
if (pyPoint == NULL) { return NULL; }
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
pyPoint->_object = new Point ( component->getPosition() );
|
2008-03-06 10:46:43 -06:00
|
|
|
HCATCH
|
|
|
|
|
|
|
|
return ( (PyObject*)pyPoint );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-18 05:55:34 -05:00
|
|
|
static PyObject* PyComponent_getNet ( PyComponent *self )
|
|
|
|
{
|
2008-03-17 08:54:33 -05:00
|
|
|
trace << "PyComponent_getNet ()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
Net* net = NULL;
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
METHOD_HEAD ( "Component.getNet()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
net = component->getNet ( );
|
2008-03-06 10:46:43 -06:00
|
|
|
HCATCH
|
|
|
|
|
|
|
|
return PyNet_Link ( net );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-18 05:55:34 -05:00
|
|
|
static PyObject* PyComponent_getLayer ( PyComponent *self )
|
|
|
|
{
|
2008-03-17 08:54:33 -05:00
|
|
|
trace << "PyComponent_getLayer ()" << endl;
|
|
|
|
METHOD_HEAD ( "Component.getLayer()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
Layer* layer = NULL;
|
|
|
|
|
|
|
|
HTRY
|
2008-06-05 11:11:52 -05:00
|
|
|
layer = const_cast<Layer*>(component->getLayer ());
|
2008-03-06 10:46:43 -06:00
|
|
|
HCATCH
|
|
|
|
|
Complete replacement of the Chip placement Python scripts.
Finally get rid of the demonic code from Wu Yifei...
* New: In Isobar, added encapsulation of Interval (don't know how have
forgotten it for so long).
* Change: In Isobar, In PyLayer, new PyLink_LayerDerived() function to
create/link the C++ object to the correct derived class and not the
base one (PyLayer) which then prevent to use the specialized methods.
Must replace PyLink_Layer() througout all the code.
* Change: In Isobar, in PyPoint the "setX()" & "setY()" methods where
still capitalized.
* Change: In Isobar, in PyQuery, complete the exportation of the C++
interface. remove the code belonging to a more "boost" way of
building the Python interface (will do that in a far future).
* New: In CRL Core, In PyAllianceFramework, export isPad() method.
* Change: In Unicorn, in unicornInit.py, protect the loading of each
single plugin by a "try" / "except" clause to the failing of one
plugins do not stop the loading of the next one.
Pass the same dictionnary argument to unicornHook() as for
ScripMain(), this is more uniform this way.
* New: In Cumulus, complete replacement of the chip placement scripts
from Wu Yifei (at last!). The clock-tree integration is still to
be done.
________________________________________________________________________
2014-07-21 06:18:34 -05:00
|
|
|
return PyLayer_LinkDerived ( layer );
|
2008-03-06 10:46:43 -06:00
|
|
|
}
|
2013-03-13 08:38:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
static PyObject* PyComponent_getCenter ( PyComponent *self )
|
|
|
|
{
|
|
|
|
trace << "PyComponent_getCenter ()" << endl;
|
|
|
|
METHOD_HEAD( "Component.getCenter()" )
|
|
|
|
|
|
|
|
PyPoint* pyPoint = PyObject_NEW( PyPoint, &PyTypePoint );
|
|
|
|
if (pyPoint == NULL) return NULL;
|
|
|
|
|
|
|
|
HTRY
|
|
|
|
pyPoint->_object = new Point( component->getCenter() );
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
return (PyObject*)pyPoint;
|
|
|
|
}
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
2013-04-17 11:14:41 -05:00
|
|
|
static PyObject* PyComponent_getBoundingBox ( PyComponent *self, PyObject* args )
|
|
|
|
{
|
2008-03-17 08:54:33 -05:00
|
|
|
trace << "PyComponent_getBoundingBox ()" << endl;
|
|
|
|
METHOD_HEAD ( "Component.getBoundingBox()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
PyBox* pyBox = PyObject_NEW ( PyBox, &PyTypeBox );
|
2013-04-17 11:14:41 -05:00
|
|
|
if (pyBox == NULL) return NULL;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
HTRY
|
2013-04-17 11:14:41 -05:00
|
|
|
PyObject* pyLayer = NULL;
|
|
|
|
if (PyArg_ParseTuple( args, "|O:Component.getBoundingBox", &pyLayer )) {
|
|
|
|
if (pyLayer) {
|
|
|
|
if (not IsPyBasicLayer(pyLayer)) {
|
|
|
|
PyErr_SetString( ConstructorError, "Component.getBoundingBox(): First argument is not of type BasicLayer." );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
pyBox->_object = new Box ( component->getBoundingBox(PYBASICLAYER_O(pyLayer)) );
|
|
|
|
} else {
|
|
|
|
pyBox->_object = new Box ( component->getBoundingBox() );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PyErr_SetString( ConstructorError, "Bad parameters given to Component.getBoundingBox()." );
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-03-06 10:46:43 -06:00
|
|
|
HCATCH
|
|
|
|
|
2013-04-17 11:14:41 -05:00
|
|
|
return (PyObject*)pyBox;
|
2008-03-06 10:46:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-18 05:55:34 -05:00
|
|
|
static PyObject* PyComponent_getConnexComponents ( PyComponent *self )
|
|
|
|
{
|
|
|
|
trace << "PyComponent_getConnexComponents()" << endl;
|
|
|
|
METHOD_HEAD( "PyComponent.getConnexComponents()" )
|
|
|
|
|
|
|
|
PyComponentCollection* pyComponentCollection = NULL;
|
|
|
|
|
|
|
|
HTRY
|
|
|
|
Components* components = new Components(component->getConnexComponents());
|
|
|
|
|
|
|
|
pyComponentCollection = PyObject_NEW( PyComponentCollection, &PyTypeComponentCollection );
|
|
|
|
if (pyComponentCollection == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pyComponentCollection->_object = components;
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
return (PyObject*)pyComponentCollection;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject* PyComponent_getSlaveComponents ( PyComponent *self )
|
|
|
|
{
|
|
|
|
trace << "PyComponent_getSlaveComponents()" << endl;
|
|
|
|
METHOD_HEAD( "PyComponent.getSlaveComponents()" )
|
|
|
|
|
|
|
|
PyComponentCollection* pyComponentCollection = NULL;
|
|
|
|
|
|
|
|
HTRY
|
|
|
|
Components* components = new Components(component->getSlaveComponents());
|
|
|
|
|
|
|
|
pyComponentCollection = PyObject_NEW( PyComponentCollection, &PyTypeComponentCollection );
|
|
|
|
if (pyComponentCollection == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pyComponentCollection->_object = components;
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
return (PyObject*)pyComponentCollection;
|
|
|
|
}
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
PyMethodDef PyComponent_Methods[] =
|
2013-05-04 09:03:21 -05:00
|
|
|
{ { "getBodyHook" , (PyCFunction)PyComponent_getBodyHook , METH_NOARGS , "Return the component body hook (is a master Hook)." }
|
|
|
|
, { "getX" , (PyCFunction)PyComponent_getX , METH_NOARGS , "Return the Component X value." }
|
2013-04-18 05:55:34 -05:00
|
|
|
, { "getY" , (PyCFunction)PyComponent_getY , METH_NOARGS , "Return the Component Y value." }
|
|
|
|
, { "getPosition" , (PyCFunction)PyComponent_getPosition , METH_NOARGS , "Return the Component position." }
|
|
|
|
, { "getCenter" , (PyCFunction)PyComponent_getCenter , METH_NOARGS , "Return the Component center position." }
|
|
|
|
, { "getNet" , (PyCFunction)PyComponent_getNet , METH_NOARGS , "Returns the net owning the component." }
|
|
|
|
, { "getLayer" , (PyCFunction)PyComponent_getLayer , METH_NOARGS , "Return the component layer." }
|
|
|
|
, { "getBoundingBox" , (PyCFunction)PyComponent_getBoundingBox , METH_VARARGS, "Return the component boundingBox (optionally on a BasicLayer)." }
|
|
|
|
, { "getConnexComponents" , (PyCFunction)PyComponent_getConnexComponents, METH_NOARGS, "All the components connecteds to this one through hyper hooks." }
|
|
|
|
, { "getSlaveComponents" , (PyCFunction)PyComponent_getSlaveComponents , METH_NOARGS, "All the components anchored directly or indirectly on this one." }
|
|
|
|
, { "destroy" , (PyCFunction)PyComponent_destroy , METH_NOARGS
|
2008-03-17 08:54:33 -05:00
|
|
|
, "destroy associated hurricane object, the python object remains." }
|
2013-04-18 05:55:34 -05:00
|
|
|
, {NULL, NULL, 0, NULL} /* sentinel */
|
2008-03-06 10:46:43 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
DBoDeleteMethod(Component)
|
|
|
|
PyTypeObjectLinkPyType(Component)
|
|
|
|
|
|
|
|
|
2009-01-22 05:37:42 -06:00
|
|
|
#else // End of Python Module Code Part.
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
2013-04-18 05:55:34 -05:00
|
|
|
// +=================================================================+
|
2008-03-06 10:46:43 -06:00
|
|
|
// | "PyComponent" Shared Library Code Part |
|
2013-04-18 05:55:34 -05:00
|
|
|
// +=================================================================+
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
2009-09-30 10:11:49 -05:00
|
|
|
PyTypeInheritedObjectDefinitions(Component, Entity)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-11-20 04:56:11 -06:00
|
|
|
#endif // End of Shared Library Code Part.
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
2013-04-18 05:55:34 -05:00
|
|
|
} // extern "C".
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2013-04-18 05:55:34 -05:00
|
|
|
} // Isobar namespace.
|