From 61a58ff3d6c7b9497d8a87931b67561253549d4f Mon Sep 17 00:00:00 2001 From: Christophe Alexandre Date: Thu, 11 Dec 2008 12:25:02 +0000 Subject: [PATCH] * no more PyNames, in the Python part, names are replaced by simple strings and transformed in Names in the wrapper. * get rid of Converter in progress --- hurricane/src/isobar/CMakeLists.txt | 2 - hurricane/src/isobar/PyCell.cpp | 30 +--- hurricane/src/isobar/PyHorizontal.cpp | 130 ++------------ hurricane/src/isobar/PyHurricane.cpp | 6 - hurricane/src/isobar/PyInstance.cpp | 74 +------- hurricane/src/isobar/PyLayer.cpp | 75 +------- hurricane/src/isobar/PyLibrary.cpp | 20 +-- hurricane/src/isobar/PyName.cpp | 166 ------------------ hurricane/src/isobar/PyNet.cpp | 74 +++----- hurricane/src/isobar/PyOccurrence.cpp | 54 +----- hurricane/src/isobar/PyPath.cpp | 53 +----- hurricane/src/isobar/PyPin.cpp | 41 +---- hurricane/src/isobar/PyReference.cpp | 68 +------ hurricane/src/isobar/PyVertical.cpp | 126 ++----------- .../src/isobar/hurricane/isobar/PyHurricane.h | 101 +++-------- .../src/isobar/hurricane/isobar/PyName.h | 106 ----------- 16 files changed, 107 insertions(+), 1019 deletions(-) delete mode 100644 hurricane/src/isobar/PyName.cpp delete mode 100644 hurricane/src/isobar/hurricane/isobar/PyName.h diff --git a/hurricane/src/isobar/CMakeLists.txt b/hurricane/src/isobar/CMakeLists.txt index 92c4886b..6cf31417 100644 --- a/hurricane/src/isobar/CMakeLists.txt +++ b/hurricane/src/isobar/CMakeLists.txt @@ -19,7 +19,6 @@ PyInstanceCollection.cpp PyLayer.cpp PyLibrary.cpp - PyName.cpp PyNet.cpp PyNetCollection.cpp PyOccurrence.cpp @@ -58,7 +57,6 @@ hurricane/isobar/PyInstanceCollection.h hurricane/isobar/PyLayer.h hurricane/isobar/PyLibrary.h - hurricane/isobar/PyName.h hurricane/isobar/PyNet.h hurricane/isobar/PyNetCollection.h hurricane/isobar/PyOccurrence.h diff --git a/hurricane/src/isobar/PyCell.cpp b/hurricane/src/isobar/PyCell.cpp index be8fcfaa..40083653 100644 --- a/hurricane/src/isobar/PyCell.cpp +++ b/hurricane/src/isobar/PyCell.cpp @@ -80,17 +80,7 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyCell_getName ()" - static PyObject* PyCell_getName(PyCell *self) { - trace << "PyCell_getName ()" << endl; - - HTRY - METHOD_HEAD ( "Cell.getName()" ) - return PyString_FromString(getString(cell->getName()).c_str()); - HCATCH - - return NULL; - } - + GetNameMethod(Cell, cell) // --------------------------------------------------------------- // Attribute Method : "PyCell_getInstance ()" @@ -545,23 +535,7 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyCell_setName ()" - static PyObject* PyCell_setName ( PyCell *self, PyObject* args ) { - trace << "Cell.setName()" << endl; - - HTRY - METHOD_HEAD("Cell.setName()") - char* name = NULL; - if (PyArg_ParseTuple(args,"s:Cell.setName", &name)) { - cell->setName(Name(name)); - } else { - PyErr_SetString(ConstructorError, "invalid number of parameters for Cell.setName."); - return NULL; - } - HCATCH - - Py_RETURN_NONE; - } - + SetNameMethod(Cell, cell) // --------------------------------------------------------------- // Attribute Method : "PyCell_setAbutmentBox ()" diff --git a/hurricane/src/isobar/PyHorizontal.cpp b/hurricane/src/isobar/PyHorizontal.cpp index 1154c3a2..19883eff 100644 --- a/hurricane/src/isobar/PyHorizontal.cpp +++ b/hurricane/src/isobar/PyHorizontal.cpp @@ -1,40 +1,3 @@ - -// -*- C++ -*- -// -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie -// -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id: PyHorizontal.cpp,v 1.15 2008/02/07 17:09:41 xtof Exp $ -// // x-----------------------------------------------------------------x // | | // | C O R I O L I S | @@ -104,98 +67,37 @@ extern "C" { // x-------------------------------------------------------------x // | "PyHorizontal" Object Methods | // x-------------------------------------------------------------x + // --------------------------------------------------------------- // Attribute Method : "PyHorizontal_new ()" static PyObject* PyHorizontal_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { trace << "PyHorizontal_new()" << endl; - - PyObject* arg0; - PyObject* arg1; - PyObject* arg2; - PyObject* arg3; - PyObject* arg4; - PyObject* arg5; - PyObject* arg6; - - Horizontal* horizontal = NULL; + Horizontal* horizontal = NULL; HTRY - - __cs.init ("Horizontal.create"); - if ( ! PyArg_ParseTuple(args,"O&O&O&|O&O&O&O&:Horizontal.create" - ,Converter,&arg0 - ,Converter,&arg1 - ,Converter,&arg2 - ,Converter,&arg3 - ,Converter,&arg4 - ,Converter,&arg5 - ,Converter,&arg6 - )) { - PyErr_SetString ( ConstructorError, "invalid number of parameters for Horizontal constructor." ); - return NULL; - } - - if ( __cs.getObjectIds() == NET_LAYER_INT_ARG ) - horizontal = Horizontal::create ( PYNET_O(arg0) - , PYLAYER_O(arg1) - , PyInt_AsLong(arg2) ); - else if ( __cs.getObjectIds() == NET_LAYER_INTS2_ARG ) - horizontal = Horizontal::create ( PYNET_O(arg0) - , PYLAYER_O(arg1) - , PyInt_AsLong(arg2) - , PyInt_AsLong(arg3) ); - else if ( __cs.getObjectIds() == COMPS2_LAYER_INT_ARG ) - horizontal = Horizontal::create ( ComponentCast(arg0) - , ComponentCast(arg1) - , PYLAYER_O(arg2) - , PyInt_AsLong(arg3) ); - else if ( __cs.getObjectIds() == NET_LAYER_INTS3_ARG ) - horizontal = Horizontal::create ( PYNET_O(arg0) - , PYLAYER_O(arg1) - , PyInt_AsLong(arg2) - , PyInt_AsLong(arg3) - , PyInt_AsLong(arg4) ); - else if ( __cs.getObjectIds() == COMPS2_LAYER_INTS2_ARG ) - horizontal = Horizontal::create ( ComponentCast(arg0) - , ComponentCast(arg1) - , PYLAYER_O(arg2) - , PyInt_AsLong(arg3) - , PyInt_AsLong(arg4) ); - else if ( __cs.getObjectIds() == NET_LAYER_INTS4_ARG ) - horizontal = Horizontal::create ( PYNET_O(arg0) - , PYLAYER_O(arg1) - , PyInt_AsLong(arg2) - , PyInt_AsLong(arg3) - , PyInt_AsLong(arg4) - , PyInt_AsLong(arg5) ); - else if ( __cs.getObjectIds() == COMPS2_LAYER_INTS3_ARG ) - horizontal = Horizontal::create ( ComponentCast(arg0) - , ComponentCast(arg1) - , PYLAYER_O(arg2) - , PyInt_AsLong(arg3) - , PyInt_AsLong(arg4) - , PyInt_AsLong(arg5) ); - else if ( __cs.getObjectIds() == COMPS2_LAYER_INTS4_ARG ) - horizontal = Horizontal::create ( ComponentCast(arg0) - , ComponentCast(arg1) - , PYLAYER_O(arg2) - , PyInt_AsLong(arg3) - , PyInt_AsLong(arg4) - , PyInt_AsLong(arg5) - , PyInt_AsLong(arg6) ); - else { + PyNet* pyNet=NULL; + PyComponent *pySource = NULL, *pyTarget = NULL; + PyLayer* pyLayer = NULL; + long y = 0, width = 0, dxSource = 0, dxTarget = 0; + if (PyArg_ParseTuple(args,"O!O!l|lll:Horizontal.New", &PyTypeNet, &pyNet, + &PyTypeLayer, &pyLayer, &y, &width, &dxSource, &dxTarget)) { + horizontal = Horizontal::create(PYNET_O(pyNet), PYLAYER_O(pyLayer), y, width, dxSource, dxTarget); + } else if (PyArg_ParseTuple(args,"O!O!O!l|lll:Horizontal.New", + &PyTypeComponent, &pySource, &PyTypeComponent, &pyTarget, + &PyTypeLayer, &pyLayer, + &y, &width, &dxSource, &dxTarget)) { + horizontal = Horizontal::create(PYCOMPONENT_O(pySource), PYCOMPONENT_O(pyTarget), PYLAYER_O(pyLayer), + y, width, dxSource, dxTarget); + } else { PyErr_SetString ( ConstructorError, "invalid number of parameters for Horizontal constructor." ); return NULL; } - HCATCH return PyHorizontal_Link ( horizontal ); } - - DBoDeleteMethod(Horizontal) PyTypeObjectLinkPyType(Horizontal) PyTypeObjectConstructor(Horizontal) diff --git a/hurricane/src/isobar/PyHurricane.cpp b/hurricane/src/isobar/PyHurricane.cpp index 6e1a946b..278f9748 100644 --- a/hurricane/src/isobar/PyHurricane.cpp +++ b/hurricane/src/isobar/PyHurricane.cpp @@ -58,7 +58,6 @@ #include "hurricane/isobar/PyPoint.h" #include "hurricane/isobar/PyBox.h" #include "hurricane/isobar/PyTransformation.h" -#include "hurricane/isobar/PyName.h" #include "hurricane/isobar/PyDataBase.h" #include "hurricane/isobar/PyLibrary.h" #include "hurricane/isobar/PyEntity.h" @@ -523,7 +522,6 @@ extern "C" { PyPoint_LinkPyType (); PyBox_LinkPyType (); PyTransformation_LinkPyType (); - PyName_LinkPyType (); PyDataBase_LinkPyType (); PyTechnology_LinkPyType (); PyLibrary_LinkPyType (); @@ -561,7 +559,6 @@ extern "C" { PyLibrary_Constructor(); PyBox_Constructor(); PyTransformation_Constructor(); - PyName_Constructor(); PyReference_Constructor(); PyCell_Constructor(); PyInstance_Constructor(); @@ -578,7 +575,6 @@ extern "C" { PYTYPE_READY ( Point ) PYTYPE_READY ( Box ) PYTYPE_READY ( Transformation ) - PYTYPE_READY ( Name ) PYTYPE_READY ( DataBase ) PYTYPE_READY ( Technology ) PYTYPE_READY ( Library ) @@ -643,7 +639,6 @@ extern "C" { __cs.addType ( "instCol" , &PyTypeInstanceCollection, "" , false ); __cs.addType ( "layer" , &PyTypeLayer , "" , false ); __cs.addType ( "library" , &PyTypeLibrary , "" , false ); - __cs.addType ( "name" , &PyTypeName , "" , false ); __cs.addType ( "ref" , &PyTypeReference , "" , false, "ent" ); __cs.addType ( "refCol" , &PyTypeReferenceCollection, "" , false ); __cs.addType ( "net" , &PyTypeNet , "" , false, "ent" ); @@ -677,7 +672,6 @@ extern "C" { PyModule_AddObject(module, "Library" , (PyObject*)&PyTypeLibrary); PyModule_AddObject(module, "Box" , (PyObject*)&PyTypeBox); PyModule_AddObject(module, "Transformation" , (PyObject*)&PyTypeTransformation); - PyModule_AddObject(module, "Name" , (PyObject*)&PyTypeName); PyModule_AddObject(module, "Reference" , (PyObject*)&PyTypeReference); PyModule_AddObject(module, "Cell" , (PyObject*)&PyTypeCell); PyModule_AddObject(module, "Instance" , (PyObject*)&PyTypeInstance); diff --git a/hurricane/src/isobar/PyInstance.cpp b/hurricane/src/isobar/PyInstance.cpp index 43dbfd2b..3f2fc57f 100644 --- a/hurricane/src/isobar/PyInstance.cpp +++ b/hurricane/src/isobar/PyInstance.cpp @@ -1,40 +1,3 @@ - -// -*- C++ -*- -// -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie -// -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id: PyInstance.cpp,v 1.31 2008/02/07 17:09:41 xtof Exp $ -// // x-----------------------------------------------------------------x // | | // | C O R I O L I S | @@ -50,7 +13,6 @@ // x-----------------------------------------------------------------x #include "hurricane/isobar/PyBox.h" -#include "hurricane/isobar/PyName.h" #include "hurricane/isobar/PyTransformation.h" #include "hurricane/isobar/PyLibrary.h" #include "hurricane/isobar/PyCell.h" @@ -141,22 +103,7 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyInstance_getName ()" - static PyObject* PyInstance_getName ( PyInstance *self ) { - trace << "PyInstance_getName ()" << endl; - METHOD_HEAD ( "Instance.getName()" ) - - PyName* pyName = PyObject_NEW ( PyName, &PyTypeName ); - if ( pyName == NULL ) { return NULL; } - - HTRY - pyName->_object = new Name ( instance->getName() ); - HCATCH - - return ( (PyObject*)pyName ); - } - - - + GetNameMethod(Instance, instance) // --------------------------------------------------------------- // Attribute Method : "PyInstance_getMasterCell ()" @@ -342,20 +289,7 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyInstance_setName ()" - static PyObject* PyInstance_setName ( PyInstance *self, PyObject* args ) { - trace << "PyInstance_setName()" << endl; - METHOD_HEAD ( "Instance.setName()" ) - - HTRY - PyName* name; - if ( ! ParseOneArg ( "Instance.setName", args, NAME_ARG, (PyObject**)&name ) ) return ( NULL ); - - instance->setName ( *PYNAME_O(name) ); - HCATCH - - Py_RETURN_NONE; - } - + SetNameMethod(Instance, instance) // --------------------------------------------------------------- @@ -442,6 +376,7 @@ extern "C" { trace << "PyInstance_new ()" << endl; Instance* instance = NULL; +#if 0 //FIXME PyObject* arg0; PyObject* arg1; PyObject* arg2; @@ -459,7 +394,7 @@ extern "C" { return NULL; } - if ( __cs.getObjectIds() == CELL_NAME_CELL_ARG ) { instance = Instance::create ( PYCELL_O(arg0) + if ( __cs.getObjectIds() == :ent:string:ent ) { instance = Instance::create ( PYCELL_O(arg0) , *PYNAME_O(arg1) , PYCELL_O(arg2) ); } else if ( __cs.getObjectIds() == CELL_NAME_CELL_TRANS_ARG ) { instance = Instance::create ( PYCELL_O(arg0) @@ -472,6 +407,7 @@ extern "C" { return ( NULL ); } HCATCH +#endif return PyInstance_Link ( instance ); } diff --git a/hurricane/src/isobar/PyLayer.cpp b/hurricane/src/isobar/PyLayer.cpp index 17c28f76..15e34369 100644 --- a/hurricane/src/isobar/PyLayer.cpp +++ b/hurricane/src/isobar/PyLayer.cpp @@ -1,40 +1,3 @@ - -// -*- C++ -*- -// -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie -// -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id: PyLayer.cpp,v 1.10 2006/09/22 11:27:31 tsunami Exp $ -// // x-----------------------------------------------------------------x // | | // | C O R I O L I S | @@ -53,7 +16,6 @@ #include "hurricane/isobar/PyLayer.h" -#include "hurricane/isobar/PyName.h" #include "hurricane/isobar/PyTechnology.h" @@ -108,43 +70,12 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyLayer_getName ()" - static PyObject* PyLayer_getName ( PyLayer *self ) - { - - trace << "Layer_getName ()" << endl; - METHOD_HEAD ( "Layer.getName()" ) - - PyName* pyName = PyObject_NEW ( PyName, &PyTypeName ); - if ( pyName == NULL ) { return NULL; } - - HTRY - pyName->_object = new Name ( layer->getName() ); - HCATCH - - return ( (PyObject*)pyName ); - } - - + GetNameMethod(Layer, layer) // --------------------------------------------------------------- // Attribute Method : "PyLayer_SetName ()" - static PyObject* PyLayer_SetName ( PyLayer *self, PyObject* args ) - { - trace << "Layer.SetName()" << endl; - METHOD_HEAD ( "Layer.SetName()" ) - - HTRY - PyName* name; - if ( ! ParseOneArg ( "Layer.SetName", args, NAME_ARG, (PyObject**)&name ) ) return ( NULL ); - - layer->setName ( *PYNAME_O(name) ); - HCATCH - - Py_RETURN_NONE; - } - - + SetNameMethod(Layer, layer) // --------------------------------------------------------------- // PyLayer Attribute Method table. @@ -152,7 +83,7 @@ extern "C" { PyMethodDef PyLayer_Methods[] = { { "getTechnology" , (PyCFunction)PyLayer_getTechnology , METH_NOARGS , "Returns the technology owning the layer." } , { "getName" , (PyCFunction)PyLayer_getName , METH_NOARGS , "Returns the name of the layer." } - , { "SetName" , (PyCFunction)PyLayer_SetName , METH_VARARGS, "Allows to change the layer name." } + , { "setName" , (PyCFunction)PyLayer_setName , METH_VARARGS, "Allows to change the layer name." } , { "destroy" , (PyCFunction)PyLayer_destroy , METH_NOARGS , "Destroy associated hurricane object The python object remains." } , {NULL, NULL, 0, NULL} /* sentinel */ diff --git a/hurricane/src/isobar/PyLibrary.cpp b/hurricane/src/isobar/PyLibrary.cpp index d926cfc0..df57563f 100644 --- a/hurricane/src/isobar/PyLibrary.cpp +++ b/hurricane/src/isobar/PyLibrary.cpp @@ -46,18 +46,7 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyLibrary_getName ()" - - static PyObject* PyLibrary_getName ( PyLibrary *self ) { - trace << "PyLibrary_getName ()" << endl; - - METHOD_HEAD ( "Library.getName()" ) - - HTRY - return PyString_FromString(getString(lib->getName()).c_str()); - HCATCH - - return NULL; - } + GetNameMethod(Library, lib) // --------------------------------------------------------------- @@ -137,13 +126,12 @@ extern "C" { static PyObject* PyLibrary_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { trace << "PyLibrary_new()" << endl; - char* name = NULL; - PyDataBase* pyDataBase = NULL; - PyLibrary* pyRootLibrary = NULL; - Library* library = NULL; HTRY + char* name = NULL; + PyDataBase* pyDataBase = NULL; + PyLibrary* pyRootLibrary = NULL; if (PyArg_ParseTuple(args,"O!s:Library.new", &PyTypeDataBase, &pyDataBase, &name)) { DataBase* db = PYDATABASE_O(pyDataBase); library = Library::create(db, Name(name)); diff --git a/hurricane/src/isobar/PyName.cpp b/hurricane/src/isobar/PyName.cpp deleted file mode 100644 index cd5a0f93..00000000 --- a/hurricane/src/isobar/PyName.cpp +++ /dev/null @@ -1,166 +0,0 @@ - -// -*- C++ -*- -// -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie -// -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id: PyName.cpp,v 1.13 2006/09/22 11:27:31 tsunami Exp $ -// -// x-----------------------------------------------------------------x -// | | -// | 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@asim.lip6.fr | -// | =============================================================== | -// | C++ Module : "./PyName.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x - -#include "hurricane/isobar/PyName.h" - - -namespace Isobar { - -using namespace Hurricane; - -extern "C" { - - -#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Name,_object,function) - - -// x=================================================================x -// | "PyName" Python Module Code Part | -// x=================================================================x - -#if defined(__PYTHON_MODULE__) - - - // x-------------------------------------------------------------x - // | "PyName" Attribute Methods | - // x-------------------------------------------------------------x - - //DirectGetBoolAttribute(PyName_IsEmpty,IsEmpty,PyName,Name) - - static PyObject* PyName_isEmpty ( PyName *self ) { - trace << "PyName_isEmpty()" << endl; - - METHOD_HEAD ( "Name.isEmpty()" ) - return ( Py_BuildValue ("i",_object->isEmpty()) ); - } - - - // Standart destroy (Attribute). - DirectDestroyAttribute(PyName_destroy, PyName) - - - - - // --------------------------------------------------------------- - // PyName Attribute Method table. - - PyMethodDef PyName_Methods[] = - { { "isEmpty" , (PyCFunction)PyName_isEmpty , METH_NOARGS , "True if empty." } - , { "destroy" , (PyCFunction)PyName_destroy , METH_NOARGS - , "Destroy associated hurricane object The python object remains." } - , {NULL, NULL, 0, NULL} /* sentinel */ - }; - - // --------------------------------------------------------------- - // Attribute Method : "PyName_new ()" - - static PyObject* PyName_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - trace << "PyName_new ()" << endl; - - Name* name = NULL; - PyObject* arg0; - - __cs.init ("Name.new"); - if (!PyArg_ParseTuple(args,"|O&:Name.new",Converter,&arg0)) { - PyErr_SetString ( ConstructorError, "invalid number of parameters for Name constructor." ); - return NULL; - } - - HTRY - if (__cs.getObjectIds() == NO_ARG ) { name = new Name (); } - else if (__cs.getObjectIds() == STRING_ARG ) { name = new Name ( PyString_AsString(arg0) ); } - else { - PyErr_SetString ( ConstructorError, "invalid number of parameters for Name constructor." ); - return NULL; - } - HCATCH - - PyObject* pyName = type->tp_alloc(type, 0); - if (pyName != NULL) { - ((PyName*)pyName)->ACCESS_OBJECT = name; - } - - return pyName; - } - - - DirectDeleteMethod(PyName_DeAlloc,PyName) - PyTypeObjectLinkPyType(Name) - PyTypeObjectConstructor(Name) - - -#else // End of Python Module Code Part. - - -// x=================================================================x -// | "PyName" Shared Library Code Part | -// x=================================================================x - - - - - - // --------------------------------------------------------------- - // PyName Object Definitions. - - PyTypeObjectDefinitions(Name) - - -#endif // End of Shared Library Code Part. - - -} // End of extern "C". - - - - -} // End of Isobar namespace. - diff --git a/hurricane/src/isobar/PyNet.cpp b/hurricane/src/isobar/PyNet.cpp index a4c45fcb..80347511 100644 --- a/hurricane/src/isobar/PyNet.cpp +++ b/hurricane/src/isobar/PyNet.cpp @@ -145,18 +145,7 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyNet_getName ()" - - static PyObject* PyNet_getName ( PyNet *self ) { - trace << "PyNet_getName ()" << endl; - - HTRY - METHOD_HEAD("Net.getName()") - return PyString_FromString(getString(net->getName()).c_str()); - HCATCH - - return NULL; - } - + GetNameMethod(Net, net) // --------------------------------------------------------------- @@ -290,41 +279,24 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyNet_setName ()" - static PyObject* PyNet_setName ( PyNet *self, PyObject* args ) - { - trace << "PyNet_setName()" << endl; - - HTRY - METHOD_HEAD("Net.setName()") - char* name = NULL; - if (PyArg_ParseTuple(args,"s:Net.setName", &name)) { - net->setName(Name(name)); - } else { - PyErr_SetString(ConstructorError, "invalid number of parameters for Net.setName."); - return NULL; - } - HCATCH - - Py_RETURN_NONE; - } + SetNameMethod(Net, net) // --------------------------------------------------------------- // Attribute Method : "PyNet_setGlobal ()" - static PyObject* PyNet_setGlobal ( PyNet *self, PyObject* args ) - { + static PyObject* PyNet_setGlobal ( PyNet *self, PyObject* args ) { trace << "PyNet_setGlobal()" << endl; HTRY - METHOD_HEAD ( "Net.setGlobal()" ) - PyObject* arg0; - if ( ! ParseOneArg ( "Net.setGlobal", args, INT_ARG, (PyObject**)&arg0 ) ) return ( NULL ); - - net->setGlobal ( PyInt_AsLong(arg0) != 0 ); - + if (PyArg_ParseTuple(args,"O:Net.setGlobal", &arg0) && PyBool_Check(arg0)) { + (arg0 == Py_True)?net->setGlobal(true):net->setGlobal(false); + } else { + PyErr_SetString ( ConstructorError, "invalid number of parameters for Net.setGlobal." ); + return NULL; + } HCATCH Py_RETURN_NONE; @@ -335,19 +307,18 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyNet_setExternal ()" - static PyObject* PyNet_setExternal ( PyNet *self, PyObject* args ) - { + static PyObject* PyNet_setExternal ( PyNet *self, PyObject* args ) { trace << "PyNet_setExternal()" << endl; HTRY - METHOD_HEAD ( "Net.setExternal()" ) - PyObject* arg0; - if ( ! ParseOneArg ( "Net.setExternal", args, INT_ARG, (PyObject**)&arg0 ) ) return ( NULL ); - - net->setExternal ( PyInt_AsLong(arg0) != 0 ); - + if (PyArg_ParseTuple(args,"O:Net.setExternal", &arg0) && PyBool_Check(arg0)) { + (arg0 == Py_True)?net->setExternal(true):net->setExternal(false); + } else { + PyErr_SetString ( ConstructorError, "invalid number of parameters for Net.setExternal." ); + return NULL; + } HCATCH Py_RETURN_NONE; @@ -433,13 +404,14 @@ extern "C" { trace << "PyNet_merge()" << endl; HTRY - + PyNet* pyNetToMerge; METHOD_HEAD ( "Net.merge()" ) - - PyObject* arg0; - if ( ! ParseOneArg ( "Net.merge", args, NET_ARG, (PyObject**)&arg0 ) ) return ( NULL ); - - net->merge ( PYNET_O(arg0) ); + if (PyArg_ParseTuple(args, "O!:Net.merge", &PyTypeNet, &pyNetToMerge)) { + net->merge(PYNET_O(pyNetToMerge)); + } else { + PyErr_SetString (ConstructorError, "invalid number of parameters for Net.merge."); + return NULL; + } HCATCH diff --git a/hurricane/src/isobar/PyOccurrence.cpp b/hurricane/src/isobar/PyOccurrence.cpp index 9ef81fa0..db3f4636 100644 --- a/hurricane/src/isobar/PyOccurrence.cpp +++ b/hurricane/src/isobar/PyOccurrence.cpp @@ -1,40 +1,3 @@ - -// -*- C++ -*- -// -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie -// -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id: PyOccurrence.cpp,v 1.7 2007/05/02 11:50:46 d2 Exp $ -// // x-----------------------------------------------------------------x // | | // | C O R I O L I S | @@ -51,7 +14,6 @@ #include "hurricane/isobar/PyBox.h" #include "hurricane/isobar/PyTransformation.h" -#include "hurricane/isobar/PyName.h" #include "hurricane/isobar/PyPath.h" #include "hurricane/isobar/PyOccurrence.h" #include "hurricane/isobar/PyCell.h" @@ -177,21 +139,7 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyOccurrence_getName ()" - static PyObject* PyOccurrence_getName ( PyOccurrence *self ) - { - trace << "PyOccurrence_getName ()" << endl; - - METHOD_HEAD ( "Occurrence.getName()" ) - - PyName* pyName = PyObject_NEW ( PyName, &PyTypeName ); - if ( pyName == NULL ) { return NULL; } - - HTRY - pyName->_object = new Name ( occurrence->getName() ); - HCATCH - - return ( (PyObject*)pyName ); - } + GetNameMethod(Occurrence, occurrence) // --------------------------------------------------------------- diff --git a/hurricane/src/isobar/PyPath.cpp b/hurricane/src/isobar/PyPath.cpp index d7020d4c..97a1c5e6 100644 --- a/hurricane/src/isobar/PyPath.cpp +++ b/hurricane/src/isobar/PyPath.cpp @@ -1,40 +1,3 @@ - -// -*- C++ -*- -// -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie -// -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id: PyPath.cpp,v 1.6 2006/09/22 11:27:32 tsunami Exp $ -// // x-----------------------------------------------------------------x // | | // | C O R I O L I S | @@ -53,7 +16,6 @@ using namespace Hurricane; #include "hurricane/isobar/PyTransformation.h" -#include "hurricane/isobar/PyName.h" #include "hurricane/isobar/PyPath.h" #include "hurricane/isobar/PyCell.h" #include "hurricane/isobar/PyInstance.h" @@ -168,20 +130,7 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyPath_getName ()" - static PyObject* PyPath_getName ( PyPath *self ) { - trace << "PyPath_getName ()" << endl; - - METHOD_HEAD ( "Path.getName()" ) - - PyName* pyName = PyObject_NEW ( PyName, &PyTypeName ); - if ( pyName == NULL ) { return NULL; } - - HTRY - pyName->_object = new Name ( path->getName() ); - HCATCH - - return ( (PyObject*)pyName ); - } + GetNameMethod(Path, path) // --------------------------------------------------------------- diff --git a/hurricane/src/isobar/PyPin.cpp b/hurricane/src/isobar/PyPin.cpp index c34bc455..99638a2e 100644 --- a/hurricane/src/isobar/PyPin.cpp +++ b/hurricane/src/isobar/PyPin.cpp @@ -1,40 +1,3 @@ - -// -*- C++ -*- -// -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie -// -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id: PyPin.cpp,v 1.18 2008/02/07 17:09:41 xtof Exp $ -// // x-----------------------------------------------------------------x // | | // | C O R I O L I S | @@ -51,7 +14,6 @@ #include "hurricane/isobar/PyPin.h" #include "hurricane/isobar/PyNet.h" -#include "hurricane/isobar/PyName.h" #include "hurricane/isobar/PyLayer.h" @@ -161,6 +123,8 @@ extern "C" { trace << "PyPin_new()" << endl; +#if 0 + PyObject* arg0; PyObject* arg1; PyObject* arg2; @@ -219,6 +183,7 @@ extern "C" { return NULL; } +#endif HCATCH return PyPin_Link ( pin ); diff --git a/hurricane/src/isobar/PyReference.cpp b/hurricane/src/isobar/PyReference.cpp index 53461b98..3ecd5fa4 100644 --- a/hurricane/src/isobar/PyReference.cpp +++ b/hurricane/src/isobar/PyReference.cpp @@ -1,40 +1,3 @@ - -// -*- C++ -*- -// -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie -// -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id: PyReference.cpp,v 1.8 2008/02/07 17:09:42 xtof Exp $ -// // x-----------------------------------------------------------------x // | | // | C O R I O L I S | @@ -55,7 +18,6 @@ using namespace Hurricane; #include "hurricane/isobar/PyReference.h" #include "hurricane/isobar/PyPoint.h" -#include "hurricane/isobar/PyName.h" #include "hurricane/isobar/PyCell.h" #include "hurricane/isobar/PyNet.h" @@ -90,30 +52,7 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyReference_getName ()" - static PyObject* PyReference_getName ( PyReference *self ) { - - trace << "PyReference_getName ()" << endl; - - METHOD_HEAD ( "Reference.getName()" ) - - PyName* pyName = PyObject_NEW ( PyName, &PyTypeName ); - if ( pyName == NULL ) { return NULL; } - - HTRY - - trace_in (); - trace << "new PyName [" << hex << pyName << "]" << endl; - trace_out (); - - pyName->_object = new Name ( reference->getName() ); - - HCATCH - - return ( (PyObject*)pyName ); - } - - - + GetNameMethod(Reference, reference) // --------------------------------------------------------------- // Attribute Method : "PyReference_getPoint ()" @@ -186,12 +125,14 @@ extern "C" { static PyObject* PyReference_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { trace << "PyReference_new()" << endl; + Reference* reference = NULL; + +#if 0 PyObject* arg0; PyObject* arg1; PyObject* arg2; PyObject* arg3; - Reference* reference = NULL; HTRY @@ -221,6 +162,7 @@ extern "C" { } HCATCH +#endif return PyReference_Link ( reference ); } diff --git a/hurricane/src/isobar/PyVertical.cpp b/hurricane/src/isobar/PyVertical.cpp index d80c4424..338dfd01 100644 --- a/hurricane/src/isobar/PyVertical.cpp +++ b/hurricane/src/isobar/PyVertical.cpp @@ -1,40 +1,3 @@ - -// -*- C++ -*- -// -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie -// -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id: PyVertical.cpp,v 1.18 2008/02/07 17:09:42 xtof Exp $ -// // x-----------------------------------------------------------------x // | | // | C O R I O L I S | @@ -107,88 +70,29 @@ extern "C" { static PyObject* PyVertical_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { trace << "PyVertical_new()" << endl; - - PyObject* arg0; - PyObject* arg1; - PyObject* arg2; - PyObject* arg3; - PyObject* arg4; - PyObject* arg5; - PyObject* arg6; Vertical* vertical = NULL; HTRY - __cs.init ("Vertical.new"); - if (!PyArg_ParseTuple(args,"O&O&O&|O&O&O&O&:Vertical.new" - ,Converter,&arg0 - ,Converter,&arg1 - ,Converter,&arg2 - ,Converter,&arg3 - ,Converter,&arg4 - ,Converter,&arg5 - ,Converter,&arg6 - )) { - PyErr_SetString ( ConstructorError, "invalid number of parameters for Vertical constructor." ); - return NULL; - } - - - if ( __cs.getObjectIds() == NET_LAYER_INT_ARG ) - vertical = Vertical::create ( PYNET_O(arg0) - , PYLAYER_O(arg1) - , PyInt_AsLong(arg2) ); - else if ( __cs.getObjectIds() == NET_LAYER_INTS2_ARG ) - vertical = Vertical::create ( PYNET_O(arg0) - , PYLAYER_O(arg1) - , PyInt_AsLong(arg2) - , PyInt_AsLong(arg3) ); - else if ( __cs.getObjectIds() == COMPS2_LAYER_INT_ARG ) - vertical = Vertical::create ( ComponentCast(arg0) - , ComponentCast(arg1) - , PYLAYER_O(arg2) - , PyInt_AsLong(arg3) ); - else if ( __cs.getObjectIds() == NET_LAYER_INTS3_ARG ) - vertical = Vertical::create ( PYNET_O(arg0) - , PYLAYER_O(arg1) - , PyInt_AsLong(arg2) - , PyInt_AsLong(arg3) - , PyInt_AsLong(arg4) ); - else if ( __cs.getObjectIds() == COMPS2_LAYER_INTS2_ARG ) - vertical = Vertical::create ( ComponentCast(arg0) - , ComponentCast(arg1) - , PYLAYER_O(arg2) - , PyInt_AsLong(arg3) - , PyInt_AsLong(arg4) ); - else if ( __cs.getObjectIds() == NET_LAYER_INTS4_ARG ) - vertical = Vertical::create ( PYNET_O(arg0) - , PYLAYER_O(arg1) - , PyInt_AsLong(arg2) - , PyInt_AsLong(arg3) - , PyInt_AsLong(arg4) - , PyInt_AsLong(arg5) ); - else if ( __cs.getObjectIds() == COMPS2_LAYER_INTS3_ARG ) - vertical = Vertical::create ( ComponentCast(arg0) - , ComponentCast(arg1) - , PYLAYER_O(arg2) - , PyInt_AsLong(arg3) - , PyInt_AsLong(arg4) - , PyInt_AsLong(arg5) ); - else if ( __cs.getObjectIds() == COMPS2_LAYER_INTS4_ARG ) - vertical = Vertical::create ( ComponentCast(arg0) - , ComponentCast(arg1) - , PYLAYER_O(arg2) - , PyInt_AsLong(arg3) - , PyInt_AsLong(arg4) - , PyInt_AsLong(arg5) - , PyInt_AsLong(arg6) ); - else { + PyNet* pyNet=NULL; + PyComponent *pySource = NULL, *pyTarget = NULL; + PyLayer* pyLayer = NULL; + long x = 0, width = 0, dySource = 0, dyTarget = 0; + if (PyArg_ParseTuple(args,"O!O!l|lll:Vertical.New", &PyTypeNet, &pyNet, + &PyTypeLayer, &pyLayer, &x, &width, &dySource, &dyTarget)) { + vertical = Vertical::create(PYNET_O(pyNet), PYLAYER_O(pyLayer), x, width, dySource, dyTarget); + } else if (PyArg_ParseTuple(args,"O!O!O!l|lll:Vertical.New", + &PyTypeComponent, &pySource, &PyTypeComponent, &pyTarget, + &PyTypeLayer, &pyLayer, + &x, &width, &dySource, &dyTarget)) { + vertical = Vertical::create(PYCOMPONENT_O(pySource), PYCOMPONENT_O(pyTarget), PYLAYER_O(pyLayer), + x, width, dySource, dyTarget); + } else { PyErr_SetString ( ConstructorError, "invalid number of parameters for Vertical constructor." ); return NULL; } - HCATCH - return PyVertical_Link(vertical); + } DBoDeleteMethod(Vertical) diff --git a/hurricane/src/isobar/hurricane/isobar/PyHurricane.h b/hurricane/src/isobar/hurricane/isobar/PyHurricane.h index 3ee74e35..89da2a31 100644 --- a/hurricane/src/isobar/hurricane/isobar/PyHurricane.h +++ b/hurricane/src/isobar/hurricane/isobar/PyHurricane.h @@ -1,39 +1,3 @@ -// -*- C++ -*- -// -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie -// -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id: PyHurricane.h,v 1.41 2008/02/07 17:09:41 xtof Exp $ -// // x-----------------------------------------------------------------x // | | // | C O R I O L I S | @@ -291,7 +255,7 @@ extern "C" { // ------------------------------------------------------------------- // Attribute Method Macro For Long. -# define DirectSetLongAttribute(PY_FUNC_NAME,FUNC_NAME,PY_FORMAT,PY_SELF_TYPE,SELF_TYPE) \ +#define DirectSetLongAttribute(PY_FUNC_NAME,FUNC_NAME,PY_FORMAT,PY_SELF_TYPE,SELF_TYPE) \ static PyObject* PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* args ) \ { \ GENERIC_METHOD_HEAD(SELF_TYPE,cobject,"DirectSetLongAttribute()") \ @@ -305,7 +269,34 @@ extern "C" { } +// ------------------------------------------------------------------- +// Attribute Method Macro For Names. +#define GetNameMethod(SELF_TYPE, SELF) \ + static PyObject* Py##SELF_TYPE##_getName(Py##SELF_TYPE* self) { \ + trace << "Py"#SELF_TYPE"_getName()" << endl; \ + HTRY \ + METHOD_HEAD (#SELF_TYPE".getName()") \ + return PyString_FromString(getString(SELF->getName()).c_str()); \ + HCATCH \ + return NULL; \ + } + +#define SetNameMethod(SELF_TYPE, SELF) \ + static PyObject* Py##SELF_TYPE##_setName(Py##SELF_TYPE* self, PyObject* args) { \ + trace << "Py"#SELF_TYPE"_setName()" << endl; \ + HTRY \ + METHOD_HEAD (#SELF_TYPE".setName()") \ + char* name = NULL; \ + if (PyArg_ParseTuple(args,"s:"#SELF_TYPE".setName", &name)) { \ + SELF->setName(Name(name)); \ + } else { \ + PyErr_SetString(ConstructorError, "invalid number of parameters for "#SELF_TYPE".setName."); \ + return NULL; \ + } \ + HCATCH \ + Py_RETURN_NONE; \ + } // ------------------------------------------------------------------- // Attribute Macro For Deletion. @@ -635,40 +626,6 @@ extern "C" { PyType##PY_SELF_TYPE##Locator.tp_methods = Py##PY_SELF_TYPE##Locator_Methods; \ } -// ------------------------------------------------------------------- -// CEngine Initialization -#define CEngineModuleInitialization(CENGINE) \ - DL_EXPORT(void) init##CENGINE () { \ - trace << "init" #CENGINE "()" << endl; \ - Py##CENGINE##_LinkPyType (); \ - PYTYPE_READY_SUB ( CENGINE, CEngine ) \ - __cs.AddType ( #CENGINE, &PyType##CENGINE, "<" #CENGINE ">", false, "cengine" ); \ - PyObject* module = Py_InitModule(#CENGINE, Py##CENGINE##Module_Methods); \ - if ( module == NULL ) { \ - cerr << "[ERROR]\n" \ - << " Failed to initialize " #CENGINE " module." << endl; \ - } \ - } - -// ------------------------------------------------------------------- -// Direct getCEngine() Method (no argument) -#define DirectGetCEngine(CENGINE) \ - PyObject* Py##CENGINE##_get##CENGINE ( PyObject* module, PyObject* args ) \ - { \ - PyObject* arg0; \ - CENGINE* cengine = NULL; \ - HTRY \ - if (!ParseOneArg("get" #CENGINE, args, CELL_ARG, &arg0 ) ) return ( NULL ); \ - Cell* cell = PYCELL_O(arg0); \ - cengine = static_cast(getCEngine(cell, Name(#CENGINE))); \ - if (!cengine) { \ - cengine = CENGINE::create (cell); \ - } \ - HCATCH \ - return Py##CENGINE##_Link( cengine ); \ - } - - #define PyTypeObjectDefinitions(SELF_TYPE) \ PyTypeObject PyType##SELF_TYPE = \ { PyObject_HEAD_INIT(NULL) \ @@ -702,7 +659,7 @@ extern "C" { { PyObject_HEAD_INIT(NULL) \ 0 /* ob_size. */ \ , "Hurricane."#SELF_TYPE /* tp_name. */ \ - , sizeof(Py##SELF_TYPE) /* tp_basicsize. */ \ + , sizeof(Py ##SELF_TYPE) /* tp_basicsize. */ \ , 0 /* tp_itemsize. */ \ /* methods. */ \ , 0 /* tp_dealloc. */ \ diff --git a/hurricane/src/isobar/hurricane/isobar/PyName.h b/hurricane/src/isobar/hurricane/isobar/PyName.h deleted file mode 100644 index eefd4a52..00000000 --- a/hurricane/src/isobar/hurricane/isobar/PyName.h +++ /dev/null @@ -1,106 +0,0 @@ - -// -*- C++ -*- -// -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie -// -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id: PyName.h,v 1.7 2006/05/03 14:00:03 jpc Exp $ -// -// x-----------------------------------------------------------------x -// | | -// | 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@asim.lip6.fr | -// | =============================================================== | -// | C++ Header : "./PyName.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x - - - - - -#ifndef __PYNAME__ -#define __PYNAME__ - - -#include "hurricane/isobar/PyHurricane.h" - -#include "hurricane/Name.h" - - -namespace Isobar { - - -extern "C" { - - -// ------------------------------------------------------------------- -// Python Object : "PyName". - - typedef struct { - PyObject_HEAD - Hurricane::Name* _object; - } PyName; - - - -// ------------------------------------------------------------------- -// Functions & Types exported to "PyHurricane.ccp". - - extern PyTypeObject PyTypeName; - extern PyMethodDef PyName_Methods[]; - - extern void PyName_LinkPyType(); - extern void PyName_Constructor(); - - -#define IsPyName(v) ( (v)->ob_type == &PyTypeName ) -#define PYNAME(v) ( (PyName*)(v) ) -#define PYNAME_O(v) ( PYNAME(v)->_object ) - - -} // End of extern "C". - - - - -} // End of Isobar namespace. - - - - -#endif