Exported Layer::getTopEnclosure() in Python interface.

This commit is contained in:
Jean-Paul Chaput 2020-11-14 18:51:41 +01:00
parent e4d821e5b6
commit a4eb811bcb
3 changed files with 111 additions and 66 deletions

View File

@ -707,6 +707,7 @@ extern "C" {
__cs.addType( "inst" , &PyTypeInstance , "<Instance>" , false, "ent" ); __cs.addType( "inst" , &PyTypeInstance , "<Instance>" , false, "ent" );
__cs.addType( "instCol" , &PyTypeInstanceCollection , "<InstanceCollection>" , false ); __cs.addType( "instCol" , &PyTypeInstanceCollection , "<InstanceCollection>" , false );
__cs.addType( "mat" , &PyTypeMaterial , "<Material>" , false ); __cs.addType( "mat" , &PyTypeMaterial , "<Material>" , false );
__cs.addType( "layer" , &PyTypeLayer , "<Layer>" , false );
__cs.addType( "basicLayer" , &PyTypeBasicLayer , "<BasicLayer>" , false, "layer" ); __cs.addType( "basicLayer" , &PyTypeBasicLayer , "<BasicLayer>" , false, "layer" );
__cs.addType( "regLayer" , &PyTypeRegularLayer , "<RegularLayer>" , false, "layer" ); __cs.addType( "regLayer" , &PyTypeRegularLayer , "<RegularLayer>" , false, "layer" );
__cs.addType( "contLayer" , &PyTypeContactLayer , "<ContactLayer>" , false, "layer" ); __cs.addType( "contLayer" , &PyTypeContactLayer , "<ContactLayer>" , false, "layer" );
@ -717,7 +718,6 @@ extern "C" {
__cs.addType( "blayerColl" , &PyTypeBasicLayerCollection , "<BasicLayerCollection>" , false ); __cs.addType( "blayerColl" , &PyTypeBasicLayerCollection , "<BasicLayerCollection>" , false );
__cs.addType( "rlayerColl" , &PyTypeRegularLayerCollection, "<RegularLayerCollection>", false ); __cs.addType( "rlayerColl" , &PyTypeRegularLayerCollection, "<RegularLayerCollection>", false );
__cs.addType( "vlayerColl" , &PyTypeViaLayerCollection , "<ViaLayerCollection>" , false ); __cs.addType( "vlayerColl" , &PyTypeViaLayerCollection , "<ViaLayerCollection>" , false );
__cs.addType( "layer" , &PyTypeLayer , "<Layer>" , false );
__cs.addType( "lmask" , &PyTypeLayerMask , "<Layer::Mask>" , false ); __cs.addType( "lmask" , &PyTypeLayerMask , "<Layer::Mask>" , false );
__cs.addType( "library" , &PyTypeLibrary , "<Library>" , false ); __cs.addType( "library" , &PyTypeLibrary , "<Library>" , false );
__cs.addType( "ref" , &PyTypeReference , "<Reference>" , false, "ent" ); __cs.addType( "ref" , &PyTypeReference , "<Reference>" , false, "ent" );

View File

@ -133,32 +133,73 @@ extern "C" {
static PyObject* PY_SELF_TYPE##_##FUNC_NAME ( PY_SELF_TYPE* self, PyObject* args ) \ static PyObject* PY_SELF_TYPE##_##FUNC_NAME ( PY_SELF_TYPE* self, PyObject* args ) \
{ \ { \
cdebug_log(20,0) << #PY_SELF_TYPE "_" #FUNC_NAME "()" << endl; \ cdebug_log(20,0) << #PY_SELF_TYPE "_" #FUNC_NAME "()" << endl; \
\
Layer* rlayer = NULL; \ Layer* rlayer = NULL; \
\ \
HTRY \ HTRY \
GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#SELF_TYPE"."#FUNC_NAME"()") \ GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#SELF_TYPE"."#FUNC_NAME"()") \
\
PyObject* arg0 = NULL; \ PyObject* arg0 = NULL; \
bool useSymbolic = true; \ bool useSymbolic = true; \
\ \
if (PyArg_ParseTuple( args, "|O:"#SELF_TYPE"."#FUNC_NAME"()", &arg0)) { \ if (PyArg_ParseTuple( args, "|O:"#SELF_TYPE"."#FUNC_NAME"()", &arg0)) { \
if (arg0 != NULL) { \ if (arg0) useSymbolic = PyObject_IsTrue(arg0); \
useSymbolic = PyObject_IsTrue(arg0); \
} \
} else { \ } else { \
PyErr_SetString( ConstructorError \ PyErr_SetString( ConstructorError \
, "Invalid number of parameters passed to "#SELF_TYPE"."#FUNC_NAME"()." ); \ , #SELF_TYPE"."#FUNC_NAME"(): Takes exactly one boolean parameter." ); \
return NULL; \ return NULL; \
} \ } \
rlayer = const_cast<SELF_TYPE*>( cobject->FUNC_NAME(useSymbolic) ); \ rlayer = const_cast<SELF_TYPE*>( cobject->FUNC_NAME(useSymbolic) ); \
HCATCH \ HCATCH \
\ \
if (rlayer == NULL) Py_RETURN_NONE; \ if (not rlayer) Py_RETURN_NONE; \
return PyLayer_LinkDerived(rlayer); \ return PyLayer_LinkDerived(rlayer); \
} }
# define accessorLayerFromUInt(FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \
static PyObject* PY_SELF_TYPE##_##FUNC_NAME ( PY_SELF_TYPE* self, PyObject* args ) \
{ \
cdebug_log(20,0) << #PY_SELF_TYPE "_" #FUNC_NAME "()" << endl; \
Layer* rlayer = NULL; \
\
HTRY \
GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#SELF_TYPE"."#FUNC_NAME"()") \
unsigned int flags = 0; \
\
if (not PyArg_ParseTuple( args, "I:"#SELF_TYPE"."#FUNC_NAME"()", &flags)) { \
PyErr_SetString( ConstructorError \
, #SELF_TYPE"."#FUNC_NAME"(): Takes exactly one integer parameter." ); \
return NULL; \
} \
rlayer = const_cast<SELF_TYPE*>( cobject->FUNC_NAME(uint32_t(flags)) ); \
HCATCH \
\
if (not rlayer) Py_RETURN_NONE; \
return PyLayer_LinkDerived(rlayer); \
}
# define accessorDbuFromUInt(FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \
static PyObject* PY_SELF_TYPE##_##FUNC_NAME ( PY_SELF_TYPE* self, PyObject* args ) \
{ \
cdebug_log(20,0) << #PY_SELF_TYPE "_" #FUNC_NAME "()" << endl; \
DbU::Unit u = 0; \
\
HTRY \
GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#SELF_TYPE"."#FUNC_NAME"()") \
unsigned int flags = 0; \
\
if (not PyArg_ParseTuple( args, "I:"#SELF_TYPE"."#FUNC_NAME"()", &flags)) { \
PyErr_SetString( ConstructorError \
, #SELF_TYPE"."#FUNC_NAME"(): Takes exactly one integer parameter." ); \
return NULL; \
} \
u = cobject->FUNC_NAME( uint32_t(flags) ); \
HCATCH \
\
return PyDbU_FromLong(u); \
}
# define predicateFromVoid(FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ # define predicateFromVoid(FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \
static PyObject* PY_SELF_TYPE##_##FUNC_NAME ( PY_SELF_TYPE* self ) \ static PyObject* PY_SELF_TYPE##_##FUNC_NAME ( PY_SELF_TYPE* self ) \
{ \ { \
@ -329,6 +370,8 @@ extern "C" {
accessorLayerFromOptBool ( getMetalBelow ,PyLayer,Layer) accessorLayerFromOptBool ( getMetalBelow ,PyLayer,Layer)
accessorLayerFromOptBool ( getCutAbove ,PyLayer,Layer) accessorLayerFromOptBool ( getCutAbove ,PyLayer,Layer)
accessorLayerFromOptBool ( getCutBelow ,PyLayer,Layer) accessorLayerFromOptBool ( getCutBelow ,PyLayer,Layer)
accessorDbuFromUInt ( getTopEnclosure ,PyLayer,Layer)
accessorDbuFromUInt ( getBottomEnclosure,PyLayer,Layer)
DirectGetLongAttribute (PyLayer_getMinimalSize ,getMinimalSize ,PyLayer,Layer) DirectGetLongAttribute (PyLayer_getMinimalSize ,getMinimalSize ,PyLayer,Layer)
DirectGetLongAttribute (PyLayer_getMinimalSpacing,getMinimalSpacing ,PyLayer,Layer) DirectGetLongAttribute (PyLayer_getMinimalSpacing,getMinimalSpacing ,PyLayer,Layer)
@ -379,6 +422,10 @@ extern "C" {
, "Returns the cut layer below this one." } , "Returns the cut layer below this one." }
, { "getEnclosure" , (PyCFunction)PyLayer_getEnclosure , METH_VARARGS , { "getEnclosure" , (PyCFunction)PyLayer_getEnclosure , METH_VARARGS
, "Returns the enclosure (global or for one BasicLayer)." } , "Returns the enclosure (global or for one BasicLayer)." }
, { "getTopEnclosure" , (PyCFunction)PyLayer_getTopEnclosure , METH_VARARGS
, "Returns the top layer enclosure." }
, { "getBottomEnclosure" , (PyCFunction)PyLayer_getBottomEnclosure , METH_VARARGS
, "Returns the bottom layer enclosure." }
, { "getExtentionCap" , (PyCFunction)PyLayer_getExtentionCap , METH_VARARGS , { "getExtentionCap" , (PyCFunction)PyLayer_getExtentionCap , METH_VARARGS
, "Returns the extention cap (global or for one BasicLayer)." } , "Returns the extention cap (global or for one BasicLayer)." }
, { "getExtentionWidth" , (PyCFunction)PyLayer_getExtentionWidth , METH_VARARGS , { "getExtentionWidth" , (PyCFunction)PyLayer_getExtentionWidth , METH_VARARGS

View File

@ -289,22 +289,20 @@ extern "C" {
\ \
HTRY \ HTRY \
GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#SELF_TYPE"."#FUNC_NAME"()") \ GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#SELF_TYPE"."#FUNC_NAME"()") \
\
PyObject* arg0 = NULL; \ PyObject* arg0 = NULL; \
bool rvalue = false; \ bool rvalue = false; \
\
__cs.init (#SELF_TYPE"."#FUNC_NAME"()"); \ __cs.init (#SELF_TYPE"."#FUNC_NAME"()"); \
if (PyArg_ParseTuple( args, "O&:"#SELF_TYPE"."#FUNC_NAME"()", Converter, &arg0)) { \ if (PyArg_ParseTuple( args, "O&:"#SELF_TYPE"."#FUNC_NAME"()", Converter, &arg0)) { \
if (__cs.getObjectIds() == ":layer") \ if (__cs.getObjectIds() == ":layer") \
rvalue = cobject->FUNC_NAME( PYLAYER_O(arg0) ); \ rvalue = cobject->FUNC_NAME( PYLAYER_O(arg0) ); \
else { \ else { \
PyErr_SetString ( ConstructorError \ PyErr_SetString ( ConstructorError \
, "invalid parameter type for "#SELF_TYPE"."#FUNC_NAME"()." ); \ , #SELF_TYPE"."#FUNC_NAME"(): The sole parameter is not a Layer." ); \
return NULL; \ return NULL; \
} \ } \
} else { \ } else { \
PyErr_SetString ( ConstructorError \ PyErr_SetString ( ConstructorError \
, "Invalid number of parameters passed to "#SELF_TYPE"."#FUNC_NAME"()." ); \ , #SELF_TYPE"."#FUNC_NAME"(): Takes only *one* Layer parameter. " ); \
return NULL; \ return NULL; \
} \ } \
if (rvalue) Py_RETURN_TRUE; \ if (rvalue) Py_RETURN_TRUE; \