diff --git a/crlcore/python/helpers/__init__.py b/crlcore/python/helpers/__init__.py index 02c8d83d..77841a72 100644 --- a/crlcore/python/helpers/__init__.py +++ b/crlcore/python/helpers/__init__.py @@ -8,7 +8,7 @@ # | C o r i o l i s / C h a m s B u i l d e r | # | | # | Author : Jean-Paul Chaput | -# | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +# | E-mail : Jean-Paul.Chaput@lip6.fr | # | =============================================================== | # | Python : "./crlcore/__init__.py" | # +-----------------------------------------------------------------+ diff --git a/crlcore/src/pyCRL/PyBanner.cpp b/crlcore/src/pyCRL/PyBanner.cpp index 6dd4a796..98e1bec1 100644 --- a/crlcore/src/pyCRL/PyBanner.cpp +++ b/crlcore/src/pyCRL/PyBanner.cpp @@ -129,13 +129,13 @@ extern "C" { DirectGetUIntAttribute (PyBanner_getScreenWidth ,getScreenWidth ,PyBanner,Banner) // Standart Mutators (Attributes). - DirectSetCStringAttribute(PyBanner_setName ,setName ,"Banner.setName" ,PyBanner,Banner) - DirectSetCStringAttribute(PyBanner_setVersion ,setVersion ,"Banner.setVersion" ,PyBanner,Banner) - DirectSetCStringAttribute(PyBanner_setPurpose ,setPurpose ,"Banner.setPurpose" ,PyBanner,Banner) - DirectSetCStringAttribute(PyBanner_setDate ,setDate ,"Banner.setDate" ,PyBanner,Banner) - DirectSetCStringAttribute(PyBanner_setContributors,setContributors,"Banner.setContributors",PyBanner,Banner) - DirectSetCStringAttribute(PyBanner_setAuthors ,setAuthors ,"Banner.setAuthors" ,PyBanner,Banner) - DirectSetLongAttribute (PyBanner_setScreenWidth ,setScreenWidth ,"Banner.setScreenWidth" ,PyBanner,Banner) + DirectSetCStringAttribute(PyBanner_setName ,setName ,PyBanner,Banner) + DirectSetCStringAttribute(PyBanner_setVersion ,setVersion ,PyBanner,Banner) + DirectSetCStringAttribute(PyBanner_setPurpose ,setPurpose ,PyBanner,Banner) + DirectSetCStringAttribute(PyBanner_setDate ,setDate ,PyBanner,Banner) + DirectSetCStringAttribute(PyBanner_setContributors,setContributors,PyBanner,Banner) + DirectSetCStringAttribute(PyBanner_setAuthors ,setAuthors ,PyBanner,Banner) + DirectSetLongAttribute (PyBanner_setScreenWidth ,setScreenWidth ,PyBanner,Banner) // Standart Destroy (Attribute). diff --git a/crlcore/src/pyCRL/PyCatalogState.cpp b/crlcore/src/pyCRL/PyCatalogState.cpp index 6ac01a37..346e4153 100644 --- a/crlcore/src/pyCRL/PyCatalogState.cpp +++ b/crlcore/src/pyCRL/PyCatalogState.cpp @@ -66,12 +66,12 @@ extern "C" { DirectGetBoolAttribute(PyCatalogState_isPhysical ,isPhysical ,PyCatalogState,Catalog::State) DirectGetBoolAttribute(PyCatalogState_isLogical ,isFlattenLeaf,PyCatalogState,Catalog::State) - DirectSetBoolAttribute(PyCatalogState_setFlattenLeaf,setFlattenLeaf,"Catalog::State::setFlatenLeaf",PyCatalogState,Catalog::State) - DirectSetBoolAttribute(PyCatalogState_setFeed ,setFeed ,"Catalog::State::setFeed" ,PyCatalogState,Catalog::State) - DirectSetBoolAttribute(PyCatalogState_setGds ,setGds ,"Catalog::State::setGds" ,PyCatalogState,Catalog::State) - DirectSetBoolAttribute(PyCatalogState_setDelete ,setDelete ,"Catalog::State::setDelete" ,PyCatalogState,Catalog::State) - DirectSetBoolAttribute(PyCatalogState_setPhysical ,setPhysical ,"Catalog::State::setPhysical" ,PyCatalogState,Catalog::State) - DirectSetBoolAttribute(PyCatalogState_setLogical ,setFlattenLeaf,"Catalog::State::setLogical" ,PyCatalogState,Catalog::State) + DirectSetBoolAttribute(PyCatalogState_setFlattenLeaf,setFlattenLeaf,PyCatalogState,Catalog::State) + DirectSetBoolAttribute(PyCatalogState_setFeed ,setFeed ,PyCatalogState,Catalog::State) + DirectSetBoolAttribute(PyCatalogState_setGds ,setGds ,PyCatalogState,Catalog::State) + DirectSetBoolAttribute(PyCatalogState_setDelete ,setDelete ,PyCatalogState,Catalog::State) + DirectSetBoolAttribute(PyCatalogState_setPhysical ,setPhysical ,PyCatalogState,Catalog::State) + DirectSetBoolAttribute(PyCatalogState_setLogical ,setFlattenLeaf,PyCatalogState,Catalog::State) // Standart Destroy (Attribute). diff --git a/crlcore/src/pyCRL/PyEnvironment.cpp b/crlcore/src/pyCRL/PyEnvironment.cpp index de41ae4d..91964b4c 100644 --- a/crlcore/src/pyCRL/PyEnvironment.cpp +++ b/crlcore/src/pyCRL/PyEnvironment.cpp @@ -166,19 +166,19 @@ extern "C" { DirectIsAFromCStringAttribute(PyEnvironment_isPad ,isPad ,PyEnvironment,Environment) // Standart Mutators (Attributes). - DirectSetCStringAttribute(PyEnvironment_setDisplayStyle ,setDisplayStyle ,"Environment.setDisplayStyle" ,PyEnvironment,Environment) - DirectSetLongAttribute (PyEnvironment_setSCALE_X ,setSCALE_X ,"Environment.setSCALE_X" ,PyEnvironment,Environment) - DirectSetCStringAttribute(PyEnvironment_setIN_LO ,setIN_LO ,"Environment.setIN_LO" ,PyEnvironment,Environment) - DirectSetCStringAttribute(PyEnvironment_setIN_PH ,setIN_PH ,"Environment.setIN_PH" ,PyEnvironment,Environment) - DirectSetCStringAttribute(PyEnvironment_setOUT_LO ,setOUT_LO ,"Environment.setOUT_LO" ,PyEnvironment,Environment) - DirectSetCStringAttribute(PyEnvironment_setOUT_PH ,setOUT_PH ,"Environment.setOUT_PH" ,PyEnvironment,Environment) - DirectSetCStringAttribute(PyEnvironment_setPOWER ,setPOWER ,"Environment.setPOWER" ,PyEnvironment,Environment) - DirectSetCStringAttribute(PyEnvironment_setGROUND ,setGROUND ,"Environment.setGROUND" ,PyEnvironment,Environment) - DirectSetCStringAttribute(PyEnvironment_setCLOCK ,setCLOCK ,"Environment.setCLOCK" ,PyEnvironment,Environment) - DirectSetCStringAttribute(PyEnvironment_setBLOCKAGE ,setBLOCKAGE ,"Environment.setBLOCKAGE" ,PyEnvironment,Environment) - DirectSetCStringAttribute(PyEnvironment_setPad ,setPad ,"Environment.setPad" ,PyEnvironment,Environment) - DirectSetCStringAttribute(PyEnvironment_setCATALOG ,setCATALOG ,"Environment.setCATALOG" ,PyEnvironment,Environment) - DirectSetCStringAttribute(PyEnvironment_setWORKING_LIBRARY ,setWORKING_LIBRARY ,"Environment.setWORKING_LIBRARY" ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setDisplayStyle ,setDisplayStyle ,PyEnvironment,Environment) + DirectSetLongAttribute (PyEnvironment_setSCALE_X ,setSCALE_X ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setIN_LO ,setIN_LO ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setIN_PH ,setIN_PH ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setOUT_LO ,setOUT_LO ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setOUT_PH ,setOUT_PH ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setPOWER ,setPOWER ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setGROUND ,setGROUND ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setCLOCK ,setCLOCK ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setBLOCKAGE ,setBLOCKAGE ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setPad ,setPad ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setCATALOG ,setCATALOG ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setWORKING_LIBRARY,setWORKING_LIBRARY,PyEnvironment,Environment) // Standart Destroy (Attribute). diff --git a/hurricane/src/isobar/PyBasicLayer.cpp b/hurricane/src/isobar/PyBasicLayer.cpp index 4a4235de..76315cf1 100644 --- a/hurricane/src/isobar/PyBasicLayer.cpp +++ b/hurricane/src/isobar/PyBasicLayer.cpp @@ -110,8 +110,8 @@ extern "C" { updatorFromBasicLayer (setBlockageLayer,PyBasicLayer,BasicLayer) accessorLayerFromVoid (getBlockageLayer,PyBasicLayer,BasicLayer) - DirectSetLongAttribute (PyBasicLayer_setExtractNumber,setExtractNumber,"BasicLayer.setExtractNumber",PyBasicLayer,BasicLayer) - DirectSetCStringAttribute(PyBasicLayer_setRealName ,setRealName ,"BasicLayer.setRealName" ,PyBasicLayer,BasicLayer) + DirectSetLongAttribute (PyBasicLayer_setExtractNumber,setExtractNumber,PyBasicLayer,BasicLayer) + DirectSetCStringAttribute(PyBasicLayer_setRealName ,setRealName ,PyBasicLayer,BasicLayer) // Standart destroy (Attribute). diff --git a/hurricane/src/isobar/PyContact.cpp b/hurricane/src/isobar/PyContact.cpp index c266bcdf..bbe2849d 100644 --- a/hurricane/src/isobar/PyContact.cpp +++ b/hurricane/src/isobar/PyContact.cpp @@ -52,12 +52,12 @@ extern "C" { DirectGetLongAttribute(PyContact_getDx, getDx, PyContact,Contact) DirectGetLongAttribute(PyContact_getDy, getDy, PyContact,Contact) - DirectSetLongAttribute(PyContact_setX ,setX ,"Contact.setX" ,PyContact,Contact) - DirectSetLongAttribute(PyContact_setY ,setY ,"Contact.setY" ,PyContact,Contact) - DirectSetLongAttribute(PyContact_setDx ,setDx ,"Contact.setDx" ,PyContact,Contact) - DirectSetLongAttribute(PyContact_setDy ,setDy ,"Contact.setDy" ,PyContact,Contact) - DirectSetLongAttribute(PyContact_setWidth ,setWidth ,"Contact.setWidth" ,PyContact,Contact) - DirectSetLongAttribute(PyContact_setHeight,setHeight,"Contact.setHeight",PyContact,Contact) + DirectSetLongAttribute(PyContact_setX ,setX ,PyContact,Contact) + DirectSetLongAttribute(PyContact_setY ,setY ,PyContact,Contact) + DirectSetLongAttribute(PyContact_setDx ,setDx ,PyContact,Contact) + DirectSetLongAttribute(PyContact_setDy ,setDy ,PyContact,Contact) + DirectSetLongAttribute(PyContact_setWidth ,setWidth ,PyContact,Contact) + DirectSetLongAttribute(PyContact_setHeight,setHeight,PyContact,Contact) accessorHook(getAnchorHook,PyContact,Contact) diff --git a/hurricane/src/isobar/PyHorizontal.cpp b/hurricane/src/isobar/PyHorizontal.cpp index 37245ed6..608e88e5 100644 --- a/hurricane/src/isobar/PyHorizontal.cpp +++ b/hurricane/src/isobar/PyHorizontal.cpp @@ -49,9 +49,9 @@ extern "C" { DirectGetLongAttribute(PyHorizontal_getY ,getY ,PyHorizontal,Horizontal) DirectGetLongAttribute(PyHorizontal_getDxSource,getDxSource,PyHorizontal,Horizontal) DirectGetLongAttribute(PyHorizontal_getDxTarget,getDxTarget,PyHorizontal,Horizontal) - DirectSetLongAttribute(PyHorizontal_setY ,setY ,"Horizontal.setY",PyHorizontal,Horizontal) - DirectSetLongAttribute(PyHorizontal_setDxSource,setDxSource,"Horizontal.setDxSource",PyHorizontal,Horizontal) - DirectSetLongAttribute(PyHorizontal_setDxTarget,setDxTarget,"Horizontal.setDxTarget",PyHorizontal,Horizontal) + DirectSetLongAttribute(PyHorizontal_setY ,setY ,PyHorizontal,Horizontal) + DirectSetLongAttribute(PyHorizontal_setDxSource,setDxSource,PyHorizontal,Horizontal) + DirectSetLongAttribute(PyHorizontal_setDxTarget,setDxTarget,PyHorizontal,Horizontal) // Standart destroy (Attribute). DBoDestroyAttribute(PyHorizontal_destroy, PyHorizontal) diff --git a/hurricane/src/isobar/PyHurricane.cpp b/hurricane/src/isobar/PyHurricane.cpp index 46a338ef..8d8acef9 100644 --- a/hurricane/src/isobar/PyHurricane.cpp +++ b/hurricane/src/isobar/PyHurricane.cpp @@ -129,6 +129,16 @@ using namespace Hurricane; // +-----------------------------------------------------------------+ + int PyAny_AsInt ( PyObject* object ) + { + long value = 0; + + if (PyObject_IsInstance(object,(PyObject*)&PyInt_Type )) value = PyInt_AsLong ( object ); + else if (PyObject_IsInstance(object,(PyObject*)&PyLong_Type)) value = PyLong_AsLong( object ); + return (int)value; + } + + long PyAny_AsLong ( PyObject* object ) { long value = 0; diff --git a/hurricane/src/isobar/PyInstance.cpp b/hurricane/src/isobar/PyInstance.cpp index f0f1b172..548f9325 100644 --- a/hurricane/src/isobar/PyInstance.cpp +++ b/hurricane/src/isobar/PyInstance.cpp @@ -73,45 +73,45 @@ extern "C" { static PyObject* PyInstance_create ( PyObject*, PyObject *args ) { - trace << "PyInstance_create ()" << endl; + trace << "PyInstance_create()" << endl; Instance* instance = NULL; - PyObject* arg0; - PyObject* arg1; - PyObject* arg2; - PyObject* arg3; + PyObject* arg0 = NULL; + PyObject* arg1 = NULL; + PyObject* arg2 = NULL; + PyObject* arg3 = NULL; HTRY - __cs.init ("Instance.create"); - if ( ! PyArg_ParseTuple(args,"O&O&O&|O&:Instance.new" - ,Converter,&arg0 - ,Converter,&arg1 - ,Converter,&arg2 - ,Converter,&arg3 - )) { - PyErr_SetString ( ConstructorError, "invalid number of parameters for Instance constructor." ); + __cs.init( "Instance.create" ); + if (not PyArg_ParseTuple(args,"O&O&O&|O&:Instance.create" + ,Converter,&arg0 + ,Converter,&arg1 + ,Converter,&arg2 + ,Converter,&arg3 + )) { + PyErr_SetString( ConstructorError, "Instance.create(): Invalid number of parameters." ); return NULL; } - if ( __cs.getObjectIds() == ":ent:string:ent") { - instance = Instance::create( - PYCELL_O(arg0), - Name(PyString_AsString(arg1)), - PYCELL_O(arg2) ); - } else if ( __cs.getObjectIds() == ":ent:string:ent:transfo") { - instance = Instance::create( - PYCELL_O(arg0), - Name(PyString_AsString(arg1)), - PYCELL_O(arg2), - *PYTRANSFORMATION_O(arg3), - Instance::PlacementStatus::PLACED); + if (__cs.getObjectIds() == ":ent:string:ent") { + instance = Instance::create( PYCELL_O(arg0) + , Name(PyString_AsString(arg1)) + , PYCELL_O(arg2) + ); + } else if (__cs.getObjectIds() == ":ent:string:ent:transfo") { + instance = Instance::create( PYCELL_O(arg0) + , Name(PyString_AsString(arg1)) + , PYCELL_O(arg2) + , *PYTRANSFORMATION_O(arg3) + , Instance::PlacementStatus::PLACED + ); } else { - PyErr_SetString ( ConstructorError, "invalid number of parameters for Instance constructor." ); + PyErr_SetString( ConstructorError, "Instance.create(): Bad type of parameter(s)." ); return NULL; } HCATCH - return PyInstance_Link ( instance ); + return PyInstance_Link( instance ); } diff --git a/hurricane/src/isobar/PyLibrary.cpp b/hurricane/src/isobar/PyLibrary.cpp index fc90f92a..e45ae5a0 100644 --- a/hurricane/src/isobar/PyLibrary.cpp +++ b/hurricane/src/isobar/PyLibrary.cpp @@ -135,7 +135,7 @@ extern "C" { PyMethodDef PyLibrary_Methods[] = - { { "create" , (PyCFunction)PyLibrary_create , METH_NOARGS|METH_STATIC + { { "create" , (PyCFunction)PyLibrary_create , METH_VARARGS|METH_STATIC , "Creates a new library." } , { "getName" , (PyCFunction)PyLibrary_getName , METH_NOARGS , "Returns the name of the library." } , { "getLibrary", (PyCFunction)PyLibrary_getSubLibrary, METH_VARARGS, "Get the sub-library named " } diff --git a/hurricane/src/isobar/PyPoint.cpp b/hurricane/src/isobar/PyPoint.cpp index 75ab63c4..ec9247d5 100644 --- a/hurricane/src/isobar/PyPoint.cpp +++ b/hurricane/src/isobar/PyPoint.cpp @@ -114,8 +114,8 @@ extern "C" { // Standart Accessors (Attributes). DirectGetLongAttribute(PyPoint_getX,getX,PyPoint,Point) DirectGetLongAttribute(PyPoint_getY,getY,PyPoint,Point) - DirectSetLongAttribute(PyPoint_SetX,setX,"Point.setX",PyPoint,Point) - DirectSetLongAttribute(PyPoint_SetY,setY,"Point.setY",PyPoint,Point) + DirectSetLongAttribute(PyPoint_SetX,setX,PyPoint,Point) + DirectSetLongAttribute(PyPoint_SetY,setY,PyPoint,Point) // Standart destroy (Attribute). diff --git a/hurricane/src/isobar/PyRoutingPad.cpp b/hurricane/src/isobar/PyRoutingPad.cpp index ec96eae7..149deba9 100644 --- a/hurricane/src/isobar/PyRoutingPad.cpp +++ b/hurricane/src/isobar/PyRoutingPad.cpp @@ -53,8 +53,8 @@ extern "C" { DirectGetLongAttribute(PyRoutingPad_getSourceY ,getSourceY ,PyRoutingPad,RoutingPad) DirectGetLongAttribute(PyRoutingPad_getTargetX ,getTargetX ,PyRoutingPad,RoutingPad) DirectGetLongAttribute(PyRoutingPad_getTargetY ,getTargetY ,PyRoutingPad,RoutingPad) - // DirectSetLongAttribute(PyRoutingPad_setX ,setX ,"RoutingPad.setX",PyRoutingPad,RoutingPad) - // DirectSetLongAttribute(PyRoutingPad_setY ,setY ,"RoutingPad.setY",PyRoutingPad,RoutingPad) + //DirectSetLongAttribute(PyRoutingPad_setX ,setX ,PyRoutingPad,RoutingPad) + //DirectSetLongAttribute(PyRoutingPad_setY ,setY ,PyRoutingPad,RoutingPad) // Standart destroy (Attribute). DBoDestroyAttribute(PyRoutingPad_destroy, PyRoutingPad) diff --git a/hurricane/src/isobar/PySegment.cpp b/hurricane/src/isobar/PySegment.cpp index 8823d1fd..35640742 100644 --- a/hurricane/src/isobar/PySegment.cpp +++ b/hurricane/src/isobar/PySegment.cpp @@ -55,7 +55,7 @@ extern "C" { DirectGetLongAttribute(PySegment_getTargetX,getTargetX,PySegment,Segment) DirectGetLongAttribute(PySegment_getTargetY,getTargetY,PySegment,Segment) DirectGetLongAttribute(PySegment_getWidth ,getWidth ,PySegment,Segment) - DirectSetLongAttribute(PySegment_setWidth ,setWidth ,"Segment.setWidth",PySegment,Segment) + DirectSetLongAttribute(PySegment_setWidth ,setWidth ,PySegment,Segment) DirectVoidMethod(Segment,segment,invert) accessorHook(getSourceHook,PySegment,Segment) accessorHook(getTargetHook,PySegment,Segment) diff --git a/hurricane/src/isobar/PyVertical.cpp b/hurricane/src/isobar/PyVertical.cpp index f5bfc9e7..08e6207b 100644 --- a/hurricane/src/isobar/PyVertical.cpp +++ b/hurricane/src/isobar/PyVertical.cpp @@ -47,9 +47,9 @@ extern "C" { DirectGetLongAttribute(PyVertical_getX ,getX ,PyVertical,Vertical) DirectGetLongAttribute(PyVertical_getDySource,getDySource,PyVertical,Vertical) DirectGetLongAttribute(PyVertical_getDyTarget,getDyTarget,PyVertical,Vertical) - DirectSetLongAttribute(PyVertical_setX,setX,"Vertical.setX",PyVertical,Vertical) - DirectSetLongAttribute(PyVertical_setDySource,setDySource,"Vertical.setDySource",PyVertical,Vertical) - DirectSetLongAttribute(PyVertical_setDyTarget,setDyTarget,"Vertical.setDyTarget",PyVertical,Vertical) + DirectSetLongAttribute(PyVertical_setX ,setX ,PyVertical,Vertical) + DirectSetLongAttribute(PyVertical_setDySource,setDySource,PyVertical,Vertical) + DirectSetLongAttribute(PyVertical_setDyTarget,setDyTarget,PyVertical,Vertical) // Standard destroy (Attribute). DBoDestroyAttribute(PyVertical_destroy, PyVertical) diff --git a/hurricane/src/isobar/hurricane/isobar/PyHurricane.h b/hurricane/src/isobar/hurricane/isobar/PyHurricane.h index 90c71963..852ef463 100644 --- a/hurricane/src/isobar/hurricane/isobar/PyHurricane.h +++ b/hurricane/src/isobar/hurricane/isobar/PyHurricane.h @@ -107,6 +107,7 @@ using namespace std; extern ConverterState __cs; extern int __objectOffset; + int PyAny_AsInt ( PyObject* object ); long PyAny_AsLong ( PyObject* object ); @@ -257,7 +258,7 @@ extern "C" { # define DirectGetBoolAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* args ) \ { \ - GENERIC_METHOD_HEAD(SELF_TYPE,cobject,"DirectGetBoolAttribute()") \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME"()") \ if (cobject->FUNC_NAME()) \ Py_RETURN_TRUE; \ Py_RETURN_FALSE; \ @@ -272,7 +273,7 @@ extern "C" { # define DirectIsAFromCStringAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* args ) \ { \ - GENERIC_METHOD_HEAD(SELF_TYPE,cobject,"DirectIsAFromCStringAttribute()") \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME"()") \ HTRY \ char* value = NULL; \ if ( !PyArg_ParseTuple(args, "s:", &value) ) \ @@ -287,13 +288,13 @@ extern "C" { // ------------------------------------------------------------------- -// Attribute Method Macro For Long. +// Attribute Method Macro For Int. -# define DirectGetLongAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ +# define DirectGetIntAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* args ) \ { \ - GENERIC_METHOD_HEAD(SELF_TYPE,cobject,"DirectGetLongAttribute()") \ - return ( PyLong_FromLong(cobject->FUNC_NAME()) ); \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME"()") \ + return Py_BuildValue("i", cobject->FUNC_NAME()); \ } @@ -303,8 +304,19 @@ extern "C" { # define DirectGetUIntAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* args ) \ { \ - GENERIC_METHOD_HEAD(SELF_TYPE,cobject,"DirectGetUIntAttribute()") \ - return ( Py_BuildValue ("I",cobject->FUNC_NAME()) ); \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME"()") \ + return Py_BuildValue ("I",cobject->FUNC_NAME()); \ + } + + +// ------------------------------------------------------------------- +// Attribute Method Macro For Long. + +# define DirectGetLongAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ + static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* args ) \ + { \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME"()") \ + return Py_BuildValue("l", cobject->FUNC_NAME()); \ } @@ -314,8 +326,8 @@ extern "C" { # define DirectGetDoubleAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* args ) \ { \ - GENERIC_METHOD_HEAD(SELF_TYPE,cobject,"DirectGetDoubleAttribute()") \ - return ( Py_BuildValue ("d",cobject->FUNC_NAME()) ); \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME"()") \ + return Py_BuildValue ("d",cobject->FUNC_NAME()); \ } @@ -325,8 +337,19 @@ extern "C" { # define DirectGetStringAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self ) \ { \ - GENERIC_METHOD_HEAD(SELF_TYPE,cobject,"DirectGetStringAttribute()") \ - return ( Py_BuildValue ("s",cobject->FUNC_NAME().c_str()) ); \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME"()") \ + return Py_BuildValue ("s",cobject->FUNC_NAME().c_str()); \ + } + + +// ------------------------------------------------------------------- +// Attribute Method Macro For Name. + +# define DirectGetNameAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ + static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self ) \ + { \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME"()") \ + return Py_BuildValue ("s",getString(cobject->FUNC_NAME()).c_str()); \ } @@ -515,15 +538,17 @@ extern "C" { // ------------------------------------------------------------------- // Attribute Method Macro For Booleans. -#define DirectSetBoolAttribute(PY_FUNC_NAME,FUNC_NAME,STR_FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ +#define DirectSetBoolAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* args ) \ { \ - GENERIC_METHOD_HEAD(SELF_TYPE,cobject,STR_FUNC_NAME "()") \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME "()") \ \ HTRY \ PyObject* arg0; \ - if ( not PyArg_ParseTuple ( args, "O:" STR_FUNC_NAME, &arg0 ) or PyBool_Check(arg0) ) \ + if (not PyArg_ParseTuple( args, "O:" #FUNC_NAME, &arg0 ) or not PyBool_Check(arg0) ) { \ + PyErr_SetString(ConstructorError, #SELF_TYPE"."#FUNC_NAME"(): Argument is not a boolean."); \ return NULL; \ + } \ \ (PyObject_IsTrue(arg0)) ? cobject->FUNC_NAME (true) : cobject->FUNC_NAME (false); \ HCATCH \ @@ -533,35 +558,54 @@ extern "C" { // ------------------------------------------------------------------- -// Attribute Method Macro For Long. +// Attribute Method Macro For Int. -#define DirectSetLongAttribute(PY_FUNC_NAME,FUNC_NAME,PY_FORMAT,PY_SELF_TYPE,SELF_TYPE) \ +#define DirectSetIntAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* args ) \ { \ - GENERIC_METHOD_HEAD(SELF_TYPE,cobject,"DirectSetLongAttribute()") \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME"()") \ \ HTRY \ PyObject* arg0; \ - if ( ! PyArg_ParseTuple ( args, "O:" PY_FORMAT, &arg0 ) ) \ + if ( ! PyArg_ParseTuple ( args, "O:" #SELF_TYPE"."#FUNC_NAME"()", &arg0 ) ) \ return ( NULL ); \ - cobject->FUNC_NAME ( Isobar::PyAny_AsLong(arg0) ); \ + cobject->FUNC_NAME ( Isobar::PyAny_AsInt(arg0) ); \ HCATCH \ \ Py_RETURN_NONE; \ } +// ------------------------------------------------------------------- +// Attribute Method Macro For Long. + +#define DirectSetLongAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ + static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* args ) \ + { \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME"()") \ + \ + HTRY \ + PyObject* arg0; \ + if ( ! PyArg_ParseTuple ( args, "O:" #SELF_TYPE"."#FUNC_NAME"()", &arg0 ) ) \ + return ( NULL ); \ + cobject->FUNC_NAME ( Isobar::PyAny_AsLong(arg0) ); \ + HCATCH \ + \ + Py_RETURN_NONE; \ + } + + // ------------------------------------------------------------------- // Attribute Method Macro For Double. -#define DirectSetDoubleAttribute(PY_FUNC_NAME,FUNC_NAME,PY_FORMAT,PY_SELF_TYPE,SELF_TYPE) \ +#define DirectSetDoubleAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* args ) \ { \ - GENERIC_METHOD_HEAD(SELF_TYPE,cobject,"DirectSetDoubleAttribute()") \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME"()") \ \ HTRY \ PyObject* arg0; \ - if ( ! PyArg_ParseTuple ( args, "O:" PY_FORMAT, &arg0 ) ) \ + if ( ! PyArg_ParseTuple ( args, "O:" #SELF_TYPE"."#FUNC_NAME"()", &arg0 ) ) \ return ( NULL ); \ cobject->FUNC_NAME ( PyFloat_AsDouble(arg0) ); \ HCATCH \ @@ -573,14 +617,14 @@ extern "C" { // ------------------------------------------------------------------- // Attribute Method Macro For C String (char*). -#define DirectSetCStringAttribute(PY_FUNC_NAME,FUNC_NAME,PY_FORMAT,PY_SELF_TYPE,SELF_TYPE) \ +#define DirectSetCStringAttribute(PY_FUNC_NAME,FUNC_NAME,PY_SELF_TYPE,SELF_TYPE) \ static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* args ) \ { \ - GENERIC_METHOD_HEAD(SELF_TYPE,cobject,"DirectSetCStringAttribute()") \ + GENERIC_METHOD_HEAD(SELF_TYPE,cobject,#FUNC_NAME"()") \ \ HTRY \ char* value = NULL; \ - if ( !PyArg_ParseTuple(args, "s:" PY_FORMAT, &value) ) \ + if ( !PyArg_ParseTuple(args, "s:" #SELF_TYPE"."#FUNC_NAME"()", &value) ) \ return NULL; \ cobject->FUNC_NAME ( value ); \ HCATCH \ diff --git a/hurricane/src/viewer/PyHSVr.cpp b/hurricane/src/viewer/PyHSVr.cpp index ccb65e0e..f0a10393 100644 --- a/hurricane/src/viewer/PyHSVr.cpp +++ b/hurricane/src/viewer/PyHSVr.cpp @@ -95,9 +95,9 @@ extern "C" { DirectGetDoubleAttribute(PyHSVr_GetHue ,getHue ,PyHSVr,DisplayStyle::HSVr) DirectGetDoubleAttribute(PyHSVr_GetSaturation,getSaturation,PyHSVr,DisplayStyle::HSVr) DirectGetDoubleAttribute(PyHSVr_GetValue ,getValue ,PyHSVr,DisplayStyle::HSVr) - DirectSetDoubleAttribute(PyHSVr_SetHue ,setHue ,"HSVr.setHue" ,PyHSVr,DisplayStyle::HSVr) - DirectSetDoubleAttribute(PyHSVr_SetSaturation,setSaturation,"HSVr.setSaturation",PyHSVr,DisplayStyle::HSVr) - DirectSetDoubleAttribute(PyHSVr_SetValue ,setValue ,"HSVr.setValue" ,PyHSVr,DisplayStyle::HSVr) + DirectSetDoubleAttribute(PyHSVr_SetHue ,setHue ,PyHSVr,DisplayStyle::HSVr) + DirectSetDoubleAttribute(PyHSVr_SetSaturation,setSaturation,PyHSVr,DisplayStyle::HSVr) + DirectSetDoubleAttribute(PyHSVr_SetValue ,setValue ,PyHSVr,DisplayStyle::HSVr) // Standart Predicates (Attributes). DirectGetBoolAttribute(PyHSVr_IsId,isId,PyHSVr,DisplayStyle::HSVr)