Add CRL::Catalog and Net::getRoutingPads() to the Python interface.

* New: In CRL::PyAllianceFramework, export getCatalog(), in PyCatalog,
    export the getState(name) method and add a PyCatalog_Link().
    In PyCatalogState, add PyCatalogState_Link(), cannot use the
    macro because of the C++ name resolution operator (Catalog::State).
* New: In Isobar, export the RoutingPads collection to the Python interface.
* New: In Hurricane::Net, export the getRoutingPads() method to the
    Python interface (hence the need of the previous export).
This commit is contained in:
Jean-Paul Chaput 2020-08-21 16:00:50 +02:00
parent 1c6a9b64b0
commit 083e58d953
9 changed files with 234 additions and 39 deletions

View File

@ -18,6 +18,7 @@
#include "hurricane/isobar/PyLibrary.h"
#include "hurricane/DataBase.h"
#include "crlcore/PyEnvironment.h"
#include "crlcore/PyCatalog.h"
#include "crlcore/PyCellGauge.h"
#include "crlcore/PyRoutingGauge.h"
#include "crlcore/PyAllianceLibrary.h"
@ -336,6 +337,19 @@ extern "C" {
}
static PyObject* PyAllianceFramework_getCatalog ( PyAllianceFramework* self )
{
cdebug_log(30,0) << "PyAllianceFramework_getCatalog ()" << endl;
Catalog* catalog = NULL;
HTRY
METHOD_HEAD("AllianceFramework.getCatalog()")
catalog = af->getCatalog();
HCATCH
return PyCatalog_Link(catalog);
}
static PyObject* PyAllianceFramework_isInCatalog ( PyAllianceFramework* self, PyObject* args )
{
cdebug_log(30,0) << "PyAllianceFramework_isInCatalog ()" << endl;
@ -555,6 +569,8 @@ extern "C" {
, "Gets the Alliance Framework." }
, { "getEnvironment" , (PyCFunction)PyAllianceFramework_getEnvironment , METH_NOARGS
, "Gets the Alliance Environment." }
, { "getCatalog" , (PyCFunction)PyAllianceFramework_getCatalog , METH_NOARGS
, "Gets the libraries composite catalog." }
, { "bindLibraries" , (PyCFunction)PyAllianceFramework_bindLibraries , METH_NOARGS
, "Bind Alliance libraries to Hurricane one. This is a one-time only methods." }
, { "getLibrary" , (PyCFunction)PyAllianceFramework_getLibrary , METH_VARARGS

View File

@ -29,6 +29,8 @@ namespace CRL {
using std::hex;
using std::ostringstream;
using Hurricane::tab;
using Hurricane::Exception;
using Hurricane::Bug;
using Hurricane::Error;
using Hurricane::Warning;
using Isobar::ProxyProperty;
@ -58,15 +60,32 @@ extern "C" {
#if defined(__PYTHON_MODULE__)
// Standart Accessors (Attributes).
// Standart Destroy (Attribute).
// DBoDestroyAttribute(PyCatalog_destroy,PyCatalog)
static PyObject* PyCatalog_getState ( PyCatalog* self, PyObject* args )
{
cdebug_log(30,0) << "PyCatalog_getState ()" << endl;
char* name = NULL;
Catalog::State* state = NULL;
HTRY
METHOD_HEAD("Catalog.getState()")
if ( not PyArg_ParseTuple(args,"s",&name) ) {
PyErr_SetString( ConstructorError, "Catalog.getState(): Invalid number or bad type of parameters.");
return NULL;
}
state = catalog->getState( Name(name) );
HCATCH
if (not state) Py_RETURN_FALSE;
return PyCatalogState_Link(state);
}
PyMethodDef PyCatalog_Methods[] =
{ {NULL, NULL, 0, NULL} /* sentinel */
{ { "getState" , (PyCFunction)PyCatalog_getState, METH_VARARGS
, "Gets the catalog state of a cell." }
, {NULL, NULL, 0, NULL} /* sentinel */
};
@ -83,6 +102,7 @@ extern "C" {
// Link/Creation Method.
PyTypeObjectDefinitions(Catalog)
LinkCreateMethod(Catalog)
extern void PyCatalog_postModuleInit ()

View File

@ -157,6 +157,22 @@ extern "C" {
PyTypeObjectDefinitions(CatalogState)
PyObject* PyCatalogState_Link ( Catalog::State* object )
{
if (not object) Py_RETURN_NONE;
PyCatalogState* pyObject = NULL;
HTRY
pyObject = PyObject_NEW( PyCatalogState, &PyTypeCatalogState );
if (not pyObject) return NULL;
pyObject->_object = object;
cdebug_log(20,0) << "PyCatalogState_Link(" << (void*)pyObject << ") "
<< (void*)object << ":" << object << endl;
HCATCH
return (PyObject*)pyObject;
}
#endif // End of Shared Library Code Part.

View File

@ -64,6 +64,7 @@
PyReference.cpp
PyReferenceCollection.cpp
PyRoutingPad.cpp
PyRoutingPadCollection.cpp
PySegment.cpp
PySegmentCollection.cpp
PyTechnology.cpp
@ -140,6 +141,7 @@
hurricane/isobar/PyReference.h
hurricane/isobar/PyReferenceCollection.h
hurricane/isobar/PyRoutingPad.h
hurricane/isobar/PyRoutingPadCollection.h
hurricane/isobar/PySegment.h
hurricane/isobar/PySegmentCollection.h
hurricane/isobar/PyTechnology.h

View File

@ -98,6 +98,22 @@ extern "C" {
}
static PyObject* PyContact_getAnchor ( PyContact *self )
{
cdebug_log(20,0) << "PyContact_getAnchor ()" << endl;
METHOD_HEAD ( "Contact.getAnchor()" )
Component* anchor = NULL;
PyObject* pyAnchor = NULL;
HTRY
anchor = contact->getAnchor();
if (anchor) pyAnchor = PyEntity_NEW( anchor );
else
Py_RETURN_NONE;
HCATCH
return pyAnchor;
}
static PyObject* PyContact_translate ( PyContact *self, PyObject* args ) {
cdebug_log(20,0) << "PyContact_translate ()" << endl;
@ -123,25 +139,26 @@ extern "C" {
PyMethodDef PyContact_Methods[] =
{ { "create" , (PyCFunction)PyContact_create , METH_VARARGS|METH_STATIC
, "Create a new Contact." }
, { "destroy" , (PyCFunction)PyContact_destroy , METH_NOARGS
, "Destroy associated hurricane object, the python object remains." }
, { "getAnchorHook" , (PyCFunction)PyContact_getAnchorHook , METH_NOARGS , "Return the contact anchor hook." }
, { "getWidth" , (PyCFunction)PyContact_getWidth , METH_NOARGS , "Return the contact width." }
, { "getHalfWidth" , (PyCFunction)PyContact_getHalfWidth , METH_NOARGS , "Return the contact half width." }
, { "getHeight" , (PyCFunction)PyContact_getHeight , METH_NOARGS , "Return the contact height." }
, { "getHalfHeight" , (PyCFunction)PyContact_getHalfHeight , METH_NOARGS , "Return the contact half height." }
, { "getDx" , (PyCFunction)PyContact_getDx , METH_NOARGS , "Return the contact dx value." }
, { "getDy" , (PyCFunction)PyContact_getDy , METH_NOARGS , "Return the contact dy value." }
, { "translate" , (PyCFunction)PyContact_translate , METH_VARARGS, "Translates the Contact of dx and dy." }
, { "setX" , (PyCFunction)PyContact_setX , METH_VARARGS, "Sets the contact X value." }
, { "setY" , (PyCFunction)PyContact_setY , METH_VARARGS, "Sets the contact Y value." }
, { "setDx" , (PyCFunction)PyContact_setDx , METH_VARARGS, "Sets the contact dx value." }
, { "setDy" , (PyCFunction)PyContact_setDy , METH_VARARGS, "Sets the contact dy value." }
, { "setWidth" , (PyCFunction)PyContact_setWidth , METH_VARARGS, "Sets the contact width." }
, { "setHeight" , (PyCFunction)PyContact_setHeight , METH_VARARGS, "Sets the contact height." }
, {NULL, NULL, 0, NULL} /* sentinel */
{ { "create" , (PyCFunction)PyContact_create , METH_VARARGS|METH_STATIC
, "Create a new Contact." }
, { "destroy" , (PyCFunction)PyContact_destroy , METH_NOARGS
, "Destroy associated hurricane object, the python object remains." }
, { "getAnchorHook" , (PyCFunction)PyContact_getAnchorHook , METH_NOARGS , "Return the contact anchor hook." }
, { "getAnchor" , (PyCFunction)PyContact_getAnchor , METH_NOARGS , "Return the contact anchor (component)." }
, { "getWidth" , (PyCFunction)PyContact_getWidth , METH_NOARGS , "Return the contact width." }
, { "getHalfWidth" , (PyCFunction)PyContact_getHalfWidth , METH_NOARGS , "Return the contact half width." }
, { "getHeight" , (PyCFunction)PyContact_getHeight , METH_NOARGS , "Return the contact height." }
, { "getHalfHeight" , (PyCFunction)PyContact_getHalfHeight , METH_NOARGS , "Return the contact half height." }
, { "getDx" , (PyCFunction)PyContact_getDx , METH_NOARGS , "Return the contact dx value." }
, { "getDy" , (PyCFunction)PyContact_getDy , METH_NOARGS , "Return the contact dy value." }
, { "translate" , (PyCFunction)PyContact_translate , METH_VARARGS, "Translates the Contact of dx and dy." }
, { "setX" , (PyCFunction)PyContact_setX , METH_VARARGS, "Sets the contact X value." }
, { "setY" , (PyCFunction)PyContact_setY , METH_VARARGS, "Sets the contact Y value." }
, { "setDx" , (PyCFunction)PyContact_setDx , METH_VARARGS, "Sets the contact dx value." }
, { "setDy" , (PyCFunction)PyContact_setDy , METH_VARARGS, "Sets the contact dy value." }
, { "setWidth" , (PyCFunction)PyContact_setWidth , METH_VARARGS, "Sets the contact width." }
, { "setHeight" , (PyCFunction)PyContact_setHeight , METH_VARARGS, "Sets the contact height." }
, {NULL, NULL, 0, NULL} /* sentinel */
};

View File

@ -47,6 +47,7 @@
#include "hurricane/isobar/PyPinPlacementStatus.h"
#include "hurricane/isobar/PyPinDirection.h"
#include "hurricane/isobar/PyPinCollection.h"
#include "hurricane/isobar/PyRoutingPadCollection.h"
#include "hurricane/isobar/PyPlacementStatus.h"
#include "hurricane/isobar/PyInstance.h"
#include "hurricane/isobar/PyInstanceCollection.h"
@ -555,6 +556,7 @@ extern "C" {
PyPinPlacementStatus_LinkPyType ();
PyPinDirection_LinkPyType ();
PyPinCollection_LinkPyType ();
PyRoutingPadCollection_LinkPyType ();
PySegmentCollection_LinkPyType ();
PyOccurrenceCollection_LinkPyType ();
PyComponentCollection_LinkPyType ();
@ -635,6 +637,8 @@ extern "C" {
PYTYPE_READY( PinDirection )
PYTYPE_READY( PinCollection )
PYTYPE_READY( PinCollectionLocator )
PYTYPE_READY( RoutingPadCollection )
PYTYPE_READY( RoutingPadCollectionLocator )
PYTYPE_READY( SegmentCollection )
PYTYPE_READY( SegmentCollectionLocator )
PYTYPE_READY( ComponentCollection )
@ -723,6 +727,7 @@ extern "C" {
__cs.addType( "hyperNet" , &PyTypeHyperNet , "<HyperNet>" , false );
__cs.addType( "pin" , &PyTypePin , "<Pin>" , false, "contact" );
__cs.addType( "pinCol" , &PyTypePinCollection , "<PinCollection>" , false );
__cs.addType( "rpCol" , &PyTypeRoutingPadCollection , "<RoutingPadCollection>" , false );
__cs.addType( "plug" , &PyTypePlug , "<Plug>" , false, "comp" );
__cs.addType( "plugCol" , &PyTypePlugCollection , "<PlugCollection>" , false );
__cs.addType( "point" , &PyTypePoint , "<Point>" , false );
@ -772,7 +777,6 @@ extern "C" {
PyModule_AddObject ( module, "Path" , (PyObject*)&PyTypePath );
Py_INCREF ( &PyTypeOccurrence );
PyModule_AddObject ( module, "Occurrence" , (PyObject*)&PyTypeOccurrence );
Py_INCREF ( &PyTypeDataBase );
PyModule_AddObject ( module, "DataBase" , (PyObject*)&PyTypeDataBase );
Py_INCREF ( &PyTypeLibrary );
@ -817,7 +821,6 @@ extern "C" {
PyModule_AddObject ( module, "Query" , (PyObject*)&PyTypeQuery );
Py_INCREF ( &PyTypeReference );
PyModule_AddObject ( module, "Reference" , (PyObject*)&PyTypeReference );
Py_INCREF ( &PyTypeHook );
PyModule_AddObject ( module, "Hook" , (PyObject*)&PyTypeHook );
Py_INCREF ( &PyTypeHookCollection );
@ -844,7 +847,6 @@ extern "C" {
PyModule_AddObject ( module, "Rectilinear" , (PyObject*)&PyTypeRectilinear );
Py_INCREF ( &PyTypePolygon );
PyModule_AddObject ( module, "Polygon" , (PyObject*)&PyTypePolygon );
Py_INCREF( &PyTypeDeviceDescriptor );
PyModule_AddObject( module, "DeviceDescriptor" , (PyObject*)&PyTypeDeviceDescriptor );

View File

@ -23,6 +23,7 @@
#include "hurricane/isobar/PySegmentCollection.h"
#include "hurricane/isobar/PyComponentCollection.h"
#include "hurricane/isobar/PyPinCollection.h"
#include "hurricane/isobar/PyRoutingPadCollection.h"
#include "hurricane/Cell.h"
#include "hurricane/NetExternalComponents.h"
using namespace Hurricane;
@ -197,28 +198,42 @@ extern "C" {
}
static PyObject* PyNet_getPins(PyNet *self) {
static PyObject* PyNet_getPins ( PyNet *self )
{
cdebug_log(20,0) << "PyNet_getPins()" << endl;
METHOD_HEAD ("Net.getPins()")
PyPinCollection* pyPinCollection = NULL;
HTRY
Pins* pins = new Pins(net->getPins());
pyPinCollection = PyObject_NEW(PyPinCollection, &PyTypePinCollection);
if (pyPinCollection == NULL) {
return NULL;
}
pyPinCollection->_object = pins;
Pins* pins = new Pins( net->getPins() );
pyPinCollection = PyObject_NEW(PyPinCollection, &PyTypePinCollection);
if (pyPinCollection == NULL) {
return NULL;
}
pyPinCollection->_object = pins;
HCATCH
return (PyObject*)pyPinCollection;
}
static PyObject* PyNet_getRoutingPads ( PyNet *self )
{
cdebug_log(20,0) << "PyNet_getRoutingPads()" << endl;
METHOD_HEAD ("Net.getRoutingPads()")
PyRoutingPadCollection* pyRoutingPadCollection = NULL;
HTRY
RoutingPads* routingPads = new RoutingPads( net->getRoutingPads() );
pyRoutingPadCollection = PyObject_NEW(PyRoutingPadCollection, &PyTypeRoutingPadCollection);
if (pyRoutingPadCollection == NULL) {
return NULL;
}
pyRoutingPadCollection->_object = routingPads;
HCATCH
return (PyObject*)pyRoutingPadCollection;
}
static PyObject* PyNet_getComponents(PyNet *self) {
cdebug_log(20,0) << "PyNet_getComponents()" << endl;
@ -451,6 +466,7 @@ extern "C" {
, { "getExternalComponents", (PyCFunction)PyNet_getExternalComponents , METH_NOARGS , "Returns the collection of net's external components. (only for an external net)" }
, { "getPlugs" , (PyCFunction)PyNet_getPlugs , METH_NOARGS , "Returns the collection of net's plugs." }
, { "getPins" , (PyCFunction)PyNet_getPins , METH_NOARGS , "Returns the collection of net's pins." }
, { "getRoutingPads" , (PyCFunction)PyNet_getRoutingPads , METH_NOARGS , "Returns the collection of net's RoutingPads." }
, { "getSegments" , (PyCFunction)PyNet_getSegments , METH_NOARGS , "Returns the collection of net's segments." }
, { "isGlobal" , (PyCFunction)PyNet_isGlobal , METH_NOARGS , "return true if the net is global" }
, { "isExternal" , (PyCFunction)PyNet_isExternal , METH_NOARGS , "return true if the the net is external." }

View File

@ -0,0 +1,56 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) SU/LIP6 2020-2020, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | 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@lip6.fr |
// | =============================================================== |
// | C++ Module : "./PyRoutingPadCollection.h" |
// +-----------------------------------------------------------------+
#include "hurricane/isobar/PyRoutingPadCollection.h"
#include "hurricane/isobar/PyRoutingPad.h"
namespace Isobar {
using namespace Hurricane;
extern "C" {
#if defined(__PYTHON_MODULE__)
// +=================================================================+
// | "PyRoutingPadCollection" Python Module Code Part |
// +=================================================================+
DirectDeleteMethod(PyRoutingPadCollection_DeAlloc, PyRoutingPadCollection)
LocatorNextMethod(RoutingPad)
CollectionMethods(RoutingPad)
#else // End of Python Module Code Part.
// +=================================================================+
// | "PyRoutingPadCollection" Shared Library Code Part |
// +=================================================================+
PyTypeCollectionObjectDefinitions(RoutingPadCollection)
PyTypeCollectionObjectDefinitions(RoutingPadCollectionLocator)
#endif // End of Shared Library Code Part.
} // End of extern "C".
} // Isobar namespace.

View File

@ -0,0 +1,50 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) SU/LIP6 2020-2020, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | 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@lip6.fr |
// | =============================================================== |
// | C++ Header : "./isobar/PyRoutingPadCollection.h" |
// +-----------------------------------------------------------------+
#pragma once
#include "hurricane/isobar/PyHurricane.h"
#include "hurricane/RoutingPad.h"
#include "hurricane/RoutingPads.h"
namespace Isobar {
extern "C" {
typedef struct {
PyObject_HEAD
Hurricane::RoutingPads* _object;
} PyRoutingPadCollection;
typedef struct {
PyObject_HEAD
Hurricane::Locator<Hurricane::RoutingPad*>* _object;
PyRoutingPadCollection* _collection;
} PyRoutingPadCollectionLocator;
extern PyTypeObject PyTypeRoutingPadCollection;
extern PyTypeObject PyTypeRoutingPadCollectionLocator;
extern void PyRoutingPadCollection_LinkPyType();
extern void PyRoutingPadCollectionLocator_LinkPyType();
} // End of extern "C".
} // Isobar namespace.