more cleaning in isobar :

- new arguments parsing method
 - get rid of PyNames...
Still lot to do ;)
This commit is contained in:
Christophe Alexandre 2008-12-10 18:37:32 +00:00
parent 69a2f10906
commit 452a52ee9e
4 changed files with 108 additions and 280 deletions

View File

@ -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 <Christophe.Alexandre@lip6.fr>
// Sophie Belloeil <Sophie.Belloeil@lip6.fr>
// Hugo Clément <Hugo.Clement@lip6.fr>
// Jean-Paul Chaput <Jean-Paul.Chaput@lip6.fr>
// Damien Dupuis <Damien.Dupuis@lip6.fr>
// Christian Masson <Christian.Masson@lip6.fr>
// Marek Sroka <Marek.Sroka@lip6.fr>
//
// 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: PyCell.cpp,v 1.34 2008/02/07 17:09:41 xtof Exp $
//
// x-----------------------------------------------------------------x // x-----------------------------------------------------------------x
// | | // | |
// | C O R I O L I S | // | C O R I O L I S |
@ -51,7 +14,6 @@
#include "hurricane/isobar/PyCell.h" #include "hurricane/isobar/PyCell.h"
#include "hurricane/isobar/PyBox.h" #include "hurricane/isobar/PyBox.h"
#include "hurricane/isobar/PyName.h"
#include "hurricane/isobar/PyLibrary.h" #include "hurricane/isobar/PyLibrary.h"
#include "hurricane/isobar/PyInstance.h" #include "hurricane/isobar/PyInstance.h"
#include "hurricane/isobar/PyOccurrence.h" #include "hurricane/isobar/PyOccurrence.h"
@ -121,16 +83,12 @@ extern "C" {
static PyObject* PyCell_getName(PyCell *self) { static PyObject* PyCell_getName(PyCell *self) {
trace << "PyCell_getName ()" << endl; trace << "PyCell_getName ()" << endl;
METHOD_HEAD ( "Cell.getName()" )
PyName* pyName = PyObject_NEW ( PyName, &PyTypeName );
if ( pyName == NULL ) { return NULL; }
HTRY HTRY
pyName->_object = new Name ( cell->getName() ); METHOD_HEAD ( "Cell.getName()" )
return PyString_FromString(getString(cell->getName()).c_str());
HCATCH HCATCH
return (PyObject*)pyName; return NULL;
} }
@ -139,20 +97,21 @@ extern "C" {
static PyObject* PyCell_getInstance ( PyCell *self, PyObject* args ) { static PyObject* PyCell_getInstance ( PyCell *self, PyObject* args ) {
trace << "PyCell_getInstance ()" << endl; trace << "PyCell_getInstance ()" << endl;
METHOD_HEAD("Cell.getInstance()")
Instance* instance = NULL; Instance* instance = NULL;
HTRY HTRY
METHOD_HEAD ( "Cell.getInstance()" ) char* name;
if (PyArg_ParseTuple(args,"s:Cell.getInstance", &name)) {
PyName* arg0; instance = cell->getInstance(Name(name));
if ( ! ParseOneArg ( "Cell.getInstance", args, NAME_ARG, (PyObject**)&arg0 ) ) } else {
PyErr_SetString(ConstructorError, "invalid number of parameters for Cell.getInstance." );
return NULL; return NULL;
}
instance = cell->getInstance ( *PYNAME_O(arg0) );
HCATCH HCATCH
return PyInstance_Link ( instance ); return PyInstance_Link(instance);
} }
@ -397,22 +356,23 @@ extern "C" {
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Attribute Method : "PyCell_getNet ()" // Attribute Method : "PyCell_getNet ()"
static PyObject* PyCell_getNet ( PyCell *self, PyObject* args ) { static PyObject* PyCell_getNet(PyCell *self, PyObject* args) {
trace << "PyCell_getNet ()" << endl; trace << "PyCell_getNet ()" << endl;
METHOD_HEAD ( "Cell.getNet()" )
Net* net = NULL; Net* net = NULL;
HTRY HTRY
METHOD_HEAD ( "Cell.getNet()" ) char* name = NULL;
if (PyArg_ParseTuple(args,"s:Cell.getNet", &name)) {
net = cell->getNet(Name(name));
} else {
PyErr_SetString(ConstructorError, "invalid number of parameters for getNet." );
return NULL;
}
HCATCH
PyName* arg0; return PyNet_Link(net);
if ( ! ParseOneArg ( "Cell.getNet", args, NAME_ARG, (PyObject**)&arg0 ) )
return NULL;
net = cell->getNet ( *PYNAME_O(arg0) );
HCATCH
return PyNet_Link ( net );
} }
@ -585,17 +545,18 @@ extern "C" {
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Attribute Method : "PyCell_setName ()" // Attribute Method : "PyCell_setName ()"
static PyObject* PyCell_setName ( PyCell *self, PyObject* args ) static PyObject* PyCell_setName ( PyCell *self, PyObject* args ) {
{
trace << "Cell.setName()" << endl; trace << "Cell.setName()" << endl;
HTRY HTRY
METHOD_HEAD ( "Cell.setName()" ) METHOD_HEAD("Cell.setName()")
char* name = NULL;
PyName* name; if (PyArg_ParseTuple(args,"s:Cell.setName", &name)) {
if ( ! ParseOneArg ( "Cell.setName", args, NAME_ARG, (PyObject**)&name ) ) cell->setName(Name(name));
} else {
PyErr_SetString(ConstructorError, "invalid number of parameters for Cell.setName.");
return NULL; return NULL;
cell->setName ( *PYNAME_O(name) ); }
HCATCH HCATCH
Py_RETURN_NONE; Py_RETURN_NONE;
@ -689,18 +650,17 @@ extern "C" {
static PyObject* PyCell_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { static PyObject* PyCell_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
trace << "PyCell_new()" << endl; trace << "PyCell_new()" << endl;
PyObject* arg0; char* name = NULL;
PyObject* arg1; PyLibrary* pyLibrary = NULL;
string lib_name_arg = ":library:name";
if (!ParseTwoArg("Cell.init", args, lib_name_arg, &arg0, &arg1)) {
PyErr_SetString ( ConstructorError, "invalid number of parameters for Cell constructor.");
return NULL;
}
Cell* cell = NULL; Cell* cell = NULL;
HTRY HTRY
cell = Cell::create(PYLIBRARY_O(arg0), getString(*PYNAME_O(arg1))); if (PyArg_ParseTuple(args,"O!s:Cell.new", &PyTypeLibrary, &pyLibrary, &name)) {
cell = Cell::create(PYLIBRARY_O(pyLibrary), Name(name));
} else {
PyErr_SetString ( ConstructorError, "invalid number of parameters for Cell constructor.");
return NULL;
}
HCATCH HCATCH
return PyCell_Link(cell); return PyCell_Link(cell);

View File

@ -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 <Christophe.Alexandre@lip6.fr>
// Sophie Belloeil <Sophie.Belloeil@lip6.fr>
// Hugo Clément <Hugo.Clement@lip6.fr>
// Jean-Paul Chaput <Jean-Paul.Chaput@lip6.fr>
// Damien Dupuis <Damien.Dupuis@lip6.fr>
// Christian Masson <Christian.Masson@lip6.fr>
// Marek Sroka <Marek.Sroka@lip6.fr>
//
// 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: PyLibrary.cpp,v 1.17 2006/09/22 11:27:31 tsunami Exp $
//
// x-----------------------------------------------------------------x // x-----------------------------------------------------------------x
// | | // | |
// | C O R I O L I S | // | C O R I O L I S |
@ -53,7 +16,6 @@
#include "hurricane/isobar/PyDataBase.h" #include "hurricane/isobar/PyDataBase.h"
#include "hurricane/isobar/PyName.h"
#include "hurricane/isobar/PyLibrary.h" #include "hurricane/isobar/PyLibrary.h"
#include "hurricane/isobar/PyCell.h" #include "hurricane/isobar/PyCell.h"
#include "hurricane/isobar/PyCellCollection.h" #include "hurricane/isobar/PyCellCollection.h"
@ -87,17 +49,14 @@ extern "C" {
static PyObject* PyLibrary_getName ( PyLibrary *self ) { static PyObject* PyLibrary_getName ( PyLibrary *self ) {
trace << "PyLibrary_getName ()" << endl; trace << "PyLibrary_getName ()" << endl;
METHOD_HEAD ( "Library.getName()" ) METHOD_HEAD ( "Library.getName()" )
PyName* pyName = PyObject_NEW ( PyName, &PyTypeName );
if ( pyName == NULL ) { return NULL; }
HTRY HTRY
pyName->_object = new Name ( lib->getName() ); return PyString_FromString(getString(lib->getName()).c_str());
HCATCH HCATCH
return ( (PyObject*)pyName ); return NULL;
} }
@ -105,23 +64,22 @@ extern "C" {
// Attribute Method : "PyLibrary_getCell ()" // Attribute Method : "PyLibrary_getCell ()"
PyObject* PyLibrary_getCell ( PyLibrary* self, PyObject* args ) { PyObject* PyLibrary_getCell ( PyLibrary* self, PyObject* args ) {
trace << "PyLibrary_getCell ()" << endl; trace << "PyLibrary_getCell ()" << endl;
Cell* cell = NULL; Cell* cell = NULL;
HTRY HTRY
METHOD_HEAD("Library.getCell()") METHOD_HEAD("Library.getCell()")
char* name = NULL;
if (PyArg_ParseTuple(args,"s:Library.getCell", &name)) {
cell = lib->getCell (Name(name));
} else {
PyErr_SetString ( ConstructorError, "invalid number of parameters for getCell." );
return NULL;
}
HCATCH
char* name = NULL; return PyCell_Link(cell);
if (PyArg_ParseTuple(args,"s:Library.getCell", &name)) {
cell = lib->getCell (Name(name));
} else {
PyErr_SetString ( ConstructorError, "invalid number of parameters for Library constructor." );
return NULL;
}
HCATCH
return PyCell_Link ( cell );
} }

View File

@ -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 <Christophe.Alexandre@lip6.fr>
// Sophie Belloeil <Sophie.Belloeil@lip6.fr>
// Hugo Clément <Hugo.Clement@lip6.fr>
// Jean-Paul Chaput <Jean-Paul.Chaput@lip6.fr>
// Damien Dupuis <Damien.Dupuis@lip6.fr>
// Christian Masson <Christian.Masson@lip6.fr>
// Marek Sroka <Marek.Sroka@lip6.fr>
//
// 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: PyNet.cpp,v 1.27 2008/02/07 17:09:41 xtof Exp $
//
// x-----------------------------------------------------------------x // x-----------------------------------------------------------------x
// | | // | |
// | C O R I O L I S | // | C O R I O L I S |
@ -53,7 +16,6 @@
#include "hurricane/isobar/PyNet.h" #include "hurricane/isobar/PyNet.h"
#include "hurricane/isobar/PyName.h"
#include "hurricane/isobar/PyCell.h" #include "hurricane/isobar/PyCell.h"
#include "hurricane/isobar/PyPoint.h" #include "hurricane/isobar/PyPoint.h"
#include "hurricane/isobar/PyPlugCollection.h" #include "hurricane/isobar/PyPlugCollection.h"
@ -187,22 +149,12 @@ extern "C" {
static PyObject* PyNet_getName ( PyNet *self ) { static PyObject* PyNet_getName ( PyNet *self ) {
trace << "PyNet_getName ()" << endl; trace << "PyNet_getName ()" << endl;
METHOD_HEAD ( "Net.getName()" )
PyName* pyName = PyObject_NEW ( PyName, &PyTypeName );
if ( pyName == NULL ) { return NULL; }
trace_in ();
trace << "new PyName [" << hex << pyName << "]" << endl;
trace_out ();
HTRY HTRY
METHOD_HEAD("Net.getName()")
pyName->_object = new Name ( net->getName() ); return PyString_FromString(getString(net->getName()).c_str());
HCATCH HCATCH
return ( (PyObject*)pyName ); return NULL;
} }
@ -343,14 +295,14 @@ extern "C" {
trace << "PyNet_setName()" << endl; trace << "PyNet_setName()" << endl;
HTRY HTRY
METHOD_HEAD("Net.setName()")
METHOD_HEAD ( "Net.setName()" ) char* name = NULL;
if (PyArg_ParseTuple(args,"s:Net.setName", &name)) {
PyObject* arg0; net->setName(Name(name));
if ( ! ParseOneArg ( "Net.setName", args, NET_ARG, (PyObject**)&arg0 ) ) return ( NULL ); } else {
PyErr_SetString(ConstructorError, "invalid number of parameters for Net.setName.");
net->setName ( *PYNAME_O(arg0) ); return NULL;
}
HCATCH HCATCH
Py_RETURN_NONE; Py_RETURN_NONE;
@ -548,20 +500,20 @@ extern "C" {
static PyObject* PyNet_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { static PyObject* PyNet_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
trace << "PyNet_new()" << endl; trace << "PyNet_new()" << endl;
Net* net = NULL; char* name = NULL;
PyObject* arg0; PyCell* pyCell = NULL;
PyObject* arg1; Net* net = NULL;
if (!ParseTwoArg("Net.new", args, CELL_NAME_ARG, &arg0, &arg1)) { HTRY
if (PyArg_ParseTuple(args,"O!s:Net.new", &PyTypeCell, &pyCell, &name)) {
net = Net::create(PYCELL_O(pyCell), Name(name));
} else {
PyErr_SetString ( ConstructorError, "invalid number of parameters for Net constructor." ); PyErr_SetString ( ConstructorError, "invalid number of parameters for Net constructor." );
return NULL; return NULL;
} }
HTRY
net = Net::create ( PYCELL_O(arg0), *PYNAME_O(arg1) );
HCATCH HCATCH
return PyNet_Link ( net ); return PyNet_Link(net);
} }
DBoDeleteMethod(Net) DBoDeleteMethod(Net)

View File

@ -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 <Christophe.Alexandre@lip6.fr>
// Sophie Belloeil <Sophie.Belloeil@lip6.fr>
// Hugo Clément <Hugo.Clement@lip6.fr>
// Jean-Paul Chaput <Jean-Paul.Chaput@lip6.fr>
// Damien Dupuis <Damien.Dupuis@lip6.fr>
// Christian Masson <Christian.Masson@lip6.fr>
// Marek Sroka <Marek.Sroka@lip6.fr>
//
// 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: PyTechnology.cpp,v 1.11 2006/09/22 11:27:32 tsunami Exp $
//
// x-----------------------------------------------------------------x // x-----------------------------------------------------------------x
// | | // | |
// | C O R I O L I S | // | C O R I O L I S |
@ -49,11 +12,7 @@
// | | // | |
// x-----------------------------------------------------------------x // x-----------------------------------------------------------------x
#include "hurricane/isobar/PyDataBase.h" #include "hurricane/isobar/PyDataBase.h"
#include "hurricane/isobar/PyName.h"
#include "hurricane/isobar/PyLayer.h" #include "hurricane/isobar/PyLayer.h"
#include "hurricane/isobar/PyTechnology.h" #include "hurricane/isobar/PyTechnology.h"
@ -85,36 +44,33 @@ extern "C" {
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Attribute Method : "PyTechnology_getName ()" // Attribute Method : "PyTechnology_getName ()"
static PyObject* PyTechnology_getName ( PyTechnology *self ) static PyObject* PyTechnology_getName(PyTechnology *self) {
{
trace << "PyTechnology_getName ()" << endl; trace << "PyTechnology_getName ()" << endl;
METHOD_HEAD ( "Technology.getName()" )
PyName* pyName = PyObject_NEW ( PyName, &PyTypeName );
if ( pyName == NULL ) { return NULL; }
HTRY HTRY
pyName->_object = new Name ( techno->getName() ); METHOD_HEAD("Technology.getName()")
return PyString_FromString(getString(techno->getName()).c_str());
HCATCH HCATCH
return ( (PyObject*)pyName ); return NULL;
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Attribute Method : "PyTechnology_setName ()" // Attribute Method : "PyTechnology_setName ()"
static PyObject* PyTechnology_setName ( PyTechnology *self, PyObject* args ) { static PyObject* PyTechnology_setName(PyTechnology *self, PyObject* args) {
trace << "Technology.setName()" << endl; trace << "Technology.setName()" << endl;
METHOD_HEAD ( "Technology.setName()" )
HTRY HTRY
METHOD_HEAD ( "Technology.setName()" )
PyName* name; char* name = NULL;
if ( ! ParseOneArg ( "Technology.setName", args, NAME_ARG, (PyObject**)&name ) ) return ( NULL ); if (PyArg_ParseTuple(args,"s:Technology.setName", &name)) {
techno->setName(Name(name));
techno->setName ( *PYNAME_O(name) ); } else {
PyErr_SetString(ConstructorError, "invalid number of parameters for Technology.setName.");
return NULL;
}
HCATCH HCATCH
Py_RETURN_NONE; Py_RETURN_NONE;
@ -125,21 +81,23 @@ extern "C" {
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Attribute Method : "PyTechnology_getLayer ()" // Attribute Method : "PyTechnology_getLayer ()"
static PyObject* PyTechnology_getLayer ( PyTechnology *self, PyObject* args ) static PyObject* PyTechnology_getLayer ( PyTechnology *self, PyObject* args ) {
{
trace << "Technology.getLayer()" << endl; trace << "Technology.getLayer()" << endl;
METHOD_HEAD ( "Technology.getLayer()" ) METHOD_HEAD("Technology.getLayer()")
Layer* layer = NULL; Layer* layer = NULL;
HTRY HTRY
PyName* name; char* name = NULL;
if ( ! ParseOneArg ( "Technology.getLayer", args,NAME_ARG, (PyObject**)&name ) ) return ( NULL ); if (PyArg_ParseTuple(args,"s:Technology.getLayer", &name)) {
layer = techno->getLayer(Name(name));
layer = techno->getLayer ( *PYNAME_O(name) ); } else {
PyErr_SetString(ConstructorError, "invalid number of parameters for getLayer.");
return NULL;
}
HCATCH HCATCH
return PyLayer_Link ( layer ); return PyLayer_Link(layer);
} }