Migration towards Python 3, stage 2: C++ template wrapper ready.
* New: In hurricane/configuration, the Python/C template wrapper has now all the needed features to mass-migrate Hurricane and the ToolEngines. The new Hurricane module is named Hurricane3 so it does not collides with the old one which is still used. Will do the same for all ToolEngines Python wrappers until migration is complete. * New: In unittests/python/, create very basic unit tests for the Configuration & Hurricane new template wrapper. Note: It is almost impossible to use valgrind on them because it doesn't recognize correctly Python allocation mechanism. To make it work, both valgrind & Python needs to be recompiled with special options...
This commit is contained in:
parent
3bd0dbfd24
commit
16d1da053a
|
@ -37,7 +37,12 @@
|
|||
hurricane/configuration/PyTechnology.h
|
||||
hurricane/configuration/PyLayerMask.h
|
||||
hurricane/configuration/PyLayer.h
|
||||
hurricane/configuration/PyMaterial.h
|
||||
hurricane/configuration/PyBasicLayer.h
|
||||
hurricane/configuration/PyViaLayer.h
|
||||
hurricane/configuration/PyRegularLayer.h
|
||||
hurricane/configuration/PyDiffusionLayer.h
|
||||
hurricane/configuration/PyTransistorLayer.h
|
||||
)
|
||||
set( cpps Parameter.cpp
|
||||
LayoutDescription.cpp
|
||||
|
@ -64,7 +69,12 @@
|
|||
PyTechnology.cpp
|
||||
PyLayerMask.cpp
|
||||
PyLayer.cpp
|
||||
PyMaterial.cpp
|
||||
PyBasicLayer.cpp
|
||||
PyViaLayer.cpp
|
||||
PyRegularLayer.cpp
|
||||
PyDiffusionLayer.cpp
|
||||
PyTransistorLayer.cpp
|
||||
PyHurricane3.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -28,6 +28,12 @@ extern "C" {
|
|||
|
||||
// Thin wrappers for overloadeds member functions.
|
||||
|
||||
static BasicLayer* create3 ( Technology* technology
|
||||
, Name name
|
||||
, BasicLayer::Material material
|
||||
)
|
||||
{ return BasicLayer::create( technology, name, material ); }
|
||||
|
||||
static BasicLayer* create5 ( Technology* technology
|
||||
, Name name
|
||||
, BasicLayer::Material material
|
||||
|
@ -53,7 +59,13 @@ extern "C" {
|
|||
, DbU::Unit minimalSize
|
||||
, DbU::Unit minimalSpacing
|
||||
)
|
||||
{ return BasicLayer::create( technology, name, material, gds2Layer, gds2Datatype, minimalSize, minimalSpacing ); }
|
||||
{ return BasicLayer::create( technology
|
||||
, name
|
||||
, material
|
||||
, gds2Layer
|
||||
, gds2Datatype
|
||||
, minimalSize
|
||||
, minimalSpacing ); }
|
||||
|
||||
|
||||
// Python methods.
|
||||
|
@ -63,29 +75,30 @@ extern "C" {
|
|||
PyObject* rvalue = callFunction("BasicLayer.create",&create7,args);
|
||||
if (not rvalue) rvalue = callFunction("BasicLayer.create",&create6,args);
|
||||
if (not rvalue) rvalue = callFunction("BasicLayer.create",&create5,args);
|
||||
if (not rvalue) rvalue = callFunction("BasicLayer.create",&create3,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyBasicLayer_getMaterial ( PyVoidPointer* self )
|
||||
{ return callMethod("BasicLayer.getMaterial",&BasicLayer::getMaterial,self,NULL); }
|
||||
static PyObject* PyBasicLayer_getMaterial ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("BasicLayer.getMaterial",&BasicLayer::getMaterial,self,args); }
|
||||
|
||||
static PyObject* PyBasicLayer_getBlockageLayer ( PyVoidPointer* self )
|
||||
{ return callMethod("BasicLayer.getBlockageLayer",&BasicLayer::getBlockageLayer,self,NULL); }
|
||||
static PyObject* PyBasicLayer_getBlockageLayer ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("BasicLayer.getBlockageLayer",&BasicLayer::getBlockageLayer,self,args); }
|
||||
|
||||
static PyObject* PyBasicLayer_setBlockageLayer ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBasicLayer_setBlockageLayer ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("BasicLayer.setBlockageLayer",&BasicLayer::setBlockageLayer,self,args); }
|
||||
|
||||
static PyObject* PyBasicLayer_setGds2Layer ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBasicLayer_setGds2Layer ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("BasicLayer.setGds2Layer",&BasicLayer::setGds2Layer,self,args); }
|
||||
|
||||
static PyObject* PyBasicLayer_setGds2Datatype ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBasicLayer_setGds2Datatype ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("BasicLayer.setGds2Datatype",&BasicLayer::setGds2Datatype,self,args); }
|
||||
|
||||
static PyObject* PyBasicLayer_setRealName ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBasicLayer_setRealName ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("BasicLayer.setRealName",&BasicLayer::setRealName,self,args); }
|
||||
|
||||
static PyObject* PyBasicLayer_destroy ( PyVoidPointer* self )
|
||||
{ return callMethod("BasicLayer.destroy",&BasicLayer::destroy,self,NULL); }
|
||||
static PyObject* PyBasicLayer_destroy ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("BasicLayer.destroy",&BasicLayer::destroy,self,args); }
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
|
|
@ -87,61 +87,61 @@ extern "C" {
|
|||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyBox_isEmpty ( PyVoidPointer* self )
|
||||
{ return callMethod("Box.isEmpty",&Box::isEmpty,self,NULL); }
|
||||
static PyObject* PyBox_isEmpty ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.isEmpty",&Box::isEmpty,self,args); }
|
||||
|
||||
static PyObject* PyBox_isFlat ( PyVoidPointer* self )
|
||||
{ return callMethod("Box.isFlat",&Box::isFlat,self,NULL); }
|
||||
static PyObject* PyBox_isFlat ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.isFlat",&Box::isFlat,self,args); }
|
||||
|
||||
static PyObject* PyBox_isPonctual ( PyVoidPointer* self )
|
||||
{ return callMethod("Box.isPonctual",&Box::isPonctual,self,NULL); }
|
||||
static PyObject* PyBox_isPonctual ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.isPonctual",&Box::isPonctual,self,args); }
|
||||
|
||||
static PyObject* PyBox_getXMin ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getXMin ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getXMin",&Box::getXMin,self,args); }
|
||||
|
||||
static PyObject* PyBox_getYMin ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getYMin ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getYMin",&Box::getYMin,self,args); }
|
||||
|
||||
static PyObject* PyBox_getXMax ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getXMax ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getXMax",&Box::getXMax,self,args); }
|
||||
|
||||
static PyObject* PyBox_getYMax ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getYMax ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getYMax",&Box::getYMax,self,args); }
|
||||
|
||||
static PyObject* PyBox_getXCenter ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getXCenter ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getXCenter",&Box::getXCenter,self,args); }
|
||||
|
||||
static PyObject* PyBox_getYCenter ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getYCenter ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getYCenter",&Box::getYCenter,self,args); }
|
||||
|
||||
static PyObject* PyBox_getCenter ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getCenter ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getCenter",&Box::getCenter,self,args); }
|
||||
|
||||
static PyObject* PyBox_getWidth ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getWidth ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getWidth",&Box::getWidth,self,args); }
|
||||
|
||||
static PyObject* PyBox_getHalfWidth ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getHalfWidth ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getHalfWidth",&Box::getHalfWidth,self,args); }
|
||||
|
||||
static PyObject* PyBox_getHeight ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getHeight ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getHeight",&Box::getHeight,self,args); }
|
||||
|
||||
static PyObject* PyBox_getHalfHeight ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getHalfHeight ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getHalfHeight",&Box::getHalfHeight,self,args); }
|
||||
|
||||
static PyObject* PyBox_getUnion ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getUnion ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getUnion",&Box::getUnion,self,args); }
|
||||
|
||||
static PyObject* PyBox_getIntersection ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_getIntersection ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.getIntersection",&Box::getIntersection,self,args); }
|
||||
|
||||
static PyObject* PyBox_intersect ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_intersect ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.intersect",&Box::intersect,self,args); }
|
||||
|
||||
static PyObject* PyBox_isConstrainedBy ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_isConstrainedBy ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.isConstrainedBy",&Box::isConstrainedBy,self,args); }
|
||||
|
||||
static PyObject* PyBox_inflate ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_inflate ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Box.inflate",&inflate4,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Box.inflate",&inflate2,self,args);
|
||||
|
@ -149,7 +149,7 @@ extern "C" {
|
|||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyBox_merge ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_merge ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Box.merge4",&merge4 ,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Box.merge2",&merge2 ,self,args);
|
||||
|
@ -158,7 +158,7 @@ extern "C" {
|
|||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyBox_contains ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_contains ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Box.contains",&contains2 ,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Box.contains",&contains1b,self,args);
|
||||
|
@ -166,7 +166,7 @@ extern "C" {
|
|||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyBox_makeEmpty ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyBox_makeEmpty ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Box.makeEmpty",&Box::makeEmpty,self,args); }
|
||||
|
||||
PyObject* PyBox_NEW ( PyTypeObject* pyType, PyObject* args, PyObject* kwargs )
|
||||
|
|
|
@ -56,10 +56,10 @@ extern "C" {
|
|||
|
||||
// Getter & Setters, for members/attributes.
|
||||
|
||||
static PyObject* PyConfiguration_getFlags ( PyVoidPointer* self, void* closure )
|
||||
static PyObject* PyConfiguration_getFlags ( PyObject* self, void* closure )
|
||||
{ return callMethod("Configuration.getFlags",&Configuration::getFlags,self,NULL); }
|
||||
|
||||
static PyObject* PyConfiguration_setFlags ( PyVoidPointer* self, PyObject* value, void* closure )
|
||||
static PyObject* PyConfiguration_setFlags ( PyObject* self, PyObject* value, void* closure )
|
||||
{
|
||||
callMethod("Configuration.setFlags",&Configuration::setFlags,self,PyTuple_Pack(1,value));
|
||||
return 0;
|
||||
|
@ -68,23 +68,23 @@ extern "C" {
|
|||
|
||||
// Object methods.
|
||||
|
||||
static PyObject* PyConfiguration_get ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyConfiguration_get ( PyObject*, PyObject* args )
|
||||
{ return callFunction("Configuration.get",&Configuration::get,args); }
|
||||
|
||||
|
||||
static PyObject* PyConfiguration_pushDefaultPriority ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyConfiguration_pushDefaultPriority ( PyObject*, PyObject* args )
|
||||
{ return callFunction("Configuration.pushDefaultPriority",&Configuration::pushDefaultPriority,args); }
|
||||
|
||||
|
||||
static PyObject* PyConfiguration_popDefaultPriority ( PyVoidPointer* )
|
||||
{ return callFunction("Configuration.popDefaultPriority",&Configuration::popDefaultPriority,NULL); }
|
||||
static PyObject* PyConfiguration_popDefaultPriority ( PyObject*, PyObject* args )
|
||||
{ return callFunction("Configuration.popDefaultPriority",&Configuration::popDefaultPriority,args); }
|
||||
|
||||
|
||||
static PyObject* PyConfiguration_getDefaultPriority ( PyVoidPointer* )
|
||||
{ return callFunction("Configuration.getDefaultPriority",&Configuration::getDefaultPriority,NULL); }
|
||||
static PyObject* PyConfiguration_getDefaultPriority ( PyObject*, PyObject* args )
|
||||
{ return callFunction("Configuration.getDefaultPriority",&Configuration::getDefaultPriority,args); }
|
||||
|
||||
|
||||
static PyObject* PyConfiguration_getParameter ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyConfiguration_getParameter ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Configuration.getParameter",&getParameter2,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Configuration.getParameter",&getParameter1,self,args);
|
||||
|
@ -92,7 +92,7 @@ extern "C" {
|
|||
}
|
||||
|
||||
|
||||
static PyObject* PyConfiguration_addParameter ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyConfiguration_addParameter ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Configuration.addParameter",&addParameter4,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Configuration.addParameter",&addParameter3,self,args);
|
||||
|
@ -100,11 +100,11 @@ extern "C" {
|
|||
}
|
||||
|
||||
|
||||
static PyObject* PyConfiguration_getParameters ( PyVoidPointer* self )
|
||||
{ return callMethod("Configuration.getParameters",&Configuration::getParameters,self,NULL); }
|
||||
static PyObject* PyConfiguration_getParameters ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Configuration.getParameters",&Configuration::getParameters,self,args); }
|
||||
|
||||
|
||||
static PyObject* PyConfiguration_getLayout ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyConfiguration_getLayout ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Configuration.getLayout",&getLayout,self,args); }
|
||||
|
||||
|
||||
|
|
|
@ -38,30 +38,30 @@ extern "C" {
|
|||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyDataBase_create ( PyVoidPointer* self )
|
||||
{ return callFunction("DataBase.create",&DataBase::create,NULL); }
|
||||
static PyObject* PyDataBase_create ( PyObject* self, PyObject* args )
|
||||
{ return callFunction("DataBase.create",&DataBase::create,args); }
|
||||
|
||||
static PyObject* PyDataBase_getDB ( PyVoidPointer* self )
|
||||
{ return callFunction("DataBase.getDB",&DataBase::getDB,NULL); }
|
||||
static PyObject* PyDataBase_getDB ( PyObject* self, PyObject* args )
|
||||
{ return callFunction("DataBase.getDB",&DataBase::getDB,args); }
|
||||
|
||||
static PyObject* PyDataBase_getTechnology ( PyVoidPointer* self )
|
||||
{ return callMethod("DataBase.getTechnology",&DataBase::getTechnology,self,NULL); }
|
||||
static PyObject* PyDataBase_getTechnology ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("DataBase.getTechnology",&DataBase::getTechnology,self,args); }
|
||||
|
||||
static PyObject* PyDataBase_getRootLibrary ( PyVoidPointer* self )
|
||||
{ return callMethod("DataBase.getRootLibrary",&DataBase::getRootLibrary,self,NULL); }
|
||||
static PyObject* PyDataBase_getRootLibrary ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("DataBase.getRootLibrary",&DataBase::getRootLibrary,self,args); }
|
||||
|
||||
static PyObject* PyDataBase_getCell ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyDataBase_getCell ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("DataBase.getCell",&getCell2,self,args);
|
||||
if (not rvalue) rvalue = callMethod("DataBase.getCell",&getCell1,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyDataBase_clear ( PyVoidPointer* self )
|
||||
{ return callMethod("DataBase.clear",&DataBase::clear,self,NULL); }
|
||||
static PyObject* PyDataBase_clear ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("DataBase.clear",&DataBase::clear,self,args); }
|
||||
|
||||
static PyObject* PyDataBase_destroy ( PyVoidPointer* self )
|
||||
{ return callMethod("DataBase.destroy",&DataBase::destroy,self,NULL); }
|
||||
static PyObject* PyDataBase_destroy ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("DataBase.destroy",&DataBase::destroy,self,args); }
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
|
|
@ -74,134 +74,134 @@ extern "C" {
|
|||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyDbU_fromDb ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_fromDb ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.fromDb",&DbU::fromDb,args); }
|
||||
|
||||
static PyObject* PyDbU_fromGrid ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_fromGrid ( PyObject*, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callFunction("DbU.fromGrid",&fromGridDouble,args);
|
||||
if (not rvalue) rvalue = callFunction("DbU.fromGrid",&fromGridLong,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyDbU_fromLambda ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_fromLambda ( PyObject*, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callFunction("DbU.fromLambda",&fromLambdaDouble,args);
|
||||
if (not rvalue) rvalue = callFunction("DbU.fromLambda",&fromLambdaLong,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyDbU_fromPhysical ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_fromPhysical ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.fromPhysical",&DbU::fromPhysical,args); }
|
||||
|
||||
static PyObject* PyDbU_getPrecision ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getPrecision ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.getPrecision",&DbU::getPrecision,args); }
|
||||
|
||||
static PyObject* PyDbU_getMaximalPrecision ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getMaximalPrecision ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.getMaximalPrecision",&DbU::getMaximalPrecision,args); }
|
||||
|
||||
static PyObject* PyDbU_getResolution ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getResolution ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.getResolution",&DbU::getResolution,args); }
|
||||
|
||||
static PyObject* PyDbU_setPrecision ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_setPrecision ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.setPrecision",&setPrecision1,args); }
|
||||
|
||||
static PyObject* PyDbU_getPolygonStep ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getPolygonStep ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.getPolygonStep",&DbU::getPolygonStep,args); }
|
||||
|
||||
static PyObject* PyDbU_setPolygonStep ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_setPolygonStep ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.setPolygonStep",&DbU::setPolygonStep,args); }
|
||||
|
||||
static PyObject* PyDbU_getUnitPower ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getUnitPower ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.getUnitPower",&DbU::getUnitPower,args); }
|
||||
|
||||
static PyObject* PyDbU_setPhysicalsPerGrid ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_setPhysicalsPerGrid ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.setPhysicalsPerGrid",&DbU::setPhysicalsPerGrid,args); }
|
||||
|
||||
static PyObject* PyDbU_getPhysicalsPerGrid ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getPhysicalsPerGrid ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.getPhysicalsPerGrid",&DbU::getPhysicalsPerGrid,args); }
|
||||
|
||||
static PyObject* PyDbU_physicalToGrid ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_physicalToGrid ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.physicalToGrid",&DbU::physicalToGrid,args); }
|
||||
|
||||
static PyObject* PyDbU_setGridsPerLambda ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_setGridsPerLambda ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.setGridsPerLambda",&setGridsPerLambda1,args); }
|
||||
|
||||
static PyObject* PyDbU_getGridsPerLambda ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getGridsPerLambda ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.getGridsPerLambda",&DbU::getGridsPerLambda,args); }
|
||||
|
||||
static PyObject* PyDbU_getRealSnapGridStep ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getRealSnapGridStep ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.getRealSnapGridStep",&DbU::getRealSnapGridStep,args); }
|
||||
|
||||
static PyObject* PyDbU_getOnRealSnapGrid ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getOnRealSnapGrid ( PyObject*, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callFunction("DbU.getOnRealSnapGrid",&getOnRealSnapGrid2,args);
|
||||
if (not rvalue) rvalue = callFunction("DbU.getOnRealSnapGrid",&getOnRealSnapGrid1,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyDbU_setRealSnapGridStep ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_setRealSnapGridStep ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.setRealSnapGridStep",&DbU::setRealSnapGridStep,args); }
|
||||
|
||||
static PyObject* PyDbU_getSymbolicSnapGridStep ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getSymbolicSnapGridStep ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.getSymbolicSnapGridStep",&DbU::getSymbolicSnapGridStep,args); }
|
||||
|
||||
static PyObject* PyDbU_getOnSymbolicSnapGrid ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getOnSymbolicSnapGrid ( PyObject*, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callFunction("DbU.getOnSymbolicSnapGrid",&getOnSymbolicSnapGrid2,args);
|
||||
if (not rvalue) rvalue = callFunction("DbU.getOnSymbolicSnapGrid",&getOnSymbolicSnapGrid1,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyDbU_setSymbolicSnapGridStep ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_setSymbolicSnapGridStep ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.setSymbolicSnapGridStep",&DbU::setSymbolicSnapGridStep,args); }
|
||||
|
||||
static PyObject* PyDbU_getOnCustomGrid ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getOnCustomGrid ( PyObject*, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callFunction("DbU.getOnCustomGrid",&getOnCustomGrid3,args);
|
||||
if (not rvalue) rvalue = callFunction("DbU.getOnCustomGrid",&getOnCustomGrid2,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyDbU_getOnPhysicalGrid ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getOnPhysicalGrid ( PyObject*, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callFunction("DbU.getOnPhysicalGrid",&getOnPhysicalGrid2,args);
|
||||
if (not rvalue) rvalue = callFunction("DbU.getOnPhysicalGrid",&getOnPhysicalGrid1,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyDbU_toDb ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_toDb ( PyObject*, PyObject* args )
|
||||
{ return callFunction("DbU.toDb",&DbU::toDb,args); }
|
||||
|
||||
static PyObject* PyDbU_toGrid ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_toGrid ( PyObject*, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callFunction("DbU.toGrid",&toGridDouble,args);
|
||||
if (not rvalue) rvalue = callFunction("DbU.toGrid",&toGridLong,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyDbU_toLambda ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_toLambda ( PyObject*, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callFunction("DbU.toLambda",&toLambdaDouble,args);
|
||||
if (not rvalue) rvalue = callFunction("DbU.toLambda",&toLambdaLong,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyDbU_toPhysical ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_toPhysical ( PyObject*, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callFunction("DbU.toPhysical",&toPhysicalDouble,args);
|
||||
if (not rvalue) rvalue = callFunction("DbU.toPhysical",&toPhysicalLong,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyDbU_getValueString ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_getValueString ( PyObject*, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callFunction("DbU.getValueString",&getValueString2,args);
|
||||
if (not rvalue) rvalue = callFunction("DbU.getValueString",&getValueString1,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyDbU_setStringMode ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyDbU_setStringMode ( PyObject*, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callFunction("DbU.setStringMode",&setStringMode2,args);
|
||||
if (not rvalue) rvalue = callFunction("DbU.setStringMode",&setStringMode1,args);
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) Sorbonne Université 2020-2021, 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 : "./PyDiffusionLayer.cpp" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#include "hurricane/configuration/PyName.h"
|
||||
#include "hurricane/configuration/PyTechnology.h"
|
||||
#include "hurricane/configuration/PyBasicLayer.h"
|
||||
#include "hurricane/configuration/PyDiffusionLayer.h"
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
||||
using namespace Hurricane;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyDiffusionLayer_create ( PyObject* self, PyObject* args )
|
||||
{ return callFunction("DiffusionLayer.create",&DiffusionLayer::create,args); }
|
||||
|
||||
static PyObject* PyDiffusionLayer_destroy ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("DiffusionLayer.destroy",&DiffusionLayer::destroy,self,args); }
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// PyDiffusionLayer Attribute Method table.
|
||||
|
||||
PyMethodDef PyDiffusionLayer_Methods[] =
|
||||
{ { "create" , (PyCFunction)PyDiffusionLayer_create , METH_VARARGS|METH_STATIC
|
||||
, "Create a new DiffusionLayer." }
|
||||
, { "destroy" , (PyCFunction)PyDiffusionLayer_destroy , METH_NOARGS
|
||||
, "destroy associated hurricane object, the python object remains." }
|
||||
, {NULL, NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar3 namespace.
|
|
@ -1,7 +1,7 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) SU/LIP6 2010-2021, All Rights Reserved
|
||||
// Copyright (c) SU 2021-2021, All Rights Reserved
|
||||
//
|
||||
// +-----------------------------------------------------------------+
|
||||
// | C O R I O L I S |
|
||||
|
@ -15,6 +15,7 @@
|
|||
|
||||
|
||||
#include "hurricane/configuration/PyTypeManager.h"
|
||||
#include "hurricane/configuration/PyCollection.h"
|
||||
#include "hurricane/configuration/PyDbU.h"
|
||||
#include "hurricane/configuration/PyPoint.h"
|
||||
#include "hurricane/configuration/PyBox.h"
|
||||
|
@ -23,6 +24,10 @@
|
|||
#include "hurricane/configuration/PyLayerMask.h"
|
||||
#include "hurricane/configuration/PyLayer.h"
|
||||
#include "hurricane/configuration/PyBasicLayer.h"
|
||||
#include "hurricane/configuration/PyViaLayer.h"
|
||||
#include "hurricane/configuration/PyRegularLayer.h"
|
||||
#include "hurricane/configuration/PyDiffusionLayer.h"
|
||||
#include "hurricane/configuration/PyTransistorLayer.h"
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
@ -62,6 +67,7 @@ extern "C" {
|
|||
}
|
||||
PyObject* dictionnary = PyModule_GetDict( module );
|
||||
|
||||
try {
|
||||
PyTypeManagerNonDBo<DbU>::create ( module
|
||||
, PyDbU_Methods
|
||||
, NULL
|
||||
|
@ -110,11 +116,55 @@ extern "C" {
|
|||
, NULL
|
||||
, PyTypeManager::NoCppDelete
|
||||
);
|
||||
PyTypeManagerDBo<BasicLayer>::create( module
|
||||
PyTypeManagerDerivedDBo<BasicLayer,Layer>::create( module
|
||||
, PyBasicLayer_Methods
|
||||
, NULL
|
||||
, PyTypeManager::NoCppDelete
|
||||
);
|
||||
PyTypeManagerDerivedDBo<ViaLayer,Layer>::create( module
|
||||
, PyViaLayer_Methods
|
||||
, NULL
|
||||
, PyTypeManager::NoCppDelete
|
||||
);
|
||||
PyTypeManagerDerivedDBo<RegularLayer,Layer>::create( module
|
||||
, PyRegularLayer_Methods
|
||||
, NULL
|
||||
, PyTypeManager::NoCppDelete
|
||||
);
|
||||
PyTypeManagerDerivedDBo<DiffusionLayer,Layer>::create( module
|
||||
, PyDiffusionLayer_Methods
|
||||
, NULL
|
||||
, PyTypeManager::NoCppDelete
|
||||
);
|
||||
PyTypeManagerDerivedDBo<TransistorLayer,Layer>::create( module
|
||||
, PyTransistorLayer_Methods
|
||||
, NULL
|
||||
, PyTypeManager::NoCppDelete
|
||||
);
|
||||
PyTypeManagerCollection< Layer>::create( module, PyTypeManager::NoCppDelete );
|
||||
PyTypeManagerCollection< BasicLayer>::create( module, PyTypeManager::NoCppDelete );
|
||||
PyTypeManagerCollection< ViaLayer>::create( module, PyTypeManager::NoCppDelete );
|
||||
PyTypeManagerCollection<RegularLayer>::create( module, PyTypeManager::NoCppDelete );
|
||||
} catch ( const Warning& w ) {
|
||||
cerr << getString(w) << endl;
|
||||
throw;
|
||||
} catch ( const Error& e ) {
|
||||
cerr << getString(e) << endl;
|
||||
if (not e.where().empty()) cerr << e.where() << endl;
|
||||
throw;
|
||||
} catch ( const Bug& e ) {
|
||||
cerr << getString(e) << endl;
|
||||
throw;
|
||||
} catch ( const Exception& e ) {
|
||||
cerr << "\nUnknown Hurricane::Exception" << endl;
|
||||
throw;
|
||||
} catch ( const std::exception& e ) {
|
||||
cerr << e.what() << endl;
|
||||
throw;
|
||||
} catch ( ... ) {
|
||||
cerr << "Unmanaged exception, neither a Hurricane::Error nor a std::exception." << endl;
|
||||
throw;
|
||||
}
|
||||
|
||||
cdebug_log(20,0)
|
||||
<< "Hurricane3.so loaded " << (void*)&typeid(string)
|
||||
|
|
|
@ -50,131 +50,131 @@ extern "C" {
|
|||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyLayer_getTechnology ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.getTechnology",&Layer::getTechnology,self,NULL); }
|
||||
static PyObject* PyLayer_getTechnology ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getTechnology",&Layer::getTechnology,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getName ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.getName",&Layer::getName,self,NULL); }
|
||||
static PyObject* PyLayer_getName ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getName",&Layer::getName,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getMask ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.getMask",&Layer::getMask,self,NULL); }
|
||||
static PyObject* PyLayer_getMask ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getMask",&Layer::getMask,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getExtractMask ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.getExtractMask",&Layer::getExtractMask,self,NULL); }
|
||||
static PyObject* PyLayer_getExtractMask ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getExtractMask",&Layer::getExtractMask,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getMinimalSize ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.getMinimalSize",&Layer::getMinimalSize,self,NULL); }
|
||||
static PyObject* PyLayer_getMinimalSize ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getMinimalSize",&Layer::getMinimalSize,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getMinimalSpacing ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.getMinimalSpacing",&Layer::getMinimalSpacing,self,NULL); }
|
||||
static PyObject* PyLayer_getMinimalSpacing ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getMinimalSpacing",&Layer::getMinimalSpacing,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getBasicLayers ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.getBasicLayers",&Layer::getBasicLayers,self,NULL); }
|
||||
static PyObject* PyLayer_getBasicLayers ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getBasicLayers",&Layer::getBasicLayers,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getBlockageLayer ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.getBlockageLayer",&Layer::getBlockageLayer,self,NULL); }
|
||||
static PyObject* PyLayer_getBlockageLayer ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getBlockageLayer",&Layer::getBlockageLayer,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getCut ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.getCut",&Layer::getCut,self,NULL); }
|
||||
static PyObject* PyLayer_getCut ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getCut",&Layer::getCut,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getTop ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.getTop",&Layer::getTop,self,NULL); }
|
||||
static PyObject* PyLayer_getTop ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getTop",&Layer::getTop,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getBottom ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.getBottom",&Layer::getBottom,self,NULL); }
|
||||
static PyObject* PyLayer_getBottom ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getBottom",&Layer::getBottom,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getOpposite ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_getOpposite ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getOpposite",&Layer::getOpposite,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getMetalAbove ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_getMetalAbove ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getMetalAbove",&Layer::getMetalAbove,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getMetalBelow ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_getMetalBelow ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getMetalBelow",&Layer::getMetalBelow,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getCutAbove ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_getCutAbove ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getCutAbove",&Layer::getCutAbove,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getCutBelow ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_getCutBelow ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getCutBelow",&Layer::getCutBelow,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getEnclosure ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_getEnclosure ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Layer.getEnclosure",&getEnclosure2,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Layer.getEnclosure",&getEnclosure1,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyLayer_getExtentionCap ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_getExtentionCap ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Layer.getExtensionCap",&getExtentionCap1,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Layer.getExtensionCap",&getExtentionCap0,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyLayer_getExtentionWidth ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_getExtentionWidth ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Layer.getExtensionWidth",&getExtentionWidth1,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Layer.getExtensionWidth",&getExtentionWidth0,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyLayer_getTopEnclosure ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_getTopEnclosure ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getTopEnclosure",&Layer::getTopEnclosure,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getBottomEnclosure ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_getBottomEnclosure ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getBottomEnclosure",&Layer::getBottomEnclosure,self,args); }
|
||||
|
||||
static PyObject* PyLayer_getMinimalArea ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.getMinimalArea",&Layer::getMinimalArea,self,NULL); }
|
||||
static PyObject* PyLayer_getMinimalArea ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.getMinimalArea",&Layer::getMinimalArea,self,args); }
|
||||
|
||||
static PyObject* PyLayer_above ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_above ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.above",&Layer::above,self,args); }
|
||||
|
||||
static PyObject* PyLayer_below ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_below ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.below",&Layer::below,self,args); }
|
||||
|
||||
static PyObject* PyLayer_contains ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_contains ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.contains",&Layer::contains,self,args); }
|
||||
|
||||
static PyObject* PyLayer_intersect ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_intersect ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.intersect",&Layer::intersect,self,args); }
|
||||
|
||||
static PyObject* PyLayer_isSymbolic ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.isSymbolic",&Layer::isSymbolic,self,NULL); }
|
||||
static PyObject* PyLayer_isSymbolic ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.isSymbolic",&Layer::isSymbolic,self,args); }
|
||||
|
||||
static PyObject* PyLayer_isBlockage ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.isBlockage",&Layer::isBlockage,self,NULL); }
|
||||
static PyObject* PyLayer_isBlockage ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.isBlockage",&Layer::isBlockage,self,args); }
|
||||
|
||||
static PyObject* PyLayer_setName ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_setName ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.setName",&Layer::setName,self,args); }
|
||||
|
||||
static PyObject* PyLayer_setSymbolic ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_setSymbolic ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.setSymbolic",&Layer::setSymbolic,self,args); }
|
||||
|
||||
static PyObject* PyLayer_setBlockage ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_setBlockage ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.setBlockage",&Layer::setBlockage,self,args); }
|
||||
|
||||
static PyObject* PyLayer_setMinimalSize ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_setMinimalSize ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.setMinimalSize",&Layer::setMinimalSize,self,args); }
|
||||
|
||||
static PyObject* PyLayer_setMinimalSpacing ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_setMinimalSpacing ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.setMinimalSpacing",&Layer::setMinimalSpacing,self,args); }
|
||||
|
||||
static PyObject* PyLayer_setEnclosure ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_setEnclosure ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.setEnclosure",&Layer::setEnclosure,self,args); }
|
||||
|
||||
static PyObject* PyLayer_setExtentionCap ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_setExtentionCap ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.setExtentionCap",&Layer::setExtentionCap,self,args); }
|
||||
|
||||
static PyObject* PyLayer_setExtentionWidth ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_setExtentionWidth ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.setExtentionWidth",&Layer::setExtentionWidth,self,args); }
|
||||
|
||||
static PyObject* PyLayer_setMinimalArea ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayer_setMinimalArea ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.setMinimalArea",&Layer::setMinimalArea,self,args); }
|
||||
|
||||
static PyObject* PyLayer_destroy ( PyVoidPointer* self )
|
||||
{ return callMethod("Layer.destroy",&Layer::destroy,self,NULL); }
|
||||
static PyObject* PyLayer_destroy ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Layer.destroy",&Layer::destroy,self,args); }
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
|
|
@ -49,28 +49,28 @@ extern "C" {
|
|||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyLayerMask_zero ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayerMask_zero ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("PyLayerMask.zero",&Layer::Mask::zero,self,args); }
|
||||
|
||||
static PyObject* PyLayerMask_set ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayerMask_set ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("PyLayerMask.set",&Layer::Mask::set,self,args); }
|
||||
|
||||
static PyObject* PyLayerMask_unset ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayerMask_unset ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("PyLayerMask.unset",&Layer::Mask::unset,self,args); }
|
||||
|
||||
static PyObject* PyLayerMask_isSet ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayerMask_isSet ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("PyLayerMask.isSet",&Layer::Mask::isSet,self,args); }
|
||||
|
||||
static PyObject* PyLayerMask_contains ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayerMask_contains ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("PyLayerMask.contains",&Layer::Mask::contains,self,args); }
|
||||
|
||||
static PyObject* PyLayerMask_intersect ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayerMask_intersect ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("PyLayerMask.intersect",&Layer::Mask::intersect,self,args); }
|
||||
|
||||
static PyObject* PyLayerMask_nthbit ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayerMask_nthbit ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("PyLayerMask.nthbit",&Layer::Mask::nthbit,self,args); }
|
||||
|
||||
static PyObject* PyLayerMask_fromString ( PyVoidPointer*, PyObject* args )
|
||||
static PyObject* PyLayerMask_fromString ( PyObject*, PyObject* args )
|
||||
{ return callFunction("PyLayerMask.fromString",&Layer::Mask::fromString,args); }
|
||||
|
||||
PyObject* PyLayerMask_NEW ( PyTypeObject* pyType, PyObject* args, PyObject* kwargs )
|
||||
|
@ -96,8 +96,8 @@ extern "C" {
|
|||
PyErr_SetString( PyExc_TypeError, message.c_str() );
|
||||
return NULL;
|
||||
}
|
||||
Layer::Mask* cself = reinterpret_cast<Layer::Mask*>( asVPtr(self )->_object );
|
||||
Layer::Mask* cother = reinterpret_cast<Layer::Mask*>( asVPtr(other)->_object );
|
||||
Layer::Mask* cself = reinterpret_cast<Layer::Mask*>( object1(self ) );
|
||||
Layer::Mask* cother = reinterpret_cast<Layer::Mask*>( object1(other) );
|
||||
|
||||
bool result = false;
|
||||
if ((op == Py_LT) and (*cself < *cother)) result = true;
|
||||
|
@ -140,7 +140,7 @@ extern "C" {
|
|||
{ return callPredicate( "Layer::Mask::nonzero", &Layer::Mask::zero,object ); }
|
||||
|
||||
static PyObject* PyLayerMask_invert ( PyObject* object )
|
||||
{ return callMethod( "Layer::Mask::invert", &invert, (PyVoidPointer*)object, NULL ); }
|
||||
{ return callMethod( "Layer::Mask::invert", &invert, object, NULL ); }
|
||||
|
||||
static PyObject* PyLayerMask_bitand ( PyObject* pyLhs, PyObject* pyRhs )
|
||||
{ return callOperator<Layer::Mask,std::bit_and>( "Layer::Mask::bitand", pyLhs, pyRhs ); }
|
||||
|
|
|
@ -82,23 +82,23 @@ extern "C" {
|
|||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyLayoutDescription_addTab ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayoutDescription_addTab ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("LayoutDescription.addTab",&addTab,self,args); }
|
||||
|
||||
static PyObject* PyLayoutDescription_addRule ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayoutDescription_addRule ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("LayoutDescription.addRule",&LayoutDescription::addRule,self,args); }
|
||||
|
||||
static PyObject* PyLayoutDescription_addTitle ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayoutDescription_addTitle ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("LayoutDescription.addTitle",&LayoutDescription::addTitle,self,args); }
|
||||
|
||||
static PyObject* PyLayoutDescription_addSection ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayoutDescription_addSection ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("LayoutDescription.addSection",&addSection3,self,args);
|
||||
if (not rvalue) rvalue = callMethod("LayoutDescription.addSection",&addSection2,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyLayoutDescription_addParameter ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyLayoutDescription_addParameter ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("LayoutDescription.addParameter",&addParameter6,self,args);
|
||||
if (not rvalue) rvalue = callMethod("LayoutDescription.addParameter",&addParameter5,self,args);
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) Sorbonne Université 2020-2021, 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 : "./PyMaterial.cpp" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#include "hurricane/configuration/PyMaterial.h"
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
||||
using namespace Hurricane;
|
||||
|
||||
extern "C" {
|
||||
|
||||
// Thin wrappers for overloadeds member functions.
|
||||
|
||||
static BasicLayer::Material* ctorMaterial ( long code )
|
||||
{ return new BasicLayer::Material ( (BasicLayer::Material::Code)code ); }
|
||||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyMaterial_getCode ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Material.getCode",&BasicLayer::Material::getCode,self,args); }
|
||||
|
||||
PyObject* PyMaterial_NEW ( PyTypeObject* pyType, PyObject* args, PyObject* kwargs )
|
||||
{
|
||||
return callFunction("BasicLayer::Material",&ctorMaterial,args);
|
||||
}
|
||||
|
||||
int PyMaterial_Init ( PyObject* self, PyObject* args, PyObject* kwargs )
|
||||
{
|
||||
cdebug_log(20,0) << "PyMaterial_Init(): " << (void*)self << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// PyMaterial Method table.
|
||||
|
||||
PyMethodDef PyMaterial_Methods[] =
|
||||
{ { "getCode" , (PyCFunction)PyMaterial_getCode, METH_NOARGS
|
||||
, "Returns the numerical code of the material (enum)." }
|
||||
, {NULL, NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar3 namespace.
|
|
@ -63,58 +63,58 @@ extern "C" {
|
|||
|
||||
// Python getters & setters.
|
||||
|
||||
static PyObject* PyParameter_getFlags ( PyVoidPointer* self, void* closure )
|
||||
static PyObject* PyParameter_getFlags ( PyObject* self, void* closure )
|
||||
{ return callMethod("Parameter.getFlags",&Parameter::getFlags,self,NULL); }
|
||||
|
||||
static PyObject* PyParameter_setFlags ( PyVoidPointer* self, PyObject* value, void* closure )
|
||||
static PyObject* PyParameter_setFlags ( PyObject* self, PyObject* value, void* closure )
|
||||
{
|
||||
callMethod("Parameter.setFlags",&Parameter::setFlags,self,PyTuple_Pack(1,value));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject* PyParameter_getType ( PyVoidPointer* self, void* closure )
|
||||
static PyObject* PyParameter_getType ( PyObject* self, void* closure )
|
||||
{ return callMethod("Parameter.getType",&Parameter::getType,self,NULL); }
|
||||
|
||||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyParameter_isFile ( PyVoidPointer* self )
|
||||
{ return callMethod("Parameter.isFile",&Parameter::isFile,self,NULL); }
|
||||
static PyObject* PyParameter_isFile ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.isFile",&Parameter::isFile,self,args); }
|
||||
|
||||
static PyObject* PyParameter_isPath ( PyVoidPointer* self )
|
||||
{ return callMethod("Parameter.isPath",&Parameter::isPath,self,NULL); }
|
||||
static PyObject* PyParameter_isPath ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.isPath",&Parameter::isPath,self,args); }
|
||||
|
||||
static PyObject* PyParameter_hasMin ( PyVoidPointer* self )
|
||||
{ return callMethod("Parameter.hasMin",&Parameter::hasMin,self,NULL); }
|
||||
static PyObject* PyParameter_hasMin ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.hasMin",&Parameter::hasMin,self,args); }
|
||||
|
||||
static PyObject* PyParameter_hasMax ( PyVoidPointer* self )
|
||||
{ return callMethod("Parameter.hasMax",&Parameter::hasMax,self,NULL); }
|
||||
static PyObject* PyParameter_hasMax ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.hasMax",&Parameter::hasMax,self,args); }
|
||||
|
||||
static PyObject* PyParameter_hasNeedRestart ( PyVoidPointer* self )
|
||||
{ return callMethod("Parameter.hasNeedRestart",&Parameter::hasNeedRestart,self,NULL); }
|
||||
static PyObject* PyParameter_hasNeedRestart ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.hasNeedRestart",&Parameter::hasNeedRestart,self,args); }
|
||||
|
||||
static PyObject* PyParameter_hasMustExist ( PyVoidPointer* self )
|
||||
{ return callMethod("Parameter.hasMustExist",&Parameter::hasMustExist,self,NULL); }
|
||||
static PyObject* PyParameter_hasMustExist ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.hasMustExist",&Parameter::hasMustExist,self,args); }
|
||||
|
||||
static PyObject* PyParameter_hasFlags ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_hasFlags ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.hasFlags",&Parameter::hasFlags,self,args); }
|
||||
|
||||
static PyObject* PyParameter_getId ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_getId ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.getId",&Parameter::getId,self,args); }
|
||||
|
||||
static PyObject* PyParameter_getMinInt ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_getMinInt ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.getMinInt",&Parameter::getMinInt,self,args); }
|
||||
|
||||
static PyObject* PyParameter_getMaxInt ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_getMaxInt ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.getMaxInt",&Parameter::getMaxInt,self,args); }
|
||||
|
||||
static PyObject* PyParameter_getMinDouble ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_getMinDouble ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.getMinDouble",&Parameter::getMinDouble,self,args); }
|
||||
|
||||
static PyObject* PyParameter_getMaxDouble ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_getMaxDouble ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.getMaxDouble",&Parameter::getMaxDouble,self,args); }
|
||||
|
||||
static PyObject* PyParameter_checkValue ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_checkValue ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Parameter.checkValue",&checkValueInt,self,args);
|
||||
if (not rvalue)
|
||||
|
@ -122,34 +122,34 @@ extern "C" {
|
|||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyParameter_asBool ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_asBool ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.asBool",&Parameter::asBool,self,args); }
|
||||
|
||||
static PyObject* PyParameter_asInt ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_asInt ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.asInt",&Parameter::asInt,self,args); }
|
||||
|
||||
static PyObject* PyParameter_asDouble ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_asDouble ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.asDouble",&Parameter::asDouble,self,args); }
|
||||
|
||||
static PyObject* PyParameter_asPercentage ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_asPercentage ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.asPercentage",&Parameter::asPercentage,self,args); }
|
||||
|
||||
static PyObject* PyParameter_asString ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_asString ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.asString",&Parameter::asString,self,args); }
|
||||
|
||||
static PyObject* PyParameter_asPercentageString ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_asPercentageString ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.asPercentageString",&Parameter::asPercentageString,self,args); }
|
||||
|
||||
static PyObject* PyParameter_addValue ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_addValue ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.addValue",&Parameter::addValue,self,args); }
|
||||
|
||||
static PyObject* PyParameter_addSlave ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_addSlave ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.addSlave",&Parameter::addSlave,self,args); }
|
||||
|
||||
static PyObject* PyParameter_setPriority ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_setPriority ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.setPriority",&Parameter::setPriority,self,args); }
|
||||
|
||||
static PyObject* PyParameter_setString ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_setString ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Parameter.setString",&setString3,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Parameter.setString",&setString2,self,args);
|
||||
|
@ -157,28 +157,28 @@ extern "C" {
|
|||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyParameter_setBool ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_setBool ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Parameter.setBool",&setBool2,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Parameter.setBool",&setBool1,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyParameter_setInt ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_setInt ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Parameter.setInt",&setInt2,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Parameter.setInt",&setInt1,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyParameter_setDouble ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_setDouble ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Parameter.setDouble",&setDouble2,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Parameter.setDouble",&setDouble1,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyParameter_setPercentage ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_setPercentage ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Parameter.setPercentage",&setPercentage2 ,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Parameter.setPercentage",&setPercentage2i,self,args);
|
||||
|
@ -187,21 +187,21 @@ extern "C" {
|
|||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyParameter_setMin ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_setMin ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Parameter.setMin",&setMinDouble,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Parameter.setMin",&setMinInt ,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyParameter_setMax ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_setMax ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Parameter.setMax",&setMaxDouble,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Parameter.setMax",&setMaxInt ,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyParameter_getSlaves ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyParameter_getSlaves ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Parameter.getSlaves",&Parameter::getSlaves,self,args); }
|
||||
|
||||
|
||||
|
|
|
@ -47,16 +47,16 @@ extern "C" {
|
|||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyPoint_getX ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyPoint_getX ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Point.getX",&Point::getX,self,args); }
|
||||
|
||||
static PyObject* PyPoint_getY ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyPoint_getY ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Point.getY",&Point::getY,self,args); }
|
||||
|
||||
static PyObject* PyPoint_setX ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyPoint_setX ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Point.setX",&Point::setX,self,args); }
|
||||
|
||||
static PyObject* PyPoint_setY ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyPoint_setY ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Point.setY",&Point::setY,self,args); }
|
||||
|
||||
PyObject* PyPoint_NEW ( PyTypeObject* pyType, PyObject* args, PyObject* kwargs )
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) Sorbonne Université 2020-2021, 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 : "./PyRegularLayer.cpp" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#include "hurricane/configuration/PyName.h"
|
||||
#include "hurricane/configuration/PyTechnology.h"
|
||||
#include "hurricane/configuration/PyBasicLayer.h"
|
||||
#include "hurricane/configuration/PyRegularLayer.h"
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
||||
using namespace Hurricane;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyRegularLayer_create ( PyObject* self, PyObject* args )
|
||||
{ return callFunction("RegularLayer.create",&RegularLayer::create,args); }
|
||||
|
||||
static PyObject* PyRegularLayer_getBasicLayer ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("RegularLayer.getBasicLayer",&RegularLayer::getBasicLayer,self,args); }
|
||||
|
||||
static PyObject* PyRegularLayer_setBasicLayer ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("RegularLayer.setBasicLayer",&RegularLayer::setBasicLayer,self,args); }
|
||||
|
||||
static PyObject* PyRegularLayer_destroy ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("RegularLayer.destroy",&RegularLayer::destroy,self,args); }
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// PyRegularLayer Attribute Method table.
|
||||
|
||||
PyMethodDef PyRegularLayer_Methods[] =
|
||||
{ { "create" , (PyCFunction)PyRegularLayer_create , METH_VARARGS|METH_STATIC
|
||||
, "Create a new RegularLayer." }
|
||||
, { "getBasicLayer" , (PyCFunction)PyRegularLayer_getBasicLayer , METH_NOARGS
|
||||
, "Get the RegularLayer associated to this RegularLayer." }
|
||||
, { "setBasicLayer" , (PyCFunction)PyRegularLayer_setBasicLayer , METH_VARARGS
|
||||
, "Associate a RegularLayer with this RegularLayer." }
|
||||
, { "destroy" , (PyCFunction)PyRegularLayer_destroy , METH_NOARGS
|
||||
, "destroy associated hurricane object, the python object remains." }
|
||||
, {NULL, NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar3 namespace.
|
|
@ -77,41 +77,41 @@ extern "C" {
|
|||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyTechnology_create ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_create ( PyObject* self, PyObject* args )
|
||||
{
|
||||
//Name test;
|
||||
//pyToC( NULL, &test );
|
||||
return callFunction("Technology.create",&Technology::create,args);
|
||||
}
|
||||
|
||||
static PyObject* PyTechnology_getDataBase ( PyVoidPointer* self )
|
||||
{ return callMethod("Technology.getDataBase",&Technology::getDataBase,self,NULL); }
|
||||
static PyObject* PyTechnology_getDataBase ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getDataBase",&Technology::getDataBase,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getLayer ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getLayer ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Technology.getLayer",&getLayer2,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Technology.getLayer",&getLayer1,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyTechnology_getBasicLayers ( PyVoidPointer* self )
|
||||
static PyObject* PyTechnology_getBasicLayers ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Technology.getBasicLayers",&getBasicLayers1,self,NULL);
|
||||
if (not rvalue) rvalue = callMethod("Technology.getBasicLayers",&getBasicLayers0,self,NULL);
|
||||
PyObject* rvalue = callMethod("Technology.getBasicLayers",&getBasicLayers1,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Technology.getBasicLayers",&getBasicLayers0,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyTechnology_setSymbolicLayer ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_setSymbolicLayer ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Technology.setSymbolicLayer",&setSymbolicLayerLayer ,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Technology.setSymbolicLayer",&setSymbolicLayerString,self,args);
|
||||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyTechnology_getUnitRule ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getUnitRule ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getUnitRule",&Technology::getUnitRule,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getPhysicalRule ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getPhysicalRule ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Technology.getPhysicalRule",&getPhysicalRule3,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Technology.getPhysicalRule",&getPhysicalRule2,self,args);
|
||||
|
@ -119,10 +119,10 @@ extern "C" {
|
|||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyTechnology_addUnitRule ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_addUnitRule ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.addUnitRule",&Technology::addUnitRule,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_addPhysicalRule ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_addPhysicalRule ( PyObject* self, PyObject* args )
|
||||
{
|
||||
PyObject* rvalue = callMethod("Technology.addPhysicalRule",&addPhysicalRule4,self,args);
|
||||
if (not rvalue) rvalue = callMethod("Technology.addPhysicalRule",&addPhysicalRule3,self,args);
|
||||
|
@ -130,59 +130,59 @@ extern "C" {
|
|||
return rvalue;
|
||||
}
|
||||
|
||||
static PyObject* PyTechnology_getDeviceDescriptor ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getDeviceDescriptor ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getDeviceDescriptor",&Technology::getDeviceDescriptor,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_addDeviceDescriptor ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_addDeviceDescriptor ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.addDeviceDescriptor",&Technology::addDeviceDescriptor,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getName ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getName ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getName",&Technology::getName,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_setName ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_setName ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.setName",&setName,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_isMetal ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_isMetal ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.isMetal",&Technology::isMetal,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getBasicLayer ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getBasicLayer ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getBasicLayer",&Technology::getBasicLayer,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getRegularLayer ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getRegularLayer ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getRegularLayer",&Technology::getRegularLayer,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getViaLayer ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getViaLayer ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getViaLayer",&Technology::getViaLayer,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getLayers ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getLayers ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getLayers",&Technology::getLayers,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getRegularLayers ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getRegularLayers ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getRegularLayers",&Technology::getRegularLayers,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getViaLayers ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getViaLayers ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getViaLayers",&Technology::getViaLayers,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getMetalAbove ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getMetalAbove ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getMetalAbove",&Technology::getMetalAbove,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getMetalBelow ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getMetalBelow ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getMetalBelow",&Technology::getMetalBelow,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getCutAbove ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getCutAbove ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getCutAbove",&Technology::getCutAbove,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getCutBelow ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getCutBelow ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getCutBelow",&Technology::getCutBelow,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getViaBetween ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getViaBetween ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getViaBetween",&Technology::getViaBetween,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_getNthMetal ( PyVoidPointer* self, PyObject* args )
|
||||
static PyObject* PyTechnology_getNthMetal ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.getNthMetal",&Technology::getNthMetal,self,args); }
|
||||
|
||||
static PyObject* PyTechnology_destroy ( PyVoidPointer* self )
|
||||
{ return callMethod("Technology.destroy",&Technology::destroy,self,NULL); }
|
||||
static PyObject* PyTechnology_destroy ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("Technology.destroy",&Technology::destroy,self,args); }
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) Sorbonne Université 2020-2021, 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 : "./PyTransistorLayer.cpp" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#include "hurricane/configuration/PyName.h"
|
||||
#include "hurricane/configuration/PyTechnology.h"
|
||||
#include "hurricane/configuration/PyBasicLayer.h"
|
||||
#include "hurricane/configuration/PyTransistorLayer.h"
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
||||
using namespace Hurricane;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyTransistorLayer_create ( PyObject* self, PyObject* args )
|
||||
{ return callFunction("TransistorLayer.create",&TransistorLayer::create,args); }
|
||||
|
||||
static PyObject* PyTransistorLayer_destroy ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("TransistorLayer.destroy",&TransistorLayer::destroy,self,args); }
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// PyTransistorLayer Attribute Method table.
|
||||
|
||||
PyMethodDef PyTransistorLayer_Methods[] =
|
||||
{ { "create" , (PyCFunction)PyTransistorLayer_create , METH_VARARGS|METH_STATIC
|
||||
, "Create a new TransistorLayer." }
|
||||
, { "destroy" , (PyCFunction)PyTransistorLayer_destroy , METH_NOARGS
|
||||
, "destroy associated hurricane object, the python object remains." }
|
||||
, {NULL, NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar3 namespace.
|
|
@ -29,30 +29,30 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
void _tpDeAlloc ( PyObject* self )
|
||||
{ PyTypeManager::get( Py_TYPE(self) )->_getTpDeAlloc( asVPtr(self) ); }
|
||||
{ PyTypeManager::get( Py_TYPE(self) )->_getTpDeAlloc( self ); }
|
||||
|
||||
|
||||
PyObject* _tpStr ( PyObject* self )
|
||||
{ return PyTypeManager::get( Py_TYPE(self) )->_getTpStr( asVPtr(self) ); }
|
||||
{ return PyTypeManager::get( Py_TYPE(self) )->_getTpStr( self ); }
|
||||
|
||||
|
||||
long _tpHash ( PyObject* self )
|
||||
{ return PyTypeManager::get( Py_TYPE(self) )->_getTpHash( asVPtr(self) ); }
|
||||
{ return PyTypeManager::get( Py_TYPE(self) )->_getTpHash( self ); }
|
||||
|
||||
|
||||
Py_ssize_t _sqLength ( PyVoidPointer* self )
|
||||
Py_ssize_t _sqLength ( PyObject* self )
|
||||
{ return PyTypeManager::get( Py_TYPE(self) )->_getSqLength( self ); }
|
||||
|
||||
|
||||
PyObject* _sqConcat ( PyVoidPointer* a, PyVoidPointer* b )
|
||||
PyObject* _sqConcat ( PyObject* a, PyObject* b )
|
||||
{ return PyTypeManager::get( Py_TYPE(a) )->_getSqConcat( a, b ); }
|
||||
|
||||
|
||||
PyObject* _sqRepeat ( PyVoidPointer* a, Py_ssize_t count )
|
||||
PyObject* _sqRepeat ( PyObject* a, Py_ssize_t count )
|
||||
{ return PyTypeManager::get( Py_TYPE(a) )->_getSqRepeat( a, count ); }
|
||||
|
||||
|
||||
PyObject* _sqItem ( PyVoidPointer* self, Py_ssize_t count )
|
||||
PyObject* _sqItem ( PyObject* self, Py_ssize_t count )
|
||||
{ return PyTypeManager::get( Py_TYPE(self) )->_getSqItem( self, count ); }
|
||||
|
||||
|
||||
|
@ -87,8 +87,8 @@ namespace Isobar3 {
|
|||
// PyTypeObject & PyObject wrapper / manager.
|
||||
|
||||
|
||||
std::map< std::type_index, PyTypeManager* > PyTypeManager::_managerByCppTypes;
|
||||
std::map< PyTypeObject* , PyTypeManager* > PyTypeManager::_managerByPyTypes;
|
||||
std::map< size_t , PyTypeManager* > PyTypeManager::_managerByCppTypes;
|
||||
std::map< PyTypeObject*, PyTypeManager* > PyTypeManager::_managerByPyTypes;
|
||||
|
||||
|
||||
PyTypeManager::~PyTypeManager ()
|
||||
|
@ -111,28 +111,28 @@ namespace Isobar3 {
|
|||
}
|
||||
|
||||
|
||||
Py_ssize_t PyTypeManager::_getSqLength ( PyVoidPointer* )
|
||||
Py_ssize_t PyTypeManager::_getSqLength ( PyObject* )
|
||||
{
|
||||
throw Error( "PyTypeManager::_getSqLength(): Not implemented on <%s>.", _getCppTypeName().c_str() );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
PyObject* PyTypeManager::_getSqConcat ( PyVoidPointer*, PyVoidPointer* )
|
||||
PyObject* PyTypeManager::_getSqConcat ( PyObject*, PyObject* )
|
||||
{
|
||||
throw Error( "PyTypeManager::_getSqConcat(): Not implemented on <%s>.", _getCppTypeName().c_str() );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
PyObject* PyTypeManager::_getSqRepeat ( PyVoidPointer*, Py_ssize_t )
|
||||
PyObject* PyTypeManager::_getSqRepeat ( PyObject*, Py_ssize_t )
|
||||
{
|
||||
throw Error( "PyTypeManager::_getSqRepeat(): Not implemented on <%s>.", _getCppTypeName().c_str() );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
PyObject* PyTypeManager::_getSqItem ( PyVoidPointer*, Py_ssize_t )
|
||||
PyObject* PyTypeManager::_getSqItem ( PyObject*, Py_ssize_t )
|
||||
{
|
||||
throw Error( "PyTypeManager::_getSqItem(): Not implemented on <%s>.", _getCppTypeName().c_str() );
|
||||
return NULL;
|
||||
|
@ -174,6 +174,10 @@ namespace Isobar3 {
|
|||
}
|
||||
|
||||
|
||||
PyTypeManager* PyTypeManager::_getBaseManager ()
|
||||
{ return NULL; }
|
||||
|
||||
|
||||
void PyTypeManager::_setupPyType ()
|
||||
{
|
||||
PyTypeObject* ob_type = _getTypeObject();
|
||||
|
@ -183,6 +187,8 @@ namespace Isobar3 {
|
|||
ob_type->tp_hash = (hashfunc) &::Isobar3::_tpHash;
|
||||
ob_type->tp_methods = _getMethods();
|
||||
ob_type->tp_getset = _getGetsets();
|
||||
if (_getBaseManager())
|
||||
ob_type->tp_base = _getBaseManager()->_getTypeObject();
|
||||
// cerr << "_setupPyType() on \"" << _getPyTypeName()
|
||||
// << "\" ob_type=" << (void*)ob_type << endl;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) Sorbonne Université 2020-2021, 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 : "./PyViaLayer.cpp" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#include "hurricane/configuration/PyName.h"
|
||||
#include "hurricane/configuration/PyTechnology.h"
|
||||
#include "hurricane/configuration/PyBasicLayer.h"
|
||||
#include "hurricane/configuration/PyViaLayer.h"
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
||||
using namespace Hurricane;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
// Python methods.
|
||||
|
||||
static PyObject* PyViaLayer_create ( PyObject* self, PyObject* args )
|
||||
{ return callFunction("ViaLayer.create",&ViaLayer::create,args); }
|
||||
|
||||
static PyObject* PyViaLayer_destroy ( PyObject* self, PyObject* args )
|
||||
{ return callMethod("ViaLayer.destroy",&ViaLayer::destroy,self,args); }
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// PyViaLayer Attribute Method table.
|
||||
|
||||
PyMethodDef PyViaLayer_Methods[] =
|
||||
{ { "create" , (PyCFunction)PyViaLayer_create , METH_VARARGS|METH_STATIC
|
||||
, "Create a new ViaLayer." }
|
||||
, { "destroy" , (PyCFunction)PyViaLayer_destroy , METH_NOARGS
|
||||
, "destroy associated hurricane object, the python object remains." }
|
||||
, {NULL, NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar3 namespace.
|
|
@ -10,12 +10,13 @@
|
|||
// | Author : Jean-Paul CHAPUT |
|
||||
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./hurricane/configuration/PyLayer.h" |
|
||||
// | C++ Header : "./hurricane/configuration/PyBasicLayer.h" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#pragma once
|
||||
#include "hurricane/configuration/PyTypeManager.h"
|
||||
#include "hurricane/configuration/PyMaterial.h"
|
||||
#include "hurricane/BasicLayer.h"
|
||||
|
||||
|
||||
|
@ -30,4 +31,18 @@ extern "C" {
|
|||
|
||||
} // extern "C".
|
||||
|
||||
|
||||
template<>
|
||||
inline void pyTypePostModuleInit<Hurricane::BasicLayer> ( PyTypeObject* typeObject )
|
||||
{
|
||||
PyTypeManagerNonDBo<Hurricane::BasicLayer::Material>::create( (PyObject*)typeObject
|
||||
, PyMaterial_Methods
|
||||
, NULL
|
||||
, PyTypeManager::NoCppDelete
|
||||
, "Material"
|
||||
, PyMaterial_NEW
|
||||
, PyMaterial_Init
|
||||
);
|
||||
}
|
||||
|
||||
} // Isobar3 namespace.
|
||||
|
|
|
@ -36,8 +36,8 @@ namespace Isobar3 {
|
|||
static PyTypeManagerLocator* create ( PyObject* module, uint64_t flags );
|
||||
virtual PyObject* _getTpIter ( PyObject* );
|
||||
virtual PyObject* _getTpIterNext ( PyObject* );
|
||||
virtual void _getTpDeAlloc ( PyVoidPointer* );
|
||||
virtual long _getTpHash ( PyVoidPointer* );
|
||||
virtual void _getTpDeAlloc ( PyObject* );
|
||||
virtual long _getTpHash ( PyObject* );
|
||||
private:
|
||||
PyMethodDef* _noMethods;
|
||||
};
|
||||
|
@ -48,6 +48,7 @@ namespace Isobar3 {
|
|||
: PyTypeManagerVTrunk< typename Hurricane::Locator<CppT*> >(NULL,NULL,flags|PyTypeManager::IsIterator)
|
||||
, _noMethods( NULL )
|
||||
{
|
||||
_getTypeObject()->tp_basicsize = sizeof(PyTwoVoid);
|
||||
_noMethods = new PyMethodDef;
|
||||
_noMethods[0].ml_name = NULL;
|
||||
_noMethods[0].ml_meth = NULL;
|
||||
|
@ -62,11 +63,11 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename CppT >
|
||||
void PyTypeManagerLocator<CppT>::_getTpDeAlloc ( PyVoidPointer* self )
|
||||
void PyTypeManagerLocator<CppT>::_getTpDeAlloc ( PyObject* self )
|
||||
{
|
||||
Py_XDECREF( ((PyIteratorPointer*)self)->_container );
|
||||
Py_XDECREF( object2(self) );
|
||||
typename Hurricane::Locator<CppT*>* plocator = NULL;
|
||||
pyToC( self, &plocator );
|
||||
pyToC( (PyObject*)self, &plocator );
|
||||
delete plocator;
|
||||
PyObject_DEL( self );
|
||||
}
|
||||
|
@ -85,8 +86,9 @@ namespace Isobar3 {
|
|||
typename Hurricane::Locator <CppT*>* plocator = NULL;
|
||||
typename Hurricane::Collection<CppT*>* pcollection = NULL;
|
||||
pyToC( self, &plocator );
|
||||
pyToC( asIPtr(self)->_container, &pcollection );
|
||||
pyToC( (PyObject*)asIPtr(self)->_object2, &pcollection );
|
||||
|
||||
//std::cerr << "Collection::Iterator::_getTpIterNext() on " << (void*)pcollection << std::endl;
|
||||
if (plocator and plocator->isValid()) {
|
||||
PyObject* item = cToPy( plocator->getElement() );
|
||||
plocator->progress();
|
||||
|
@ -97,8 +99,8 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename CppT >
|
||||
long PyTypeManagerLocator<CppT>::_getTpHash ( PyVoidPointer *self )
|
||||
{ return (long)(self->_object); }
|
||||
long PyTypeManagerLocator<CppT>::_getTpHash ( PyObject* self )
|
||||
{ return (long)object1(self); }
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
|
@ -138,8 +140,8 @@ namespace Isobar3 {
|
|||
virtual ~PyTypeManagerCollection ();
|
||||
public:
|
||||
static PyTypeManagerCollection* create ( PyObject* module, uint64_t flags );
|
||||
virtual void _getTpDeAlloc ( PyVoidPointer* );
|
||||
virtual long _getTpHash ( PyVoidPointer* );
|
||||
virtual void _getTpDeAlloc ( PyObject* );
|
||||
virtual long _getTpHash ( PyObject* );
|
||||
virtual PyObject* _getTpIter ( PyObject* );
|
||||
private:
|
||||
PyMethodDef* _noMethods;
|
||||
|
@ -165,18 +167,19 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename CppT >
|
||||
void PyTypeManagerCollection<CppT>::_getTpDeAlloc ( PyVoidPointer* self )
|
||||
void PyTypeManagerCollection<CppT>::_getTpDeAlloc ( PyObject* self )
|
||||
{
|
||||
Hurricane::Collection<CppT*>* pcollection = NULL;
|
||||
pyToC( self->_object, &pcollection );
|
||||
pyToC( self, &pcollection );
|
||||
//std::cerr << "PyCollection::_getTpDeAlloc() on " << (void*)pcollection << std::endl;
|
||||
delete pcollection;
|
||||
PyObject_DEL( self );
|
||||
}
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
long PyTypeManagerCollection<CppT>::_getTpHash ( PyVoidPointer *self )
|
||||
{ return (long)(self->_object); }
|
||||
long PyTypeManagerCollection<CppT>::_getTpHash ( PyObject *self )
|
||||
{ return (long)object1(self); }
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
|
@ -184,9 +187,10 @@ namespace Isobar3 {
|
|||
{
|
||||
Hurricane::Collection<CppT*>* pcollection = NULL;
|
||||
pyToC( self, &pcollection );
|
||||
PyIteratorPointer* pyLocator = (PyIteratorPointer*)cToPy( pcollection->getLocator() );
|
||||
pyLocator->_container = (PyVoidPointer*)self;
|
||||
PyTwoVoid* pyLocator = (PyTwoVoid*)cToPy( pcollection->getLocator() );
|
||||
pyLocator->_object2 = self;
|
||||
Py_INCREF( self );
|
||||
//std::cerr << "Collection::_getTpIter() on " << (void*)pcollection << std::endl;
|
||||
return (PyObject*)pyLocator;
|
||||
}
|
||||
|
||||
|
@ -207,7 +211,10 @@ namespace Isobar3 {
|
|||
PyTypeObject* ob_type = manager->_getTypeObject();
|
||||
ob_type->tp_iter = (getiterfunc)&::Isobar3::_tpIter;
|
||||
|
||||
PyTypeManager::add< Hurricane::Collection<CppT*> >( module, manager );
|
||||
std::cerr << "Add to manager: <"
|
||||
<< ::Hurricane::demangle(typeid( Hurricane::Collection<CppT*> )) << ">" << std::endl;
|
||||
PyTypeManager::add< Hurricane::Collection<CppT*> >
|
||||
( module, manager, typeid(Hurricane::Collection<CppT*>).hash_code() );
|
||||
PyTypeManagerLocator<CppT>::create( module, flags );
|
||||
|
||||
return manager;
|
||||
|
@ -216,14 +223,3 @@ namespace Isobar3 {
|
|||
|
||||
} // Isobar3 namespace.
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
inline PyObject* cToPy ( const typename Hurricane::Locator<CppT*>* plocator )
|
||||
{ return Isobar3::PyTypeManager::link< typename Hurricane::Locator<CppT*> >
|
||||
( std::addressof(const_cast< typename Hurricane::Locator<CppT*>* >(plocator)) ); }
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
inline PyObject* cToPy ( const Hurricane::Collection<CppT*>* pcollection )
|
||||
{ return Isobar3::PyTypeManager::link< Hurricane::Collection<CppT*> >( std::addressof(const_cast< Hurricane::Collection<CppT*>* >(pcollection)) ); }
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) Sorbonne Université 2020-2021, All Rights Reserved
|
||||
//
|
||||
// +-----------------------------------------------------------------+
|
||||
// | C O R I O L I S |
|
||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||
// | |
|
||||
// | Author : Jean-Paul CHAPUT |
|
||||
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./hurricane/configuration/PyDiffusionLayer.h" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#pragma once
|
||||
#include "hurricane/configuration/PyTypeManager.h"
|
||||
#include "hurricane/DiffusionLayer.h"
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
extern PyMethodDef PyDiffusionLayer_Methods[];
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar3 namespace.
|
|
@ -36,8 +36,8 @@ namespace Isobar3 {
|
|||
static PyTypeManagerMapIterator* create ( PyObject* module, uint64_t flags );
|
||||
virtual PyObject* _getTpIter ( PyObject* );
|
||||
virtual PyObject* _getTpIterNext ( PyObject* );
|
||||
virtual void _getTpDeAlloc ( PyVoidPointer* );
|
||||
virtual long _getTpHash ( PyVoidPointer* );
|
||||
virtual void _getTpDeAlloc ( PyObject* );
|
||||
virtual long _getTpHash ( PyObject* );
|
||||
private:
|
||||
PyMethodDef* _noMethods;
|
||||
};
|
||||
|
@ -48,6 +48,7 @@ namespace Isobar3 {
|
|||
: PyTypeManagerVTrunk< typename std::map<CppK,CppT>::iterator >(NULL,NULL,flags|PyTypeManager::IsIterator)
|
||||
, _noMethods( NULL )
|
||||
{
|
||||
_getTypeObject()->tp_basicsize = sizeof(PyTwoVoid);
|
||||
_noMethods = new PyMethodDef;
|
||||
_noMethods[0].ml_name = NULL;
|
||||
_noMethods[0].ml_meth = NULL;
|
||||
|
@ -62,11 +63,11 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename CppK, typename CppT >
|
||||
void PyTypeManagerMapIterator<CppK,CppT>::_getTpDeAlloc ( PyVoidPointer* self )
|
||||
void PyTypeManagerMapIterator<CppK,CppT>::_getTpDeAlloc ( PyObject* self )
|
||||
{
|
||||
Py_XDECREF( (PyObject*)(asIPtr(self)->_container) );
|
||||
Py_XDECREF( object2(self) );
|
||||
typename std::map<CppK,CppT>::iterator* piterator = NULL;
|
||||
pyToC( (PyObject*)self, &piterator );
|
||||
pyToC( self, &piterator );
|
||||
delete piterator;
|
||||
PyObject_DEL( self );
|
||||
}
|
||||
|
@ -87,7 +88,7 @@ namespace Isobar3 {
|
|||
typename std::map<CppK,CppT>::iterator* piterator = NULL;
|
||||
typename std::map<CppK,CppT>* pmap = NULL;
|
||||
pyToC( self, &piterator );
|
||||
pyToC( (PyObject*)(asIPtr(self)->_container), &pmap );
|
||||
pyToC( object2(self), &pmap );
|
||||
|
||||
if ((*piterator) != pmap->end()) {
|
||||
PyObject* pyKey = cToPy( &((**piterator).first ) );
|
||||
|
@ -102,8 +103,8 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename CppK, typename CppT >
|
||||
long PyTypeManagerMapIterator<CppK,CppT>::_getTpHash ( PyVoidPointer *self )
|
||||
{ return (long)(self->_object); }
|
||||
long PyTypeManagerMapIterator<CppK,CppT>::_getTpHash ( PyObject *self )
|
||||
{ return (long)(object1(self)); }
|
||||
|
||||
|
||||
template< typename CppK, typename CppT >
|
||||
|
@ -149,8 +150,8 @@ namespace Isobar3 {
|
|||
virtual int _getSqContains ( PyObject*, PyObject* );
|
||||
virtual Py_ssize_t _getMpLength ( PyObject* );
|
||||
virtual PyObject* _getMpSubscript ( PyObject*, PyObject* );
|
||||
virtual void _getTpDeAlloc ( PyVoidPointer* );
|
||||
virtual long _getTpHash ( PyVoidPointer* );
|
||||
virtual void _getTpDeAlloc ( PyObject* );
|
||||
virtual long _getTpHash ( PyObject* );
|
||||
virtual PyObject* _getTpIter ( PyObject* );
|
||||
private:
|
||||
PyMethodDef* _noMethods;
|
||||
|
@ -184,7 +185,7 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename CppK, typename CppT >
|
||||
void PyTypeManagerMap<CppK,CppT>::_getTpDeAlloc ( PyVoidPointer* self )
|
||||
void PyTypeManagerMap<CppK,CppT>::_getTpDeAlloc ( PyObject* self )
|
||||
{
|
||||
PyObject_DEL( self );
|
||||
}
|
||||
|
@ -209,7 +210,7 @@ namespace Isobar3 {
|
|||
template< typename CppK, typename CppT >
|
||||
Py_ssize_t PyTypeManagerMap<CppK,CppT>::_getMpLength ( PyObject* self )
|
||||
{
|
||||
std::map<CppK,CppT>* pmap = reinterpret_cast< std::map<CppK,CppT>* >( asVPtr(self)->_object );
|
||||
std::map<CppK,CppT>* pmap = reinterpret_cast< std::map<CppK,CppT>* >( object1(self) );
|
||||
return pmap->size();
|
||||
}
|
||||
|
||||
|
@ -241,8 +242,8 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename CppK, typename CppT >
|
||||
long PyTypeManagerMap<CppK,CppT>::_getTpHash ( PyVoidPointer *self )
|
||||
{ return (long)(self->_object); }
|
||||
long PyTypeManagerMap<CppK,CppT>::_getTpHash ( PyObject* self )
|
||||
{ return (long)(object1(self)); }
|
||||
|
||||
|
||||
template< typename CppK, typename CppT >
|
||||
|
@ -250,9 +251,9 @@ namespace Isobar3 {
|
|||
{
|
||||
std::map<CppK,CppT>* pmap = NULL;
|
||||
pyToC( self, &pmap );
|
||||
PyIteratorPointer* pyIterator = (PyIteratorPointer*)cToPy
|
||||
PyTwoVoid* pyIterator = (PyTwoVoid*)cToPy
|
||||
( new typename std::map<CppK,CppT>::iterator(pmap->begin()) );
|
||||
pyIterator->_container = (PyVoidPointer*)self;
|
||||
object2(pyIterator) = self;
|
||||
Py_INCREF( self );
|
||||
return (PyObject*)pyIterator;
|
||||
}
|
||||
|
@ -288,17 +289,3 @@ namespace Isobar3 {
|
|||
|
||||
} // Isobar3 namespace.
|
||||
|
||||
|
||||
template< typename CppK, typename CppT >
|
||||
inline PyObject* cToPy ( const typename std::map<CppK,CppT>::iterator* pit )
|
||||
{ return Isobar3::PyTypeManager::link< typename std::map<CppK,CppT>::iterator >
|
||||
( std::addressof(const_cast< typename std::map<CppK,CppT>::iterator* >(pit)) ); }
|
||||
|
||||
|
||||
template< typename CppK, typename CppT >
|
||||
inline PyObject* cToPy ( const std::map<CppK,CppT>& vobject )
|
||||
{
|
||||
return Isobar3::PyTypeManager::link< std::map<CppK,CppT> >
|
||||
( std::addressof(const_cast< std::map<CppK,CppT>& >(vobject)) );
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) Sorbonne Université 2020-2021, All Rights Reserved
|
||||
//
|
||||
// +-----------------------------------------------------------------+
|
||||
// | C O R I O L I S |
|
||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||
// | |
|
||||
// | Author : Jean-Paul CHAPUT |
|
||||
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./hurricane/configuration/PyMaterial.h" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#pragma once
|
||||
#include "hurricane/configuration/PyTypeManager.h"
|
||||
#include "hurricane/BasicLayer.h"
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
extern PyMethodDef PyMaterial_Methods[];
|
||||
extern PyObject* PyMaterial_NEW ( PyTypeObject* pyType, PyObject* args, PyObject* kwargs );
|
||||
extern int PyMaterial_Init ( PyObject* self, PyObject* args, PyObject* kwargs );
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar3 namespace.
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
||||
|
||||
template<>
|
||||
inline void pyTypePostModuleInit<Hurricane::BasicLayer::Material> ( PyTypeObject* typeObject )
|
||||
{
|
||||
addConstant( typeObject, "nWell" , BasicLayer::Material::nWell );
|
||||
addConstant( typeObject, "pWell" , BasicLayer::Material::pWell );
|
||||
addConstant( typeObject, "nImplant", BasicLayer::Material::nImplant );
|
||||
addConstant( typeObject, "pImplant", BasicLayer::Material::pImplant );
|
||||
addConstant( typeObject, "active" , BasicLayer::Material::active );
|
||||
addConstant( typeObject, "poly" , BasicLayer::Material::poly );
|
||||
addConstant( typeObject, "cut" , BasicLayer::Material::cut );
|
||||
addConstant( typeObject, "metal" , BasicLayer::Material::metal );
|
||||
addConstant( typeObject, "blockage", BasicLayer::Material::blockage );
|
||||
addConstant( typeObject, "info" , BasicLayer::Material::info );
|
||||
addConstant( typeObject, "other" , BasicLayer::Material::other );
|
||||
}
|
||||
|
||||
|
||||
} // Isobar3 namespace.
|
|
@ -19,18 +19,20 @@
|
|||
#include "hurricane/Name.h"
|
||||
|
||||
|
||||
template<>
|
||||
inline PyObject* cToPy<Hurricane::Name>( Hurricane::Name name )
|
||||
inline PyObject* cToPy ( Hurricane::Name name )
|
||||
{ return PyUnicode_FromString( getString(name).c_str() ); }
|
||||
|
||||
|
||||
template<>
|
||||
inline bool pyToC<const Hurricane::Name> ( PyObject* pyArg, const Hurricane::Name* arg )
|
||||
inline bool pyToC ( PyObject* pyArg, const Hurricane::Name* arg )
|
||||
{
|
||||
std::cerr << "pyToC<Hurricane::Name>() called." << std::endl;
|
||||
//std::cerr << "pyToC<Hurricane::Name>() called." << std::endl;
|
||||
if (not PyUnicode_Check(pyArg)) return false;
|
||||
PyObject* pyBytes = PyUnicode_AsASCIIString( pyArg );
|
||||
*(const_cast<Hurricane::Name*>(arg)) = Hurricane::Name( PyBytes_AsString( pyBytes ));
|
||||
Py_DECREF( pyBytes );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline bool pyToC ( PyObject* pyArg, Hurricane::Name* arg )
|
||||
{ return pyToC( pyArg, const_cast<const Hurricane::Name*>(arg) ); }
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) Sorbonne Université 2020-2021, All Rights Reserved
|
||||
//
|
||||
// +-----------------------------------------------------------------+
|
||||
// | C O R I O L I S |
|
||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||
// | |
|
||||
// | Author : Jean-Paul CHAPUT |
|
||||
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./hurricane/configuration/PyRegularLayer.h" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#pragma once
|
||||
#include "hurricane/configuration/PyTypeManager.h"
|
||||
#include "hurricane/RegularLayer.h"
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
extern PyMethodDef PyRegularLayer_Methods[];
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar3 namespace.
|
|
@ -0,0 +1,32 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) Sorbonne Université 2020-2021, All Rights Reserved
|
||||
//
|
||||
// +-----------------------------------------------------------------+
|
||||
// | C O R I O L I S |
|
||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||
// | |
|
||||
// | Author : Jean-Paul CHAPUT |
|
||||
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./hurricane/configuration/PyTransistorLayer.h" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#pragma once
|
||||
#include "hurricane/configuration/PyTypeManager.h"
|
||||
#include "hurricane/TransistorLayer.h"
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
extern PyMethodDef PyTransistorLayer_Methods[];
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar3 namespace.
|
|
@ -56,24 +56,24 @@ extern "C" {
|
|||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
void* _object;
|
||||
} PyVoidPointer;
|
||||
void* _object1;
|
||||
} PyOneVoid;
|
||||
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
void* _object; // pointer to iterator.
|
||||
PyVoidPointer* _container;
|
||||
} PyIteratorPointer;
|
||||
void* _object1; // pointer to iterator.
|
||||
PyObject* _object2; // pointer to container.
|
||||
} PyTwoVoid;
|
||||
|
||||
|
||||
extern void _tpDeAlloc ( PyObject* );
|
||||
extern PyObject* _tpStr ( PyObject* );
|
||||
extern long _tpHash ( PyObject* );
|
||||
extern Py_ssize_t _sqLength ( PyVoidPointer* );
|
||||
extern PyObject* _sqConcat ( PyVoidPointer* , PyVoidPointer* );
|
||||
extern PyObject* _sqRepeat ( PyVoidPointer* , Py_ssize_t );
|
||||
extern PyObject* _sqItem ( PyVoidPointer* , Py_ssize_t );
|
||||
extern Py_ssize_t _sqLength ( PyObject* );
|
||||
extern PyObject* _sqConcat ( PyObject* , PyObject* );
|
||||
extern PyObject* _sqRepeat ( PyObject* , Py_ssize_t );
|
||||
extern PyObject* _sqItem ( PyObject* , Py_ssize_t );
|
||||
extern int _sqContains ( PyObject*, PyObject* );
|
||||
extern Py_ssize_t _mpLength ( PyObject* );
|
||||
extern PyObject* _mpSubscript ( PyObject*, PyObject* );
|
||||
|
@ -85,9 +85,13 @@ extern "C" {
|
|||
} // "C" linkage.
|
||||
|
||||
|
||||
inline PyVoidPointer* asVPtr ( PyObject* o ) { return reinterpret_cast<PyVoidPointer *>(o); }
|
||||
inline PyIteratorPointer* asIPtr ( PyObject* o ) { return reinterpret_cast<PyIteratorPointer*>(o); }
|
||||
inline PyIteratorPointer* asIPtr ( PyVoidPointer* o ) { return reinterpret_cast<PyIteratorPointer*>(o); }
|
||||
inline PyOneVoid* asVPtr ( PyObject* o ) { return reinterpret_cast<PyOneVoid*>(o); }
|
||||
inline PyTwoVoid* asIPtr ( PyObject* o ) { return reinterpret_cast<PyTwoVoid*>(o); }
|
||||
inline void*& object1 ( PyObject* o ) { return asVPtr(o)->_object1; }
|
||||
inline void*& object1 ( PyOneVoid* o ) { return o->_object1; }
|
||||
inline void*& object1 ( PyTwoVoid* o ) { return o->_object1; }
|
||||
inline PyObject*& object2 ( PyObject* o ) { return asIPtr(o)->_object2; }
|
||||
inline PyObject*& object2 ( PyTwoVoid* o ) { return o->_object2; }
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
@ -123,8 +127,8 @@ extern "C" {
|
|||
PyErr_SetString( PyExc_TypeError, message.c_str() );
|
||||
return NULL;
|
||||
}
|
||||
CppT* cself = reinterpret_cast<CppT*>( asVPtr(self )->_object );
|
||||
CppT* cother = reinterpret_cast<CppT*>( asVPtr(other)->_object );
|
||||
CppT* cself = reinterpret_cast<CppT*>( object1(self ) );
|
||||
CppT* cother = reinterpret_cast<CppT*>( object1(other) );
|
||||
|
||||
bool result = false;
|
||||
if ((op == Py_LT) and (cself < cother)) result = true;
|
||||
|
@ -148,8 +152,8 @@ extern "C" {
|
|||
PyErr_SetString( PyExc_TypeError, message.c_str() );
|
||||
return NULL;
|
||||
}
|
||||
CppT* cself = reinterpret_cast<CppT*>( asVPtr(self )->_object );
|
||||
CppT* cother = reinterpret_cast<CppT*>( asVPtr(other)->_object );
|
||||
CppT* cself = reinterpret_cast<CppT*>( object1(self ) );
|
||||
CppT* cother = reinterpret_cast<CppT*>( object1(other) );
|
||||
|
||||
bool result = false;
|
||||
if ((op == Py_LT) and ( cself < cother )) result = true;
|
||||
|
@ -173,8 +177,8 @@ extern "C" {
|
|||
PyErr_SetString( PyExc_TypeError, message.c_str() );
|
||||
return NULL;
|
||||
}
|
||||
CppT* cself = reinterpret_cast<CppT*>( asVPtr(self )->_object );
|
||||
CppT* cother = reinterpret_cast<CppT*>( asVPtr(other)->_object );
|
||||
CppT* cself = reinterpret_cast<CppT*>( object1(self ) );
|
||||
CppT* cother = reinterpret_cast<CppT*>( object1(other) );
|
||||
|
||||
bool result = false;
|
||||
if ((op == Py_LT) and (cself->getId() < cother->getId())) result = true;
|
||||
|
@ -195,8 +199,8 @@ extern "C" {
|
|||
|
||||
class PyTypeManager {
|
||||
public:
|
||||
typedef std::map<std::type_index,PyTypeManager*> ManagerByCppTypes;
|
||||
typedef std::map<PyTypeObject* ,PyTypeManager*> ManagerByPyTypes;
|
||||
typedef std::map<size_t ,PyTypeManager*> ManagerByCppTypes;
|
||||
typedef std::map<PyTypeObject*,PyTypeManager*> ManagerByPyTypes;
|
||||
public:
|
||||
static const uint64_t NoFlags = 0;
|
||||
static const uint64_t IsDBo = (1 << 0);
|
||||
|
@ -210,25 +214,28 @@ extern "C" {
|
|||
inline bool _isIterator () const;
|
||||
inline std::string _getCppTypeName () const;
|
||||
inline std::string _getPyTypeName () const;
|
||||
inline std::string _getTypeInfo () const;
|
||||
inline PyTypeObject* _getTypeObject ();
|
||||
inline PyMethodDef* _getMethods ();
|
||||
inline PyGetSetDef* _getGetsets ();
|
||||
void _setTypeNames ( std::string className );
|
||||
void _addToModule ( PyObject* );
|
||||
virtual void _getTpDeAlloc ( PyVoidPointer* ) = 0;
|
||||
virtual PyObject* _getTpStr ( PyVoidPointer* ) = 0;
|
||||
virtual long _getTpHash ( PyVoidPointer* ) = 0;
|
||||
virtual Py_ssize_t _getSqLength ( PyVoidPointer* );
|
||||
virtual PyObject* _getSqConcat ( PyVoidPointer*, PyVoidPointer* );
|
||||
virtual PyObject* _getSqRepeat ( PyVoidPointer*, Py_ssize_t );
|
||||
virtual PyObject* _getSqItem ( PyVoidPointer*, Py_ssize_t );
|
||||
virtual void _getTpDeAlloc ( PyObject* ) = 0;
|
||||
virtual PyObject* _getTpStr ( PyObject* ) = 0;
|
||||
virtual long _getTpHash ( PyObject* ) = 0;
|
||||
virtual Py_ssize_t _getSqLength ( PyObject* );
|
||||
virtual PyObject* _getSqConcat ( PyObject*, PyObject* );
|
||||
virtual PyObject* _getSqRepeat ( PyObject*, Py_ssize_t );
|
||||
virtual PyObject* _getSqItem ( PyObject*, Py_ssize_t );
|
||||
virtual int _getSqContains ( PyObject*, PyObject* );
|
||||
virtual Py_ssize_t _getMpLength ( PyObject* );
|
||||
virtual PyObject* _getMpSubscript ( PyObject*, PyObject* );
|
||||
virtual PyObject* _getTpIter ( PyObject* );
|
||||
virtual PyObject* _getTpIterNext ( PyObject* );
|
||||
virtual PyTypeManager* _getBaseManager ();
|
||||
virtual void _setupPyType ();
|
||||
inline void _setMethods ( PyMethodDef* );
|
||||
inline void _setTypeInfo ( std::string );
|
||||
public:
|
||||
static inline ManagerByCppTypes& getManagerByCppTypes ();
|
||||
inline uint64_t flags () const;
|
||||
|
@ -236,11 +243,12 @@ extern "C" {
|
|||
template<typename CppT> static inline bool hasType ();
|
||||
template<typename CppT> static inline PyTypeManager* _get ();
|
||||
template<typename CppT> static inline PyObject* link ( CppT* );
|
||||
template<typename CppT> static void add ( PyObject*, PyTypeManager* );
|
||||
template<typename CppT> static void add ( PyObject*, PyTypeManager*, size_t hashCode=0 );
|
||||
private:
|
||||
uint64_t _flags;
|
||||
std::string _pyTypeName;
|
||||
std::string _cppTypeName;
|
||||
std::string _typeInfo;
|
||||
PyTypeObject _typeObject;
|
||||
PyMethodDef* _methods;
|
||||
PyGetSetDef* _getsets;
|
||||
|
@ -262,17 +270,24 @@ extern "C" {
|
|||
|
||||
template<typename CppT> inline bool PyTypeManager::hasType ()
|
||||
{
|
||||
auto element = _managerByCppTypes.find( std::type_index(typeid(CppT)) );
|
||||
auto element = _managerByCppTypes.find( typeid(CppT).hash_code() );
|
||||
return (element != _managerByCppTypes.end());
|
||||
}
|
||||
|
||||
|
||||
template<typename CppT> inline PyTypeManager* PyTypeManager::_get ()
|
||||
{
|
||||
auto element = _managerByCppTypes.find( std::type_index(typeid(CppT)) );
|
||||
if (element == _managerByCppTypes.end())
|
||||
auto element = _managerByCppTypes.find( typeid(CppT).hash_code() );
|
||||
if (element == _managerByCppTypes.end()) {
|
||||
std::cerr << "PyTypeManager<CppT>::_get(): Unregistered type <"
|
||||
<< demangle(typeid(CppT).name()) << ">." << std::endl;
|
||||
for ( auto item : _managerByCppTypes ) {
|
||||
std::cerr << "| " << std::setw(30) << std::right << item.first
|
||||
<< ":" << item.second->_getTypeInfo() << std::endl;
|
||||
}
|
||||
throw Error( "PyTypeManager<CppT>::_get(): Unregistered type <%s>."
|
||||
, demangle(typeid(CppT).name()).c_str() );
|
||||
}
|
||||
return (*element).second;
|
||||
}
|
||||
|
||||
|
@ -281,9 +296,10 @@ extern "C" {
|
|||
: _flags (flags)
|
||||
, _pyTypeName ()
|
||||
, _cppTypeName ()
|
||||
, _typeInfo ()
|
||||
, _typeObject { PyVarObject_HEAD_INIT(&PyType_Type,0)
|
||||
.tp_name = NULL
|
||||
, .tp_basicsize = sizeof(PyVoidPointer)
|
||||
, .tp_basicsize = sizeof(PyOneVoid)
|
||||
, .tp_itemsize = 0
|
||||
, .tp_dealloc = NULL
|
||||
, .tp_print = NULL
|
||||
|
@ -306,7 +322,7 @@ extern "C" {
|
|||
, _methods (methods)
|
||||
, _getsets (getsets)
|
||||
{
|
||||
if (_isIterator()) _typeObject.tp_basicsize = sizeof(PyIteratorPointer);
|
||||
if (_isIterator()) _typeObject.tp_basicsize = sizeof(PyTwoVoid);
|
||||
}
|
||||
|
||||
|
||||
|
@ -321,18 +337,21 @@ extern "C" {
|
|||
inline void PyTypeManager::_setMethods ( PyMethodDef* methods ) { _methods=methods; }
|
||||
inline PyTypeManager::ManagerByCppTypes&
|
||||
PyTypeManager::getManagerByCppTypes () { return _managerByCppTypes; }
|
||||
inline std::string PyTypeManager::_getTypeInfo () const { return _typeInfo; }
|
||||
inline void PyTypeManager::_setTypeInfo ( std::string ti ) { _typeInfo=ti; }
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
void PyTypeManager::add ( PyObject* module, PyTypeManager* manager )
|
||||
void PyTypeManager::add ( PyObject* module, PyTypeManager* manager, size_t hashCode )
|
||||
{
|
||||
if (ProxyProperty::getOffset() == (size_t)-1)
|
||||
ProxyProperty::setOffset( offsetof( PyVoidPointer, _object ));
|
||||
ProxyProperty::setOffset( offsetof( PyOneVoid, _object1 ));
|
||||
|
||||
// std::cerr << "PyTypeManager::add<" << demangle(typeid(CppT).name())
|
||||
// << "> hash=" << std::type_index(typeid(CppT)).hash_code()
|
||||
// << " manager=" << manager << std::endl;
|
||||
_managerByCppTypes[ std::type_index(typeid(CppT)) ] = manager;
|
||||
if (not hashCode) hashCode = typeid(CppT).hash_code();
|
||||
_managerByCppTypes[ hashCode ] = manager;
|
||||
_managerByPyTypes [ manager->_getTypeObject() ] = manager;
|
||||
manager->_addToModule( module );
|
||||
pyTypePostModuleInit<CppT>( manager->_getTypeObject() );
|
||||
|
@ -350,7 +369,9 @@ extern "C" {
|
|||
inline PyTypeManagerVTrunk ( PyMethodDef*, PyGetSetDef*, uint64_t flags );
|
||||
virtual ~PyTypeManagerVTrunk ();
|
||||
public:
|
||||
virtual PyObject* _getTpStr ( PyVoidPointer* );
|
||||
template<typename BaseT>
|
||||
inline bool _canDynamicCast ( BaseT* ) const;
|
||||
virtual PyObject* _getTpStr ( PyObject* );
|
||||
virtual PyObject* _link ( CppT* );
|
||||
};
|
||||
|
||||
|
@ -358,7 +379,9 @@ extern "C" {
|
|||
template< typename CppT >
|
||||
inline PyTypeManagerVTrunk<CppT>::PyTypeManagerVTrunk ( PyMethodDef* methods, PyGetSetDef* getsets, uint64_t flags )
|
||||
: PyTypeManager(methods,getsets,flags)
|
||||
{ }
|
||||
{
|
||||
_setTypeInfo( ::Hurricane::demangle( typeid(CppT).name() ));
|
||||
}
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
|
@ -366,9 +389,15 @@ extern "C" {
|
|||
|
||||
|
||||
template< typename CppT >
|
||||
PyObject* PyTypeManagerVTrunk<CppT>::_getTpStr ( PyVoidPointer *self )
|
||||
template< typename BaseT >
|
||||
bool PyTypeManagerVTrunk<CppT>::_canDynamicCast ( BaseT *cppObject ) const
|
||||
{ return (dynamic_cast<CppT*>(cppObject) != NULL); }
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
PyObject* PyTypeManagerVTrunk<CppT>::_getTpStr ( PyObject *self )
|
||||
{
|
||||
CppT* object = reinterpret_cast<CppT*>( self->_object );
|
||||
CppT* object = reinterpret_cast<CppT*>( object1(self) );
|
||||
if (not object) {
|
||||
std::ostringstream repr;
|
||||
repr << "<" << _getPyTypeName() << " [" << (void*)self << " <-> NULL] unbound>";
|
||||
|
@ -383,16 +412,16 @@ extern "C" {
|
|||
{
|
||||
if (not object) Py_RETURN_NONE;
|
||||
|
||||
PyVoidPointer* pyObject = NULL;
|
||||
PyOneVoid* pyObject = NULL;
|
||||
if (_isIterator())
|
||||
pyObject = (PyVoidPointer*)PyObject_NEW( PyIteratorPointer, _getTypeObject() );
|
||||
pyObject = (PyOneVoid*)PyObject_NEW( PyTwoVoid, _getTypeObject() );
|
||||
else
|
||||
pyObject = PyObject_NEW( PyVoidPointer, _getTypeObject() );
|
||||
pyObject = PyObject_NEW( PyOneVoid, _getTypeObject() );
|
||||
if (pyObject == NULL) return NULL;
|
||||
|
||||
pyObject->_object = (void*)object;
|
||||
object1(pyObject) = (void*)object;
|
||||
cdebug_log(20,0) << "PyTypeManager::_link(): " << _getPyTypeName() << " "
|
||||
<< (void*)pyObject << ") " << (void*)object << ":" << object << endl;
|
||||
<< (void*)pyObject << ") " << (void*)object << ":" << object << std::endl;
|
||||
|
||||
return (PyObject*)pyObject;
|
||||
}
|
||||
|
@ -436,8 +465,8 @@ extern "C" {
|
|||
, richcmpfunc tpRichCompare=tpRichCompareByPtr<CppT>
|
||||
, PyNumberMethods* tpAsNumber=NULL
|
||||
);
|
||||
virtual void _getTpDeAlloc ( PyVoidPointer* );
|
||||
virtual long _getTpHash ( PyVoidPointer* );
|
||||
virtual void _getTpDeAlloc ( PyObject* );
|
||||
virtual long _getTpHash ( PyObject* );
|
||||
};
|
||||
|
||||
|
||||
|
@ -452,17 +481,17 @@ extern "C" {
|
|||
|
||||
|
||||
template< typename CppT >
|
||||
void PyTypeManagerNonDBo<CppT>::_getTpDeAlloc ( PyVoidPointer* self )
|
||||
void PyTypeManagerNonDBo<CppT>::_getTpDeAlloc ( PyObject* self )
|
||||
{
|
||||
if (not (PyTypeManager::flags() & PyTypeManager::NoCppDelete))
|
||||
delete reinterpret_cast<CppT*>( self->_object );
|
||||
delete reinterpret_cast<CppT*>( object1(self) );
|
||||
PyObject_DEL( self );
|
||||
}
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
long PyTypeManagerNonDBo<CppT>::_getTpHash ( PyVoidPointer *self )
|
||||
{ return (long)(self->_object); }
|
||||
long PyTypeManagerNonDBo<CppT>::_getTpHash ( PyObject *self )
|
||||
{ return (long)(object1(self)); }
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
|
@ -508,8 +537,8 @@ extern "C" {
|
|||
, richcmpfunc tpRichCompare=tpRichCompareByDBo<CppT>
|
||||
);
|
||||
virtual PyObject* _link ( CppT* );
|
||||
virtual void _getTpDeAlloc ( PyVoidPointer* );
|
||||
virtual long _getTpHash ( PyVoidPointer* );
|
||||
virtual void _getTpDeAlloc ( PyObject* );
|
||||
virtual long _getTpHash ( PyObject* );
|
||||
};
|
||||
|
||||
|
||||
|
@ -528,19 +557,19 @@ extern "C" {
|
|||
{
|
||||
if (not object) Py_RETURN_NONE;
|
||||
|
||||
PyVoidPointer* pyObject = NULL;
|
||||
PyOneVoid* pyObject = NULL;
|
||||
ProxyProperty* proxy = static_cast<ProxyProperty*>
|
||||
( object->getProperty ( ProxyProperty::getPropertyName() ) );
|
||||
|
||||
if (not proxy) {
|
||||
pyObject = PyObject_NEW( PyVoidPointer, _getTypeObject() );
|
||||
pyObject = PyObject_NEW( PyOneVoid, _getTypeObject() );
|
||||
if (not pyObject) return NULL;
|
||||
|
||||
proxy = ProxyProperty::create( (void*)pyObject );
|
||||
pyObject->_object = (void*)object;
|
||||
object1(pyObject) = (void*)object;
|
||||
object->put( proxy );
|
||||
} else {
|
||||
pyObject = (PyVoidPointer*)proxy->getShadow ();
|
||||
pyObject = (PyOneVoid*)proxy->getShadow ();
|
||||
Py_INCREF( pyObject );
|
||||
}
|
||||
cdebug_log(20,0) << "PyTypeManagerDBo<" << demangle(typeid(CppT).name()) << ">() "
|
||||
|
@ -551,11 +580,11 @@ extern "C" {
|
|||
|
||||
|
||||
template< typename CppT >
|
||||
void PyTypeManagerDBo<CppT>::_getTpDeAlloc ( PyVoidPointer* self )
|
||||
void PyTypeManagerDBo<CppT>::_getTpDeAlloc ( PyObject* self )
|
||||
{
|
||||
DBo* object = reinterpret_cast<DBo*>( self->_object );
|
||||
DBo* object = reinterpret_cast<DBo*>( object1(self) );
|
||||
cdebug_log(20,0) << "PyTypeManager_DeAlloc(" << (void*)self << ") "
|
||||
<< (void*)(self->_object) << ":" << object << endl;
|
||||
<< object1(self) << ":" << object << endl;
|
||||
|
||||
Isobar3::ProxyProperty* proxy =
|
||||
static_cast<Isobar3::ProxyProperty*>( object->getProperty( Isobar3::ProxyProperty::getPropertyName() ) );
|
||||
|
@ -572,9 +601,9 @@ extern "C" {
|
|||
|
||||
|
||||
template< typename CppT >
|
||||
long PyTypeManagerDBo<CppT>::_getTpHash ( PyVoidPointer *self )
|
||||
long PyTypeManagerDBo<CppT>::_getTpHash ( PyObject *self )
|
||||
{
|
||||
DBo* object = reinterpret_cast<DBo*>( self->_object );
|
||||
DBo* object = reinterpret_cast<DBo*>( object1(self) );
|
||||
return object->getId();
|
||||
}
|
||||
|
||||
|
@ -600,6 +629,79 @@ extern "C" {
|
|||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// PyTypeObject & PyObject for DBo objects with inheritance.
|
||||
|
||||
|
||||
template<typename CppT, typename BaseT >
|
||||
class PyTypeManagerDerivedDBo : public PyTypeManagerDBo<CppT> {
|
||||
public:
|
||||
using PyTypeManager::_getTypeObject;
|
||||
inline PyTypeManagerDerivedDBo ( PyMethodDef*, PyGetSetDef*, uint64_t flags );
|
||||
virtual ~PyTypeManagerDerivedDBo ();
|
||||
public:
|
||||
static PyTypeManagerDerivedDBo* create ( PyObject* module
|
||||
, PyMethodDef* methods
|
||||
, PyGetSetDef* getsets
|
||||
, uint64_t flags
|
||||
, richcmpfunc tpRichCompare=tpRichCompareByDBo<CppT>
|
||||
);
|
||||
virtual PyTypeManager* _getBaseManager ();
|
||||
private:
|
||||
PyTypeManager* _baseManager;
|
||||
};
|
||||
|
||||
|
||||
template< typename CppT, typename BaseT >
|
||||
inline PyTypeManagerDerivedDBo<CppT,BaseT>::PyTypeManagerDerivedDBo ( PyMethodDef* methods, PyGetSetDef* getsets, uint64_t flags )
|
||||
: PyTypeManagerDBo<CppT>(methods,getsets,flags|PyTypeManager::IsDBo)
|
||||
, _baseManager(NULL)
|
||||
{ }
|
||||
|
||||
|
||||
template< typename CppT, typename BaseT >
|
||||
PyTypeManagerDerivedDBo<CppT,BaseT>::~PyTypeManagerDerivedDBo () { }
|
||||
|
||||
|
||||
template< typename CppT, typename BaseT >
|
||||
PyTypeManager* PyTypeManagerDerivedDBo<CppT,BaseT>::_getBaseManager ()
|
||||
{ return _baseManager; }
|
||||
|
||||
|
||||
template< typename CppT, typename BaseT >
|
||||
PyTypeManagerDerivedDBo<CppT,BaseT>* PyTypeManagerDerivedDBo<CppT,BaseT>::create ( PyObject* module
|
||||
, PyMethodDef* methods
|
||||
, PyGetSetDef* getsets
|
||||
, uint64_t flags
|
||||
, richcmpfunc tpRichCompare )
|
||||
{
|
||||
// if (not std::is_base_of<Hurricane::Entity,CppT>::value)
|
||||
// throw ::Hurricane::Error( "PyManagerDerivedDBo<CppT>::create(): The C++ class <%s> is *not* derived from DBo."
|
||||
// , ::Hurricane::demangle(typeid(CppT).name()).c_str() );
|
||||
if (not std::is_base_of<BaseT,CppT>::value)
|
||||
throw ::Hurricane::Error( "PyManagerDerivedDBo<CppT>::create(): The C++ class <%s> is *not* derived from <%s>."
|
||||
, ::Hurricane::demangle(typeid(CppT ).name()).c_str()
|
||||
, ::Hurricane::demangle(typeid(BaseT).name()).c_str()
|
||||
);
|
||||
PyTypeManager* baseManager = PyTypeManager::_get<BaseT>();
|
||||
if (not baseManager)
|
||||
throw ::Hurricane::Error( "PyManagerDerivedDBo<CppT>::create(): The Python base class <%s> for <%s> has not been registered first."
|
||||
, ::Hurricane::demangle(typeid(BaseT).name()).c_str()
|
||||
, ::Hurricane::demangle(typeid(CppT ).name()).c_str()
|
||||
);
|
||||
|
||||
PyTypeManagerDerivedDBo<CppT,BaseT>* manager = new PyTypeManagerDerivedDBo<CppT,BaseT>( methods, getsets, flags );
|
||||
manager->_baseManager = baseManager;
|
||||
manager->_setTypeNames( ::Hurricane::demangle(typeid(CppT)) );
|
||||
manager->_setupPyType();
|
||||
PyTypeObject* ob_type = manager->_getTypeObject();
|
||||
if (tpRichCompare) ob_type->tp_richcompare = tpRichCompare;
|
||||
ob_type->tp_base = baseManager->_getTypeObject();
|
||||
PyTypeManager::add<CppT>( module, manager );
|
||||
return manager;
|
||||
}
|
||||
|
||||
|
||||
} // Isobar3 namespace.
|
||||
|
||||
|
||||
|
@ -665,16 +767,45 @@ template<> inline PyObject* cToPy<const double*> ( const double* d ) { return Py
|
|||
|
||||
|
||||
// Forward declaration for PyVector.h
|
||||
template< typename CppT > inline PyObject* cToPy ( const typename std::vector<CppT>::iterator* );
|
||||
template< typename CppT > inline PyObject* cToPy ( const std::vector<CppT>& );
|
||||
template< typename CppT >
|
||||
inline PyObject* cToPy ( const typename std::vector<CppT>::iterator* pit )
|
||||
{ return Isobar3::PyTypeManager::link< typename std::vector<CppT>::iterator >
|
||||
( std::addressof(const_cast< typename std::vector<CppT>::iterator* >(pit)) ); }
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
inline PyObject* cToPy ( const std::vector<CppT>& vobject )
|
||||
{ return Isobar3::PyTypeManager::link< std::vector<CppT> >( std::addressof(const_cast< std::vector<CppT>& >(vobject)) ); }
|
||||
|
||||
|
||||
// Forward declaration for PyMap.h
|
||||
template< typename CppK, typename CppT > inline PyObject* cToPy ( const typename std::map<CppK,CppT>::iterator* );
|
||||
template< typename CppK, typename CppT > inline PyObject* cToPy ( const std::map<CppK,CppT>& vobject );
|
||||
template< typename CppK, typename CppT >
|
||||
inline PyObject* cToPy ( const typename std::map<CppK,CppT>::iterator* pit )
|
||||
{ return Isobar3::PyTypeManager::link< typename std::map<CppK,CppT>::iterator >
|
||||
( std::addressof(const_cast< typename std::map<CppK,CppT>::iterator* >(pit)) ); }
|
||||
|
||||
|
||||
template< typename CppK, typename CppT >
|
||||
inline PyObject* cToPy ( const std::map<CppK,CppT>& vobject )
|
||||
{
|
||||
return Isobar3::PyTypeManager::link< std::map<CppK,CppT> >
|
||||
( std::addressof(const_cast< std::map<CppK,CppT>& >(vobject)) );
|
||||
}
|
||||
|
||||
|
||||
// Forward declaration for PyCollection.h
|
||||
template< typename CppT > inline PyObject* cToPy ( const typename Hurricane::Locator<CppT>* );
|
||||
template< typename CppT > inline PyObject* cToPy ( const Hurricane::Collection<CppT>* );
|
||||
template< typename CppT >
|
||||
inline PyObject* cToPy ( const typename Hurricane::Locator<CppT*>* plocator )
|
||||
{ return Isobar3::PyTypeManager::link< typename Hurricane::Locator<CppT*> >
|
||||
( std::addressof(const_cast< typename Hurricane::Locator<CppT*>* >(plocator)) ); }
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
inline PyObject* cToPy ( Hurricane::GenericCollection<CppT*> collection )
|
||||
{
|
||||
Hurricane::Collection<CppT*>* clone = collection.getClone();
|
||||
return Isobar3::PyTypeManager::link< Hurricane::Collection<CppT*> >( clone );
|
||||
}
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
@ -1457,7 +1588,7 @@ inline bool pyToC ( PyObject* pyArg, T* arg )
|
|||
return false;
|
||||
}
|
||||
if (Py_TYPE(pyArg) != manager->_getTypeObject()) return false;
|
||||
*arg = (T)( Isobar3::asVPtr( pyArg )->_object );
|
||||
*arg = (T)( Isobar3::object1( pyArg ));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1478,7 +1609,7 @@ inline bool pyToC ( PyObject* pyArg, T* arg )
|
|||
return false;
|
||||
}
|
||||
if (Py_TYPE(pyArg) != manager->_getTypeObject()) return false;
|
||||
*(const_cast< NonConstT* >(arg)) = *(( T* )( Isobar3::asVPtr( pyArg )->_object ));
|
||||
*(const_cast< NonConstT* >(arg)) = *(( T* )( Isobar3::object1( pyArg )));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1492,7 +1623,7 @@ inline bool pyToC ( PyObject* pyArg, T** arg )
|
|||
return false;
|
||||
}
|
||||
// std::cerr << "pyToC< " << demangle(typeid(T).name()) << " >() called." << std::endl;
|
||||
*arg = (T*)( Isobar3::asVPtr( pyArg )->_object );
|
||||
*arg = (T*)( Isobar3::object1( pyArg ));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1597,7 +1728,7 @@ namespace Isobar3 {
|
|||
success = success and pyToC( pyArgs[count], &(as<T>( args[count])) );
|
||||
//std::cerr << "success=" << success << std::endl;
|
||||
if (not success) {
|
||||
message += "\n " + getString(nth) + " argument is not convertible to \"" + Hurricane::demangle(typeid(T).name()) + "\".";
|
||||
message += "\n " + getString(nth) + " X argument is not convertible to \"" + Hurricane::demangle(typeid(T).name()) + "\".";
|
||||
PyErr_SetString( Isobar3::ConstructorError, message.c_str() );
|
||||
} else {
|
||||
parse_pyobjects<index,Tail...>( pyArgs, args, success, message, count+1 );
|
||||
|
@ -1692,7 +1823,7 @@ namespace Isobar3 {
|
|||
}
|
||||
}
|
||||
if (success) {
|
||||
//std::cerr << "_call() " << demangle(typeid(FunctionType).name()) << " (with " << nargs << " parameters) rvalue = " << (void*)rvalue << std::endl;
|
||||
//std::cerr << "_call() " << demangle(typeid(FunctionType).name()) << " (with " << nargs << " parameters)" << std::endl;
|
||||
return _callFunction<TR,TArgs...>( _method, cppArgs );
|
||||
}
|
||||
|
||||
|
@ -1742,7 +1873,7 @@ namespace Isobar3 {
|
|||
|
||||
setMessage( funcName() + "(): " );
|
||||
bool success = true;
|
||||
TC* cppObject = static_cast<TC*>( asVPtr(self)->_object );
|
||||
TC* cppObject = static_cast<TC*>( object1(self) );
|
||||
PyObject* rvalue = NULL;
|
||||
Args<TArgs...> cppArgs;
|
||||
if (nargs) {
|
||||
|
@ -1754,7 +1885,7 @@ namespace Isobar3 {
|
|||
, &args[5], &args[6], &args[7], &args[8], &args[9] )) {
|
||||
success = cppArgs.parse( args, message() );
|
||||
} else {
|
||||
cerr << fargs << endl;
|
||||
//cerr << fargs << endl;
|
||||
size_t pynargs = (size_t)PyTuple_Size( fargs );
|
||||
message() += "Invalid number of parameters, got "
|
||||
+ getString(pynargs) + " (expected " + getString(nargs) + ").";
|
||||
|
@ -1952,7 +2083,7 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename TC, typename TR, typename... TArgs >
|
||||
inline PyObject* callMethod ( std::string fname, TR(TC::* method )(TArgs...), PyVoidPointer* self, PyObject* args )
|
||||
inline PyObject* callMethod ( std::string fname, TR(TC::* method )(TArgs...), PyObject* self, PyObject* args )
|
||||
{
|
||||
cdebug_log(30,0) << "[Python]" << fname << "()" << endl;
|
||||
return PyMethodWrapper<TC,TR,TArgs...>( fname, method ).call( (PyObject*)self, args );
|
||||
|
@ -1960,14 +2091,14 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename TC, typename TR, typename... TArgs >
|
||||
inline PyObject* callMethod ( std::string fname, TR(TC::* method )(TArgs...) const, PyVoidPointer* self, PyObject* args )
|
||||
inline PyObject* callMethod ( std::string fname, TR(TC::* method )(TArgs...) const, PyObject* self, PyObject* args )
|
||||
{
|
||||
return callMethod<TC,TR,TArgs...>( fname, (TR(TC::*)(TArgs...))(method), self, args );
|
||||
}
|
||||
|
||||
|
||||
template< typename TC, typename TR, typename... TArgs >
|
||||
inline PyObject* callMethod ( std::string fname, TR(* fmethod )(TC*,TArgs...), PyVoidPointer* self, PyObject* args )
|
||||
inline PyObject* callMethod ( std::string fname, TR(* fmethod )(TC*,TArgs...), PyObject* self, PyObject* args )
|
||||
{
|
||||
cdebug_log(30,0) << "[Python]" << fname << "()" << endl;
|
||||
return PyMethodWrapper<TC,TR,TArgs...>( fname, fmethod ).call( (PyObject*)self, args );
|
||||
|
@ -1975,7 +2106,7 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename TC, typename TR, typename... TArgs >
|
||||
inline PyObject* callMethod ( std::string fname, TR(* fmethod )(const TC*,TArgs...), PyVoidPointer* self, PyObject* args )
|
||||
inline PyObject* callMethod ( std::string fname, TR(* fmethod )(const TC*,TArgs...), PyObject* self, PyObject* args )
|
||||
{
|
||||
return callMethod<TC,TR,TArgs...>( fname, (TR(*)(TC*,TArgs...))(fmethod), self, args );
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ namespace Isobar3 {
|
|||
static PyTypeManagerVectorIterator* create ( PyObject* module, uint64_t flags );
|
||||
virtual PyObject* _getTpIter ( PyObject* );
|
||||
virtual PyObject* _getTpIterNext ( PyObject* );
|
||||
virtual void _getTpDeAlloc ( PyVoidPointer* );
|
||||
virtual long _getTpHash ( PyVoidPointer* );
|
||||
virtual void _getTpDeAlloc ( PyObject* );
|
||||
virtual long _getTpHash ( PyObject* );
|
||||
private:
|
||||
PyMethodDef* _noMethods;
|
||||
};
|
||||
|
@ -48,6 +48,7 @@ namespace Isobar3 {
|
|||
: PyTypeManagerVTrunk< typename std::vector<CppT>::iterator >(NULL,NULL,flags|PyTypeManager::IsIterator)
|
||||
, _noMethods( NULL )
|
||||
{
|
||||
_getTypeObject()->tp_basicsize = sizeof(PyTwoVoid);
|
||||
_noMethods = new PyMethodDef;
|
||||
_noMethods[0].ml_name = NULL;
|
||||
_noMethods[0].ml_meth = NULL;
|
||||
|
@ -62,11 +63,11 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename CppT >
|
||||
void PyTypeManagerVectorIterator<CppT>::_getTpDeAlloc ( PyVoidPointer* self )
|
||||
void PyTypeManagerVectorIterator<CppT>::_getTpDeAlloc ( PyObject* self )
|
||||
{
|
||||
Py_XDECREF( ((PyIteratorPointer*)self)->_container );
|
||||
Py_XDECREF( object2(self) );
|
||||
typename std::vector<CppT>::iterator* piterator = NULL;
|
||||
pyToC( (PyObject*)self, &piterator );
|
||||
pyToC( self, &piterator );
|
||||
delete piterator;
|
||||
PyObject_DEL( self );
|
||||
}
|
||||
|
@ -89,7 +90,7 @@ namespace Isobar3 {
|
|||
typename std::vector<CppT>::iterator* piterator = NULL;
|
||||
typename std::vector<CppT>* pvector = NULL;
|
||||
pyToC( self, &piterator );
|
||||
pyToC( (PyObject*)(asIPtr(self)->_container), &pvector );
|
||||
pyToC( object2(self), &pvector );
|
||||
|
||||
if ((*piterator) != pvector->end()) {
|
||||
PyObject* item = cToPy( **piterator );
|
||||
|
@ -102,8 +103,8 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename CppT >
|
||||
long PyTypeManagerVectorIterator<CppT>::_getTpHash ( PyVoidPointer *self )
|
||||
{ return (long)(self->_object); }
|
||||
long PyTypeManagerVectorIterator<CppT>::_getTpHash ( PyObject *self )
|
||||
{ return (long)(object1(self)); }
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
|
@ -143,10 +144,10 @@ namespace Isobar3 {
|
|||
virtual ~PyTypeManagerVector ();
|
||||
public:
|
||||
static PyTypeManagerVector* create ( PyObject* module, uint64_t flags );
|
||||
virtual Py_ssize_t _getSqLength ( PyVoidPointer* );
|
||||
virtual PyObject* _getSqItem ( PyVoidPointer*, Py_ssize_t );
|
||||
virtual void _getTpDeAlloc ( PyVoidPointer* );
|
||||
virtual long _getTpHash ( PyVoidPointer* );
|
||||
virtual Py_ssize_t _getSqLength ( PyObject* );
|
||||
virtual PyObject* _getSqItem ( PyObject*, Py_ssize_t );
|
||||
virtual void _getTpDeAlloc ( PyObject* );
|
||||
virtual long _getTpHash ( PyObject* );
|
||||
virtual PyObject* _getTpIter ( PyObject* );
|
||||
private:
|
||||
PyMethodDef* _noMethods;
|
||||
|
@ -182,33 +183,33 @@ namespace Isobar3 {
|
|||
|
||||
|
||||
template< typename CppT >
|
||||
void PyTypeManagerVector<CppT>::_getTpDeAlloc ( PyVoidPointer* self )
|
||||
void PyTypeManagerVector<CppT>::_getTpDeAlloc ( PyObject* self )
|
||||
{
|
||||
PyObject_DEL( self );
|
||||
}
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
Py_ssize_t PyTypeManagerVector<CppT>::_getSqLength ( PyVoidPointer* self )
|
||||
Py_ssize_t PyTypeManagerVector<CppT>::_getSqLength ( PyObject* self )
|
||||
{
|
||||
std::vector<CppT>* pvector = NULL;
|
||||
pyToC( (PyObject*)self, &pvector );
|
||||
pyToC( self, &pvector );
|
||||
return pvector->size();
|
||||
}
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
PyObject* PyTypeManagerVector<CppT>::_getSqItem ( PyVoidPointer* self, Py_ssize_t index )
|
||||
PyObject* PyTypeManagerVector<CppT>::_getSqItem ( PyObject* self, Py_ssize_t index )
|
||||
{
|
||||
std::vector<CppT>* pvector = NULL;
|
||||
pyToC( (PyObject*)self, &pvector );
|
||||
pyToC( self, &pvector );
|
||||
return cToPy( (*pvector)[index] );
|
||||
}
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
long PyTypeManagerVector<CppT>::_getTpHash ( PyVoidPointer *self )
|
||||
{ return (long)(self->_object); }
|
||||
long PyTypeManagerVector<CppT>::_getTpHash ( PyObject *self )
|
||||
{ return (long)( object1(self) ); }
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
|
@ -218,9 +219,9 @@ namespace Isobar3 {
|
|||
// std::cerr << "PyTypeManagerVector<CppT>::_getTpIter() on " << (void*)self << std::endl;
|
||||
std::vector<CppT>* pvector = NULL;
|
||||
pyToC( self, &pvector );
|
||||
PyIteratorPointer* pyIterator = (PyIteratorPointer*)cToPy
|
||||
PyTwoVoid* pyIterator = (PyTwoVoid*)cToPy
|
||||
( new typename std::vector<CppT>::iterator(pvector->begin()) );
|
||||
pyIterator->_container = (PyVoidPointer*)self;
|
||||
object2(pyIterator) = self;
|
||||
Py_INCREF( self );
|
||||
// std::cerr << "First iterator:" << (void*)pyIterator << std::endl;
|
||||
return (PyObject*)pyIterator;
|
||||
|
@ -253,14 +254,3 @@ namespace Isobar3 {
|
|||
|
||||
} // Isobar3 namespace.
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
inline PyObject* cToPy ( const typename std::vector<CppT>::iterator* pit )
|
||||
{ return Isobar3::PyTypeManager::link< typename std::vector<CppT>::iterator >
|
||||
( std::addressof(const_cast< typename std::vector<CppT>::iterator* >(pit)) ); }
|
||||
|
||||
|
||||
template< typename CppT >
|
||||
inline PyObject* cToPy ( const std::vector<CppT>& vobject )
|
||||
{ return Isobar3::PyTypeManager::link< std::vector<CppT> >( std::addressof(const_cast< std::vector<CppT>& >(vobject)) ); }
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) Sorbonne Université 2020-2021, All Rights Reserved
|
||||
//
|
||||
// +-----------------------------------------------------------------+
|
||||
// | C O R I O L I S |
|
||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||
// | |
|
||||
// | Author : Jean-Paul CHAPUT |
|
||||
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./hurricane/configuration/PyViaLayer.h" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#pragma once
|
||||
#include "hurricane/configuration/PyTypeManager.h"
|
||||
#include "hurricane/ViaLayer.h"
|
||||
|
||||
|
||||
namespace Isobar3 {
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
extern PyMethodDef PyViaLayer_Methods[];
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar3 namespace.
|
|
@ -84,8 +84,8 @@ namespace Hurricane {
|
|||
static BasicLayer* create ( Technology* technology
|
||||
, const Name& name
|
||||
, const Material& material
|
||||
, unsigned gds2Layer
|
||||
, unsigned gds2Datatype
|
||||
, unsigned gds2Layer = 0
|
||||
, unsigned gds2Datatype = 0
|
||||
, const DbU::Unit& minimalSize = 0
|
||||
, const DbU::Unit& minimalSpacing = 0
|
||||
);
|
||||
|
|
|
@ -0,0 +1,337 @@
|
|||
# -*- mode:Python -*-
|
||||
#
|
||||
# This file is part of the Coriolis Software.
|
||||
# Copyright (c) SU 2012-2020, All Rights Reserved
|
||||
#
|
||||
# +-----------------------------------------------------------------+
|
||||
# | C O R I O L I S |
|
||||
# | Alliance / Hurricane Interface |
|
||||
# | |
|
||||
# | Author : Jean-Paul Chaput |
|
||||
# | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||
# | =============================================================== |
|
||||
# | Python : "./crlcore/helpers/overlay.py" |
|
||||
# +-----------------------------------------------------------------+
|
||||
#
|
||||
# Those classes are based on the work of Jock Tanner from Libre-SOC.
|
||||
|
||||
|
||||
"""
|
||||
Overlay to make some C++ objects provide a more Pythonic interface.
|
||||
Contains:
|
||||
|
||||
* ``overlay.UpdateSession`` : to be used in ``with`` construct.
|
||||
* ``overlay.Configuration`` : to be used in ``with`` construct.
|
||||
* ``overlay.CfgCache`` : A cache for Cfg parameters.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import Cfg
|
||||
import Hurricane
|
||||
|
||||
|
||||
class UpdateSession ( object ):
|
||||
"""
|
||||
Context manager for a GO update session. See Hurricane reference manual
|
||||
for an info on Hurricane::UpdateSession class.
|
||||
"""
|
||||
|
||||
def __enter__ ( self ):
|
||||
Hurricane.UpdateSession.open()
|
||||
|
||||
def __exit__( self, *args ):
|
||||
Hurricane.UpdateSession.close()
|
||||
|
||||
|
||||
class Configuration:
|
||||
"""
|
||||
Allow access to Cfg parameter as attributes. For attribute syntax,
|
||||
the dot (.) used in C++ or raw access is replaced by an underscore (_)
|
||||
in Python mode.
|
||||
|
||||
Also provides a context manager.
|
||||
"""
|
||||
|
||||
PRIORITY_USE_DEFAULT = Cfg.Parameter.Priority.UseDefault
|
||||
PRIORITY_APPLICATION_BUILTIN = Cfg.Parameter.Priority.ApplicationBuiltin
|
||||
PRIORITY_CONFIGURATION_FILE = Cfg.Parameter.Priority.ConfigurationFile
|
||||
PRIORITY_USER_FILE = Cfg.Parameter.Priority.UserFile
|
||||
PRIORITY_COMMAND_LINE = Cfg.Parameter.Priority.CommandLine
|
||||
PRIORITY_INTERACTIVE = Cfg.Parameter.Priority.Interactive
|
||||
|
||||
def __init__ ( self, priority=None ):
|
||||
self._priority = priority
|
||||
|
||||
def __enter__( self ):
|
||||
if self._priority is not None:
|
||||
Cfg.Configuration.pushDefaultPriority( self._priority )
|
||||
return self
|
||||
|
||||
def __setattr__( self, attr, val ):
|
||||
if attr.startswith("_"):
|
||||
self.__dict__[attr] = val
|
||||
return
|
||||
attr = attr.replace("_", ".")
|
||||
if isinstance(val, bool):
|
||||
Cfg.getParamBool(attr).setBool( val )
|
||||
elif isinstance(val, int):
|
||||
p = Cfg.getParamInt( attr ) # all params have a type
|
||||
if p.type == 'Enumerate':
|
||||
Cfg.getParamEnumerate(attr).setInt( val )
|
||||
else:
|
||||
Cfg.getParamInt(attr).setInt( val )
|
||||
elif isinstance(val, long):
|
||||
p = Cfg.getParamInt( attr ) # all params have a type
|
||||
p.setInt( val )
|
||||
elif isinstance(val, float):
|
||||
p = Cfg.getParamDouble( attr ).setDouble( val )
|
||||
elif '%' in val:
|
||||
Cfg.getParamPercentage(attr).setPercentage( float(val[:-1]) )
|
||||
else:
|
||||
Cfg.getParamString(attr).setString( val )
|
||||
|
||||
def __exit__( self, *args ):
|
||||
if self._priority is not None:
|
||||
Cfg.Configuration.popDefaultPriority()
|
||||
|
||||
|
||||
class CachedParameter ( object ):
|
||||
|
||||
def __init__ ( self, path, v ):
|
||||
self.path = path
|
||||
self._v = None
|
||||
self.v = v
|
||||
self.vRange = [ None, None ]
|
||||
self.vEnum = []
|
||||
self.create = True
|
||||
self.cacheRead()
|
||||
|
||||
@property
|
||||
def v ( self ): return self._v
|
||||
|
||||
@v.setter
|
||||
def v ( self, value ):
|
||||
if value is not None: self._v = value
|
||||
|
||||
def __str__ ( self ):
|
||||
if isinstance(self.v,str): s = '"{}"'.format(self.v)
|
||||
else: s = '{}'.format(self.v)
|
||||
if self.vRange[0] is not None or self.vRange[1] is not None:
|
||||
s += ' [{}:{}]'.format(self.vRange[0],self.vRange[1])
|
||||
if self.vEnum:
|
||||
s += ' ('
|
||||
for i in range(len(self.vEnum)):
|
||||
if i: s += ', '
|
||||
s += '{}:"{}"'.format(self.vEnum[i][1],self.vEnum[i][0])
|
||||
s += ')'
|
||||
return s
|
||||
|
||||
def cacheWrite ( self ):
|
||||
""""
|
||||
Commit the value of parameter ``self.path`` to ``self.v`` in Cfg.
|
||||
Percentage are set as Double and Enumerate as Int.
|
||||
"""
|
||||
if Cfg.hasParameter(self.path):
|
||||
confDb = Cfg.Configuration.get()
|
||||
p = confDb.getParameter( self.path )
|
||||
else:
|
||||
if len(self.vEnum): p = Cfg.getParamEnumerate( self.path )
|
||||
elif isinstance(self.v,bool ): p = Cfg.getParamBool ( self.path )
|
||||
elif isinstance(self.v,int ): p = Cfg.getParamInt ( self.path )
|
||||
elif isinstance(self.v,float): p = Cfg.getParamDouble ( self.path )
|
||||
else: p = Cfg.getParamString ( self.path )
|
||||
if p.type == Cfg.Parameter.Type.Enumerate: p.setInt ( self.v )
|
||||
elif p.type == Cfg.Parameter.Type.Int: p.setInt ( self.v )
|
||||
elif p.type == Cfg.Parameter.Type.Bool: p.setBool ( self.v )
|
||||
elif p.type == Cfg.Parameter.Type.Double: p.setDouble ( self.v )
|
||||
elif p.type == Cfg.Parameter.Type.Percentage: p.setDouble ( self.v*100.0 )
|
||||
else: p.setString ( str(self.v) )
|
||||
if self.create:
|
||||
if len(self.vEnum):
|
||||
for item in self.vEnum:
|
||||
p.addValue( item[0], item[1] )
|
||||
if self.vRange[0] is not None: p.setMin( self.vRange[0] )
|
||||
if self.vRange[1] is not None: p.setMax( self.vRange[1] )
|
||||
|
||||
def cacheRead ( self ):
|
||||
""""Get the value of parameter ``self.path`` from Cfg."""
|
||||
if not Cfg.hasParameter(self.path):
|
||||
self.create = True
|
||||
return
|
||||
if self.v is not None: return
|
||||
confDb = Cfg.Configuration.get()
|
||||
p = confDb.getParameter( self.path )
|
||||
if p:
|
||||
if p.type == Cfg.Parameter.Type.Enumerate: self.v = p.asInt()
|
||||
elif p.type == Cfg.Parameter.Type.Int:
|
||||
self.v = p.asInt()
|
||||
elif p.type == Cfg.Parameter.Type.Bool: self.v = p.asBool()
|
||||
elif p.type == Cfg.Parameter.Type.String: self.v = p.asString()
|
||||
elif p.type == Cfg.Parameter.Type.Double: self.v = p.asDouble()
|
||||
elif p.type == Cfg.Parameter.Type.Percentage: self.v = p.asDouble()/100.0
|
||||
else: self.v = p.asString()
|
||||
|
||||
|
||||
class CfgCache ( object ):
|
||||
"""
|
||||
CgfCache cache a set of configuration parameters. The values of the
|
||||
parameters are not set in the system *until* the ``apply()`` function
|
||||
is called.
|
||||
|
||||
If a parameter do not exists in the ``Cfg`` module, it is created
|
||||
when ``apply()`` is called. Be aware that it is not able to guess
|
||||
the right type between Double and Percentage or Int and Enumerate.
|
||||
It will, by default, only create Double or Int. So, when setting
|
||||
Percentage or Enumerate, be sure that they exists beforehand in
|
||||
the ``Cfg`` module.
|
||||
|
||||
The attributes of CfgCache exactly mimic the behavior of the
|
||||
``Cfg`` parameter string identifiers. For example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Direct access to a Cfg parameter.
|
||||
p = Cfg.getParamInt('katana.eventsLimit').setInt( 4000000 )
|
||||
|
||||
# Setup of a CfgCache parameter.
|
||||
cache = CfgCache('')
|
||||
cache.katana.eventsLimit = 4000000
|
||||
|
||||
# ...
|
||||
# Effective setting of the Cfg parameter.
|
||||
cache.apply()
|
||||
|
||||
If a cache parameter is assigned to ``None``, it triggers the
|
||||
loading of the value from the disk, it it exists.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Setup of a CfgCache parameter.
|
||||
cache = CfgCache('')
|
||||
cache.katana.eventsLimit = None
|
||||
# The parameter will read it's value from the disk (4000000).
|
||||
|
||||
|
||||
This is done by overloading ``__setattr__()`` and ``__getattr__()``
|
||||
which recursively create CfgCache objects for intermediate levels
|
||||
attributes (in the previous example, a CfgCache for ``katana``
|
||||
will automatically be created). To separate between attributes
|
||||
that are part of configuration parameters and attributes belonging
|
||||
to CfgCache itself, we prepend a '_' to the laters.
|
||||
|
||||
.. note:: It is important to understand the difference of behavior
|
||||
with ``Configuration``, the former set the parameters
|
||||
at once, it directly act on the ``Cfg`` settings.
|
||||
The later keep a state and set the ``Cfg`` parameters
|
||||
*only* when ``apply()`` is called.
|
||||
"""
|
||||
|
||||
def __enter__( self ):
|
||||
return self
|
||||
|
||||
def __exit__( self, *args ):
|
||||
self.apply()
|
||||
self.display()
|
||||
|
||||
def __init__ ( self, path='', priority=None ):
|
||||
"""Create a new CfgCache with a ``path`` as parent path."""
|
||||
self._priority = priority
|
||||
self._path = path
|
||||
self._rattr = {}
|
||||
|
||||
def __setattr__ ( self, attr, v ):
|
||||
"""
|
||||
Recursively set an attribute. Attributes names starting by an '_' are
|
||||
treated as belonging to *this* object (self).
|
||||
|
||||
How does the recursive attributes/CfgCache works? Assumes that we
|
||||
are doing:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Setup of a CfgCache parameter.
|
||||
cache = CfgCache('')
|
||||
cache.katana.eventsLimit = 4000000
|
||||
|
||||
The explicit call sequence will be:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
cache.__getattr__('katana').__setattr__( 'eventsLimit', 4000000 )
|
||||
|
||||
1. For the intermediate hierarchy level ``katana``, it is __getattr__()
|
||||
which is called, if the attribute do not exists, we create a new
|
||||
CfgCache().
|
||||
|
||||
2. Second, and only then, __setattr__() is called, which will create a
|
||||
parameter entry named ``eventsLimit``.
|
||||
|
||||
The decision of whether create a parameter entry *or* a CfgCache
|
||||
intermediate level will always be correctly handled because prior
|
||||
to any access, an attribute needs to be set. So we always have
|
||||
first a call chain of __getattr__() with one final __setattr__().
|
||||
For any subsequent access to ``cache.katana.eventsLimit``, as
|
||||
the attribute already exists, there is no type creation problem.
|
||||
"""
|
||||
if attr[0] == '_':
|
||||
object.__setattr__( self, attr, v )
|
||||
return
|
||||
vRange = None
|
||||
vEnum = None
|
||||
if isinstance(v,list ): vRange = v; v = None
|
||||
if isinstance(v,tuple): vEnum = v; v = None
|
||||
if not attr in self._rattr:
|
||||
self._rattr[ attr ] = CachedParameter( self._path+'.'+attr, v )
|
||||
if vRange is not None: self._rattr[ attr ].vRange = vRange
|
||||
elif vEnum is not None: self._rattr[ attr ].vEnum = vEnum
|
||||
else: self._rattr[ attr ].v = v
|
||||
|
||||
def __getattr__ ( self, attr ):
|
||||
"""
|
||||
Get an attribute, if it doesn't exists, then we are in an intermediate
|
||||
level like ``katana``, so create a new sub CfgCache for that attribute.
|
||||
"""
|
||||
if not attr in self._rattr:
|
||||
path = self._path+'.'+attr if len(self._path) else attr
|
||||
self._rattr[attr] = CfgCache( path, self._priority )
|
||||
if isinstance(self._rattr[attr],CachedParameter):
|
||||
return self._rattr[attr].v
|
||||
return self._rattr[attr]
|
||||
|
||||
def _hasCachedParam ( self, elements ):
|
||||
if not elements[0] in self._rattr:
|
||||
return False
|
||||
if len(elements) == 1:
|
||||
return True
|
||||
rattr = self._rattr[ elements[0] ]
|
||||
if not isinstance(rattr,CfgCache):
|
||||
return False
|
||||
return rattr._hasCachedParam( elements[1:] )
|
||||
|
||||
def hasCachedParam ( self, attr ):
|
||||
return self._hasCachedParam( attr.split('.') )
|
||||
|
||||
def apply ( self, priority=None ):
|
||||
"""Apply the parameters values stored in the cache to the ``Cfg`` database."""
|
||||
if priority is None: priority = self._priority
|
||||
if not len(self._path) and priority is not None:
|
||||
Cfg.Configuration.pushDefaultPriority( priority )
|
||||
for attrName in self._rattr.keys():
|
||||
if isinstance(self._rattr[attrName],CfgCache):
|
||||
self._rattr[attrName].apply()
|
||||
continue
|
||||
self._rattr[attrName].cacheWrite()
|
||||
if not len(self._path) and priority is not None:
|
||||
Cfg.Configuration.popDefaultPriority()
|
||||
#self.display()
|
||||
|
||||
def display ( self ):
|
||||
"""Print all the parameters stored in that CfgCache."""
|
||||
if not len(self._path):
|
||||
print( ' o Applying configuration (CfgCache):' )
|
||||
for attrName in self._rattr.keys():
|
||||
if isinstance(self._rattr[attrName],CfgCache):
|
||||
self._rattr[attrName].display()
|
||||
continue
|
||||
print( ' - {}.{} = {}'.format(self._path,attrName,self._rattr[attrName]) )
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
# -*- mode:Python -*-
|
||||
#
|
||||
# This file is part of the Coriolis Software.
|
||||
# Copyright (c) Sorbonne Université 2020-2021, All Rights Reserved
|
||||
#
|
||||
# +-----------------------------------------------------------------+
|
||||
# | C O R I O L I S |
|
||||
# | Alliance / Hurricane Interface |
|
||||
# | |
|
||||
# | Author : Jean-Paul Chaput |
|
||||
# | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||
# | =============================================================== |
|
||||
# | Python : "./crlcore/helpers/technology.py" |
|
||||
# +-----------------------------------------------------------------+
|
||||
|
||||
"""
|
||||
Some helpers to create or load a technology and it's libraries.
|
||||
"""
|
||||
|
||||
from Hurricane3 import DataBase, Layer, BasicLayer, ViaLayer
|
||||
|
||||
|
||||
__all__ = [ 'safeGetLibrary', 'createBL', 'setEnclosures' ]
|
||||
|
||||
|
||||
def safeGetLibrary ( frameworkName, libName ):
|
||||
"""
|
||||
Return the library named ``libName`` if it already exists,
|
||||
or create it if needed. To avoid potential collision, design
|
||||
kits libraries should not be created directly under the DataBase
|
||||
root library but be grouped under a common technology library,
|
||||
in this case ``CM018``.
|
||||
"""
|
||||
db = DataBase.getDB()
|
||||
tech = db.getTechnology()
|
||||
frameLib = db.getRootLibrary().getLibrary( frameworkName )
|
||||
if frameLib is None:
|
||||
frameLib = Library.create( db.getRootLibrary(), frameworkName )
|
||||
lib = frameLib.getLibrary( libName )
|
||||
if lib is None:
|
||||
lib = Library.create( frameLib, libName )
|
||||
return lib
|
||||
|
||||
|
||||
def createBL ( tech, layerName, material, size=None, spacing=None, gds2Layer=None, gds2DataType=0, area=None ):
|
||||
"""
|
||||
Create a new BasicLayer. Parameters ``tech``, ``layerName`` and ``material``
|
||||
are mandatory.
|
||||
|
||||
:param tech: The technology the basic layer will be part of.
|
||||
:param layerName: The name of the layer.
|
||||
:param material: The kind of layer, see BasicLayer.Material.
|
||||
:param size: The minimal size (i.e. width).
|
||||
:param spacing: The minimal distance, edge to edge between two wires.
|
||||
:param gds2layer: The GDSII layer number (for the GDSII driver).
|
||||
:param gds2DataType: The GDSII DataType (i.e purpose).
|
||||
:param area: The minimum area (in um2)
|
||||
"""
|
||||
print( tech )
|
||||
layer = BasicLayer.create( tech, layerName, BasicLayer.Material(material) )
|
||||
if size is not None:
|
||||
layer.setMinimalSize( size )
|
||||
if spacing is not None:
|
||||
layer.setMinimalSpacing( spacing )
|
||||
if gds2Layer is not None:
|
||||
layer.setGds2Layer ( gds2Layer )
|
||||
layer.setGds2Datatype( gds2DataType )
|
||||
if area is not None:
|
||||
layer.setMinimalArea( area )
|
||||
return layer
|
||||
|
||||
|
||||
def createVia ( tech, viaName, botName, cutName, topName, size=None ):
|
||||
"""
|
||||
Create a new ViaLayer. Parameters ``tech``, ``viaName``, ``botName``,
|
||||
``cutName`` and ``topName`` are mandatory.
|
||||
|
||||
:param tech: The technology the basic layer will be part of.
|
||||
:param viaName: The name of the newly defined VIA layer.
|
||||
:param botName: The name of the *bottom* metal layer.
|
||||
:param cutName: The name of the *cut* (aka, via hole) layer.
|
||||
:param topName: The name of the *top* metal layer.
|
||||
:param size: The minimal side size of the square *cut* layer.
|
||||
"""
|
||||
layer = ViaLayer.create( tech
|
||||
, viaName
|
||||
, tech.getLayer(botName)
|
||||
, tech.getLayer(cutName)
|
||||
, tech.getLayer(topName) )
|
||||
if size is not None:
|
||||
layer.setMinimalSize( size )
|
||||
return layer
|
||||
|
||||
|
||||
def setEnclosures ( layer, subLayer, enclosures ):
|
||||
"""
|
||||
Set horizontal & vertical enclosure for a given ``subLayer`` in a
|
||||
composite ``layer`` (typically a ViaLayer). If ``enclosures`` is a
|
||||
number, both H/V will be set to that same value. If it is a tuple
|
||||
(a pair), then the first value is horizontal and the seconf is
|
||||
vertical.
|
||||
"""
|
||||
if isinstance(enclosures,tuple):
|
||||
henclosure = enclosures[0]
|
||||
venclosure = enclosures[1]
|
||||
else:
|
||||
henclosure = enclosures
|
||||
venclosure = enclosures
|
||||
layer.setEnclosure( subLayer, henclosure, Layer.EnclosureH )
|
||||
layer.setEnclosure( subLayer, venclosure, Layer.EnclosureV )
|
||||
return
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import Cfg2
|
||||
|
||||
print dir(Cfg2)
|
||||
print dir(Cfg2.Configuration)
|
||||
|
||||
|
||||
v = Cfg2.get()
|
||||
print dir(v)
|
|
@ -0,0 +1,183 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
def flush ():
|
||||
sys.stdout.flush()
|
||||
sys.stderr.flush()
|
||||
|
||||
|
||||
import Cfg
|
||||
|
||||
print( "" )
|
||||
print( "Test 7" )
|
||||
print( "========================================" )
|
||||
print( type(Cfg) )
|
||||
flush()
|
||||
print( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" )
|
||||
print( "dir(Cfg) first test" )
|
||||
for item in dir(Cfg):
|
||||
print( item )
|
||||
flush()
|
||||
flush()
|
||||
print( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" )
|
||||
print( "Cfg.__dict__" )
|
||||
print( Cfg.__dict__ )
|
||||
flush()
|
||||
print( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" )
|
||||
print( "str(Cfg)" )
|
||||
print( str(Cfg) )
|
||||
flush()
|
||||
print( "repr(Cfg)" )
|
||||
print( repr(Cfg) )
|
||||
flush()
|
||||
print( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" )
|
||||
print( "dir(Cfg), second test" )
|
||||
for item in dir(Cfg):
|
||||
print( item )
|
||||
flush()
|
||||
flush()
|
||||
print( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" )
|
||||
print( "Cfg.__dict__" )
|
||||
print( Cfg.__dict__ )
|
||||
flush()
|
||||
print( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" )
|
||||
print( "dir(Cfg.parameter)" )
|
||||
print( type(Cfg.Parameter) )
|
||||
for item in dir(Cfg.Parameter):
|
||||
print( item )
|
||||
flush()
|
||||
flush()
|
||||
print( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" )
|
||||
print( "dir(Cfg), third test" )
|
||||
for item in dir(Cfg):
|
||||
print( item )
|
||||
flush()
|
||||
flush()
|
||||
print( Cfg.__dict__ )
|
||||
|
||||
print( "" )
|
||||
print( "Test 1" )
|
||||
print( "========================================" )
|
||||
cfg = Cfg.Configuration.get()
|
||||
p1 = cfg.addParameter( "test.param1", Cfg.Parameter.Type.String, "my_value_1", Cfg.Parameter.Priority.ApplicationBuiltin )
|
||||
print( 'p1=', p1 )
|
||||
print( '(before) p1.flags=', p1.flags )
|
||||
p1.flags = Cfg.Parameter.Flags.HasMin|Cfg.Parameter.Flags.HasMax
|
||||
print( '(after) p1.flags=', p1.flags )
|
||||
|
||||
print( "" )
|
||||
print( "Test 2" )
|
||||
print( "========================================" )
|
||||
p2 = cfg.addParameter( "test.param2", Cfg.Parameter.Type.String, "my_value_2" )
|
||||
print( p2 )
|
||||
dir(Cfg)
|
||||
|
||||
cfg.pushDefaultPriority( Cfg.Parameter.Priority.ConfigurationFile )
|
||||
print( "priority=%d" % cfg.getDefaultPriority() )
|
||||
flush()
|
||||
|
||||
print( "" )
|
||||
print( "Test 3" )
|
||||
print( "========================================" )
|
||||
hasP1 = Cfg.hasParameter( 'test.param1' )
|
||||
print( 'hasP1=%s' % hasP1 )
|
||||
hasP3 = Cfg.hasParameter( 'test.param3' )
|
||||
print( 'hasP3=%s' % hasP3 )
|
||||
dir(Cfg.Parameter)
|
||||
flush()
|
||||
|
||||
print( "" )
|
||||
print( "Test 4" )
|
||||
print( "========================================" )
|
||||
try:
|
||||
p3 = cfg.addParameter( "test.param3", Cfg.Parameter.Type.String )
|
||||
except Exception as e:
|
||||
print( e )
|
||||
dir(Cfg.Parameter)
|
||||
flush()
|
||||
|
||||
print( "" )
|
||||
print( "Test 5" )
|
||||
print( "========================================" )
|
||||
try:
|
||||
p4 = cfg.addParameter( 1, Cfg.Parameter.Type.String, "my_value4" )
|
||||
except Exception as e:
|
||||
print( e )
|
||||
dir(Cfg.Parameter)
|
||||
flush()
|
||||
|
||||
print( "" )
|
||||
print( "Test 6" )
|
||||
print( "========================================" )
|
||||
pX = Cfg.getParamString( 'test.param1' )
|
||||
print( 'test.param1=%s' % pX )
|
||||
print( 'test.param1.isFile(): %s' % pX.isFile() )
|
||||
dir(Cfg.Parameter)
|
||||
flush()
|
||||
|
||||
print( "" )
|
||||
print( "Test 8" )
|
||||
print( "========================================" )
|
||||
master = cfg.addParameter( "test.master", Cfg.Parameter.Type.String, "master value" )
|
||||
slave1 = cfg.addParameter( "test.slave1", Cfg.Parameter.Type.String, "slave1 value" )
|
||||
slave2 = cfg.addParameter( "test.slave2", Cfg.Parameter.Type.String, "slave2 value" )
|
||||
slave3 = cfg.addParameter( "test.slave3", Cfg.Parameter.Type.String, "slave3 value" )
|
||||
master.addSlave( 'test.slave1' )
|
||||
master.addSlave( 'test.slave2' )
|
||||
master.addSlave( 'test.slave3' )
|
||||
flush()
|
||||
print( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" )
|
||||
print( "Walkthrough the vector using indexes" )
|
||||
slaves = master.getSlaves()
|
||||
for i in range(len(slaves)):
|
||||
print( '[%d] %s' % (i,slaves[i]) )
|
||||
flush()
|
||||
flush()
|
||||
print( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" )
|
||||
print( "Walkthrough the vector using iterator" )
|
||||
for slave in slaves:
|
||||
print( '===> %s' % slave )
|
||||
flush()
|
||||
flush()
|
||||
print( '"test.slave2" in slaves = {}'.format('test.slave2' in slaves) )
|
||||
print( '"test.slaveX" in slaves = {}'.format('test.slaveX' in slaves) )
|
||||
|
||||
print( "" )
|
||||
print( "Test 9" )
|
||||
print( "========================================" )
|
||||
testDict = { 'machin':1, 'truc':2 }
|
||||
for key in testDict:
|
||||
print( '==>', key )
|
||||
flush()
|
||||
flush()
|
||||
print( 'has key "machin":{}'.format('machin' in testDict) )
|
||||
params = cfg.getParameters()
|
||||
print( 'params["test.master"] = %s' % params['test.master'] )
|
||||
try:
|
||||
print( 'params.has_key("test.master") = {}'.format('test.master' in params) )
|
||||
#print( 'params.has_key("test.master") = {}'.format(params.has_key('test.master') ))
|
||||
print( 'params.has_key("test.slave6") = {}'.format('test.slave6' in params) )
|
||||
print( 'params["test.slave6"] = %s' % params['test.slave6'] )
|
||||
except KeyError as ke:
|
||||
print( ke )
|
||||
print( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" )
|
||||
print( "Walkthrough the map using iterator" )
|
||||
for k, v in params:
|
||||
print( '===> %s %s' % (k,v) )
|
||||
flush()
|
||||
flush()
|
||||
|
||||
print( "" )
|
||||
print( "Test 10" )
|
||||
print( "========================================" )
|
||||
print( 'getParamString("test.master")=', Cfg.getParamString( "test.master" ) )
|
||||
flush()
|
||||
|
||||
pint = cfg.addParameter( "test.paramInt", Cfg.Parameter.Type.Int, "12" )
|
||||
print( 'pint=', pint )
|
||||
flush()
|
||||
|
||||
pdouble = cfg.addParameter( "test.paramDouble", Cfg.Parameter.Type.Double, "3.14" )
|
||||
print( 'pdouble=', pdouble )
|
||||
flush()
|
|
@ -0,0 +1,234 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import Cfg
|
||||
from Hurricane3 import DbU, Point, Box, DataBase, Technology, LayerMask, \
|
||||
BasicLayer, ViaLayer, RegularLayer
|
||||
from overlay import CfgCache
|
||||
from technology import createBL
|
||||
|
||||
def flush ():
|
||||
sys.stdout.flush()
|
||||
sys.stderr.flush()
|
||||
|
||||
#def u ( value ): return value
|
||||
#def l ( value ): return value
|
||||
def l ( value ): return DbU.fromLambda( value )
|
||||
def u ( value ): return DbU.fromPhysical( value, DbU.UnitPowerMicro )
|
||||
def n ( value ): return DbU.fromPhysical( value, DbU.UnitPowerNano )
|
||||
|
||||
def cfg_setup():
|
||||
print( "" )
|
||||
print( "Test Cfg module" )
|
||||
print( "========================================" )
|
||||
# Place & Route setup
|
||||
with CfgCache(priority=Cfg.Parameter.Priority.ConfigurationFile) as cfg:
|
||||
cfg.lefImport.minTerminalWidth = 0.0
|
||||
cfg.crlcore.groundName = 'vss'
|
||||
cfg.crlcore.powerName = 'vdd'
|
||||
cfg.etesian.aspectRatio = 1.00
|
||||
cfg.etesian.aspectRatio = [10, 1000]
|
||||
cfg.etesian.spaceMargin = 0.10
|
||||
cfg.etesian.uniformDensity = False
|
||||
cfg.etesian.routingDriven = False
|
||||
#cfg.etesian.latchUpDistance = u(30.0 - 1.0)
|
||||
cfg.etesian.latchUpDistance = 0
|
||||
cfg.etesian.antennaInsertThreshold = 0.50
|
||||
cfg.etesian.antennaMaxWL = u(250.0)
|
||||
cfg.etesian.antennaGateMaxWL = u(250.0)
|
||||
cfg.etesian.antennaDiodeMaxWL = u(550.0)
|
||||
cfg.etesian.tieName = 'tiepoly_x0'
|
||||
cfg.etesian.feedNames = 'tiepoly_x0'
|
||||
cfg.etesian.cell.zero = 'zero_x0'
|
||||
cfg.etesian.cell.one = 'one_x0'
|
||||
cfg.etesian.bloat = 'disabled'
|
||||
cfg.etesian.effort = 2
|
||||
cfg.etesian.effort = (
|
||||
('Fast', 1),
|
||||
('Standard', 2),
|
||||
('High', 3 ),
|
||||
('Extreme', 4 ),
|
||||
)
|
||||
cfg.etesian.graphics = 2
|
||||
cfg.etesian.graphics = (
|
||||
('Show every step', 1),
|
||||
('Show lower bound', 2),
|
||||
('Show result only', 3),
|
||||
)
|
||||
cfg.anabatic.routingGauge = 'FlexLib'
|
||||
cfg.anabatic.globalLengthThreshold = 1450
|
||||
cfg.anabatic.saturateRatio = 0.90
|
||||
cfg.anabatic.saturateRp = 10
|
||||
cfg.anabatic.topRoutingLayer = 'METAL6'
|
||||
cfg.anabatic.edgeLength = 48
|
||||
cfg.anabatic.edgeWidth = 8
|
||||
cfg.anabatic.edgeCostH = 9.0
|
||||
cfg.anabatic.edgeCostK = -10.0
|
||||
cfg.anabatic.edgeHInc = 1.0
|
||||
cfg.anabatic.edgeHScaling = 1.0
|
||||
cfg.anabatic.globalIterations = 10
|
||||
cfg.anabatic.globalIterations = [ 1, 100 ]
|
||||
cfg.anabatic.gcell.displayMode = 1
|
||||
cfg.anabatic.gcell.displayMode = (("Boundary", 1), ("Density", 2))
|
||||
cfg.katana.hTracksReservedLocal = 4
|
||||
cfg.katana.hTracksReservedLocal = [0, 20]
|
||||
cfg.katana.vTracksReservedLocal = 3
|
||||
cfg.katana.vTracksReservedLocal = [0, 20]
|
||||
cfg.katana.termSatReservedLocal = 8
|
||||
cfg.katana.termSatThreshold = 9
|
||||
cfg.katana.eventsLimit = 4000002
|
||||
cfg.katana.ripupCost = 3
|
||||
cfg.katana.ripupCost = [0, None]
|
||||
cfg.katana.strapRipupLimit = 16
|
||||
cfg.katana.strapRipupLimit = [1, None]
|
||||
cfg.katana.localRipupLimit = 9
|
||||
cfg.katana.localRipupLimit = [1, None]
|
||||
cfg.katana.globalRipupLimit = 5
|
||||
cfg.katana.globalRipupLimit = [1, None]
|
||||
cfg.katana.longGlobalRipupLimit = 5
|
||||
cfg.chip.padCoreSide = 'South'
|
||||
|
||||
# Plugins setup
|
||||
with CfgCache(priority=Cfg.Parameter.Priority.ConfigurationFile) as cfg:
|
||||
cfg.viewer.minimumSize = 500
|
||||
cfg.viewer.pixelThreshold = 20
|
||||
cfg.chip.block.rails.count = 0
|
||||
cfg.chip.block.rails.hWidth = u(2.68)
|
||||
cfg.chip.block.rails.vWidth = u(2.68)
|
||||
cfg.chip.block.rails.hSpacing = 0 #u(0.7)
|
||||
cfg.chip.block.rails.vSpacing = 0 #u(0.7)
|
||||
cfg.clockTree.minimumSide = l(600)
|
||||
cfg.clockTree.buffer = 'buf_x2'
|
||||
cfg.clockTree.placerEngine = 'Etesian'
|
||||
cfg.block.spareSide = 10
|
||||
cfg.spares.buffer = 'buf_x8'
|
||||
cfg.spares.maxSinks = 31
|
||||
|
||||
|
||||
def testDbU ():
|
||||
print( "" )
|
||||
print( "Test Hurricane::DbU" )
|
||||
print( "========================================" )
|
||||
DbU.setPrecision( 2 )
|
||||
DbU.setPhysicalsPerGrid( 0.5, DbU.UnitPowerMicro )
|
||||
DbU.setGridsPerLambda( 2.0 )
|
||||
DbU.setSymbolicSnapGridStep( DbU.fromLambda(1.0) )
|
||||
DbU.setPolygonStep(DbU.fromGrid( 2.0) )
|
||||
DbU.setStringMode( DbU.StringModeSymbolic, DbU.UnitPowerMicro )
|
||||
value = DbU.fromPhysical( 10.0, DbU.UnitPowerMicro )
|
||||
print( "value={}".format( DbU.getValueString(value) ))
|
||||
|
||||
|
||||
def testPoint ():
|
||||
print( "" )
|
||||
print( "Test Hurricane::Point" )
|
||||
print( "========================================" )
|
||||
p1 = Point( 1000, 2000 )
|
||||
print( p1 )
|
||||
p2 = Point( 1000, 2000 )
|
||||
print( p1 == p2 )
|
||||
p3 = Point( 2000, 2000 )
|
||||
print( p1 == p3 )
|
||||
p4 = Point( p3 )
|
||||
print( p4 )
|
||||
|
||||
|
||||
def testBox ():
|
||||
print( "" )
|
||||
print( "Test Hurricane::Box" )
|
||||
print( "========================================" )
|
||||
b1 = Box()
|
||||
print( b1 )
|
||||
b1.merge( Point(1000,1000) )
|
||||
print( 'b1.merge(Point(1000,1000)={}'.format(b1) )
|
||||
b1.merge( Box(Point(2000,2000)) )
|
||||
print( 'b1.merge(Box(Point(1000,1000))={}'.format(b1) )
|
||||
print( 'b1.getCenter()={}'.format(b1.getCenter()) )
|
||||
p1 = Point( 1000, 1000 )
|
||||
b2 = Box( p1 )
|
||||
print( b2 )
|
||||
|
||||
|
||||
def testDB ():
|
||||
print( "" )
|
||||
print( "Test Hurricane::DataBase" )
|
||||
print( "========================================" )
|
||||
db = DataBase.create()
|
||||
print( 'DataBase.getDB()={}'.format(DataBase.getDB()) )
|
||||
print( 'DataBase.Flags.CreateLib={}'.format(DataBase.Flags.CreateLib) )
|
||||
|
||||
|
||||
def testTechnology ():
|
||||
print( "" )
|
||||
print( "Test Hurricane::Technology" )
|
||||
print( "========================================" )
|
||||
tech = Technology.create( DataBase.getDB(), 'test_techno' )
|
||||
print( 'tech={}'.format(tech) )
|
||||
|
||||
|
||||
def testLayerMask ():
|
||||
print( "" )
|
||||
print( "Test Hurricane::Layer::Mask" )
|
||||
print( "========================================" )
|
||||
mask16 = LayerMask( 16 )
|
||||
print( 'mask16= {}'.format(mask16) )
|
||||
mask32 = LayerMask( 16+32 )
|
||||
print( 'mask16= {}'.format(mask32) )
|
||||
maskAnd = mask16 & mask32
|
||||
print( 'maskAnd={}'.format(maskAnd) )
|
||||
try:
|
||||
maskAnd = mask16 & 4
|
||||
print( 'maskAnd={}'.format(maskAnd) )
|
||||
except Exception as e:
|
||||
print( 'Catched and exception...' )
|
||||
print( e )
|
||||
maskShift = maskAnd << 1
|
||||
print( 'maskShift={}'.format(maskShift) )
|
||||
maskNot = ~maskAnd
|
||||
print( 'maskNot={}'.format(maskNot) )
|
||||
print( 'maskAnd={}'.format(maskAnd) )
|
||||
mask64 = LayerMask( 64+16 )
|
||||
print( 'mask64={}'.format(mask64) )
|
||||
mask64 &= LayerMask( 64 )
|
||||
print( 'mask64={}'.format(mask64) )
|
||||
mask64 |= LayerMask( 16 )
|
||||
print( 'mask64={}'.format(mask64) )
|
||||
mask64.fromString( '0x0000ffff' )
|
||||
print( 'mask64={}'.format(mask64) )
|
||||
|
||||
|
||||
def testBasicLayer ():
|
||||
print( "" )
|
||||
print( "Test Hurricane::BasicLayer" )
|
||||
print( "========================================" )
|
||||
db = DataBase.getDB()
|
||||
tech = db.getTechnology()
|
||||
nWell = createBL( tech, 'nWell' , BasicLayer.Material.nWell )
|
||||
pWell = createBL( tech, 'pWell' , BasicLayer.Material.pWell )
|
||||
cut1 = createBL( tech, 'cut1' , BasicLayer.Material.cut )
|
||||
metal1 = createBL( tech, 'metal1', BasicLayer.Material.metal )
|
||||
metal2 = createBL( tech, 'metal2', BasicLayer.Material.metal )
|
||||
METAL1 = RegularLayer.create( tech, 'METAL1', metal1 )
|
||||
METAL2 = RegularLayer.create( tech, 'METAL2', metal2 )
|
||||
VIA12 = ViaLayer .create( tech, 'VIA12' , metal1, cut1, metal2 )
|
||||
print( 'nWell={}'.format(nWell) )
|
||||
print( 'pWell={}'.format(pWell) )
|
||||
print( dir(nWell) )
|
||||
print( 'Technology.getLayers():' )
|
||||
flush()
|
||||
for layer in tech.getLayers():
|
||||
flush()
|
||||
print( '| basicLayer={}'.format(layer) )
|
||||
flush()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
testDbU()
|
||||
cfg_setup()
|
||||
testPoint()
|
||||
testBox()
|
||||
testDB()
|
||||
testTechnology()
|
||||
testLayerMask()
|
||||
testBasicLayer()
|
||||
sys.exit( 0 )
|
Loading…
Reference in New Issue