From dda0af696699916c4fc2c5c052013362d9a9e346 Mon Sep 17 00:00:00 2001 From: Damien Dupuis Date: Thu, 26 Nov 2009 12:18:12 +0000 Subject: [PATCH] ADDS translate methods UpdateSession methods for python layout --- hurricane/src/isobar/PyContact.cpp | 22 ++++++++++++++++++++++ hurricane/src/isobar/PyDbU.cpp | 3 ++- hurricane/src/isobar/PyHurricane.cpp | 3 +++ hurricane/src/isobar/PyPad.cpp | 23 +++++++++++++++++++++++ hurricane/src/isobar/PyVertical.cpp | 24 +++++++++++++++++++++++- 5 files changed, 73 insertions(+), 2 deletions(-) diff --git a/hurricane/src/isobar/PyContact.cpp b/hurricane/src/isobar/PyContact.cpp index e26c0f00..1e6a2bf7 100644 --- a/hurricane/src/isobar/PyContact.cpp +++ b/hurricane/src/isobar/PyContact.cpp @@ -64,6 +64,27 @@ extern "C" { DBoDestroyAttribute(PyContact_destroy, PyContact) + // --------------------------------------------------------------- + // Attribute Method : "PyContact_translate ()" + + static PyObject* PyContact_translate ( PyContact *self, PyObject* args ) { + trace << "PyContact_translate ()" << endl; + + HTRY + METHOD_HEAD ( "Contact.translate()" ) + DbU::Unit dx=0, dy=0; + if (PyArg_ParseTuple(args,"ll:Contact.translate", &dx, &dy)) { + contact->translate(dx, dy); + } else { + PyErr_SetString ( ConstructorError, "invalid number of parameters for Contact.translate()" ); + return NULL; + } + HCATCH + + Py_RETURN_NONE; + } + + // --------------------------------------------------------------- // PyContact Attribute Method table. @@ -76,6 +97,7 @@ extern "C" { , { "getHalfHeight" , (PyCFunction)PyContact_getHalfHeight , METH_NOARGS , "Return the contact half height." } , { "getDx" , (PyCFunction)PyContact_getDx , METH_NOARGS , "Return the contact dx value." } , { "getDy" , (PyCFunction)PyContact_getDy , METH_NOARGS , "Return the contact dy value." } + , { "translate" , (PyCFunction)PyContact_translate , METH_VARARGS, "Translates the Contact of dx and dy." } , {NULL, NULL, 0, NULL} /* sentinel */ }; diff --git a/hurricane/src/isobar/PyDbU.cpp b/hurricane/src/isobar/PyDbU.cpp index 036ea0d8..147fde05 100644 --- a/hurricane/src/isobar/PyDbU.cpp +++ b/hurricane/src/isobar/PyDbU.cpp @@ -166,7 +166,8 @@ extern "C" { if ( ! PyArg_ParseTuple(args,"|O&:DbU.grid",Converter,&arg0) ) return ( NULL ); - if ( __cs.getObjectIds() == FLOAT_ARG ) { result = DbU::grid ( PyFloat_AsDouble ( arg0 ) ); } + if ( __cs.getObjectIds() == FLOAT_ARG ) { result = DbU::grid ( PyFloat_AsDouble ( arg0 ) ); } + else if ( __cs.getObjectIds() == INT_ARG ) { result = DbU::grid ( PyInt_AsLong ( arg0 ) ); } else { PyErr_SetString ( ConstructorError, "invalid number of parameters or bad type for DbU.grid converter." ); return ( NULL ); diff --git a/hurricane/src/isobar/PyHurricane.cpp b/hurricane/src/isobar/PyHurricane.cpp index 15d56393..a9e220bb 100644 --- a/hurricane/src/isobar/PyHurricane.cpp +++ b/hurricane/src/isobar/PyHurricane.cpp @@ -511,6 +511,8 @@ extern "C" { , { "Point" , PyPoint_create , METH_VARARGS, "Creates a new Point." } , { "Box" , PyBox_create , METH_VARARGS, "Creates a new Box." } , { "Transformation" , PyTransformation_create , METH_VARARGS, "Creates a new Transformation." } + , { "UpdateSession_open" , (PyCFunction)PyUpdateSession_open , METH_NOARGS , "Opens an update session." } + , { "UpdateSession_close" , (PyCFunction)PyUpdateSession_close , METH_NOARGS , "Closes an update session." } , { "DataBase" , (PyCFunction)PyDataBase_create , METH_NOARGS , "Creates the DataBase." } , { "getDataBase" , (PyCFunction)PyDataBase_getDataBase , METH_NOARGS , "Gets the current DataBase." } , { "Library" , (PyCFunction)PyLibrary_create , METH_VARARGS, "Creates a new Library." } @@ -669,6 +671,7 @@ extern "C" { << " Failed to initialize Hurricane module." << endl; return; } + //PyModule_AddObject(module, "Box", (PyObject*)&PyTypeBox); // To add Hurricane.Box type in module -> the Hurricane.Box() method must be renamed PyObject* dictionnary = PyModule_GetDict ( module ); diff --git a/hurricane/src/isobar/PyPad.cpp b/hurricane/src/isobar/PyPad.cpp index f09a4d5f..540d69d4 100644 --- a/hurricane/src/isobar/PyPad.cpp +++ b/hurricane/src/isobar/PyPad.cpp @@ -74,6 +74,28 @@ extern "C" { Py_RETURN_NONE; } + + // --------------------------------------------------------------- + // Attribute Method : "PyPad_translate ()" + + static PyObject* PyPad_translate ( PyPad *self, PyObject* args ) { + trace << "PyPad_translate ()" << endl; + + HTRY + METHOD_HEAD ( "Pad.translate()" ) + DbU::Unit dx=0, dy=0; + if (PyArg_ParseTuple(args,"ll:Pad.translate", &dx, &dy)) { + pad->translate(dx, dy); + } else { + PyErr_SetString ( ConstructorError, "invalid number of parameters for Pad.translate()" ); + return NULL; + } + HCATCH + + Py_RETURN_NONE; + } + + // --------------------------------------------------------------- // PyPad Attribute Method table. @@ -82,6 +104,7 @@ extern "C" { , { "getY" , (PyCFunction)PyPad_getY , METH_NOARGS, "Return the Pad Y value." } , { "getBoundingBox" , (PyCFunction)PyPad_getBoundingBox, METH_NOARGS, "Return the Pad Bounding Box." } , { "setBoundingBox" , (PyCFunction)PyPad_setBoundingBox, METH_VARARGS, "Sets the Pad Bounding Box." } + , { "translate" , (PyCFunction)PyPad_translate , METH_VARARGS, "Translates the Pad of dx and dy." } , { "destroy" , (PyCFunction)PyPad_destroy , METH_NOARGS , "Destroy associated hurricane object, the python object remains." } , {NULL, NULL, 0, NULL} /* sentinel */ diff --git a/hurricane/src/isobar/PyVertical.cpp b/hurricane/src/isobar/PyVertical.cpp index 8e196d7d..f3f7813b 100644 --- a/hurricane/src/isobar/PyVertical.cpp +++ b/hurricane/src/isobar/PyVertical.cpp @@ -49,12 +49,34 @@ extern "C" { DBoDestroyAttribute(PyVertical_destroy, PyVertical) + // --------------------------------------------------------------- + // Attribute Method : "PyVertical_translate ()" + + static PyObject* PyVertical_translate ( PyVertical *self, PyObject* args ) { + trace << "PyVertical_translate ()" << endl; + + HTRY + METHOD_HEAD ( "Vertical.translate()" ) + DbU::Unit dx=0, dy=0; + if (PyArg_ParseTuple(args,"ll:Vertical.translate", &dx, &dy)) { + vertical->translate(dx, dy); + } else { + PyErr_SetString ( ConstructorError, "invalid number of parameters for Vertical.translate()" ); + return NULL; + } + HCATCH + + Py_RETURN_NONE; + } + + // --------------------------------------------------------------- // PyVertical Attribute Method table. PyMethodDef PyVertical_Methods[] = - { { "destroy" , (PyCFunction)PyVertical_destroy , METH_NOARGS + { { "destroy" , (PyCFunction)PyVertical_destroy , METH_NOARGS , "Destroy associated hurricane object, the python object remains." } + , { "translate" , (PyCFunction)PyVertical_translate , METH_VARARGS, "Translates the Vertical segment of dx and dy." } , {NULL, NULL, 0, NULL} /* sentinel */ };