2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
// -*- 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<43>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: PyReference.cpp,v 1.8 2008/02/07 17:09:42 xtof 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 : "./PyReference.cpp" |
|
|
|
|
|
// | *************************************************************** |
|
|
|
|
|
// | U p d a t e s |
|
|
|
|
|
// | |
|
|
|
|
|
// x-----------------------------------------------------------------x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 17:46:29 -05:00
|
|
|
|
#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"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Isobar {
|
|
|
|
|
|
2008-03-28 04:48:47 -05:00
|
|
|
|
using namespace Hurricane;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
#undef ACCESS_OBJECT
|
|
|
|
|
#undef ACCESS_CLASS
|
|
|
|
|
#define ACCESS_OBJECT _baseObject._object
|
|
|
|
|
#define ACCESS_CLASS(_pyObject) &(_pyObject->_baseObject)
|
|
|
|
|
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Reference,reference,function)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// x=================================================================x
|
|
|
|
|
// | "PyReference" Python Module Code Part |
|
|
|
|
|
// x=================================================================x
|
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
#if defined(__PYTHON_MODULE__)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// x-------------------------------------------------------------x
|
|
|
|
|
// | "PyReference" Attribute Methods |
|
|
|
|
|
// x-------------------------------------------------------------x
|
|
|
|
|
|
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
DBoDestroyAttribute(PyReference_destroy, PyReference)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
|
// Attribute Method : "PyReference_getName ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
static PyObject* PyReference_getName ( PyReference *self ) {
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
trace << "PyReference_getName ()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
METHOD_HEAD ( "Reference.getName()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
PyName* pyName = PyObject_NEW ( PyName, &PyTypeName );
|
|
|
|
|
if ( pyName == NULL ) { return NULL; }
|
|
|
|
|
|
|
|
|
|
HTRY
|
|
|
|
|
|
|
|
|
|
trace_in ();
|
|
|
|
|
trace << "new PyName [" << hex << pyName << "]" << endl;
|
|
|
|
|
trace_out ();
|
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
pyName->_object = new Name ( reference->getName() );
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
|
|
return ( (PyObject*)pyName );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
|
// Attribute Method : "PyReference_getPoint ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
static PyObject* PyReference_getPoint ( PyReference *self )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
{
|
2008-03-17 08:54:33 -05:00
|
|
|
|
trace << "PyReference_getPoint()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
METHOD_HEAD ( "Reference.getPoint()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
PyPoint* pyPoint = PyObject_NEW ( PyPoint, &PyTypePoint );
|
|
|
|
|
if (pyPoint == NULL) { return NULL; }
|
|
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
|
pyPoint->_object = new Point ( reference->getPoint() );
|
2008-03-06 10:46:43 -06:00
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
|
|
return ( (PyObject*)pyPoint );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-25 06:06:05 -05:00
|
|
|
|
// Attribute Method : "PyReference_translate ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-25 06:06:05 -05:00
|
|
|
|
static PyObject* PyReference_translate ( PyReference *self, PyObject* args ) {
|
|
|
|
|
trace << "PyReference_translate ()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-25 06:06:05 -05:00
|
|
|
|
METHOD_HEAD ( "Reference.translate()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
PyObject* arg0;
|
|
|
|
|
PyObject* arg1;
|
|
|
|
|
|
|
|
|
|
HTRY
|
|
|
|
|
|
2008-03-25 06:06:05 -05:00
|
|
|
|
if ( ! ParseTwoArg ( "Reference.translate", args, INTS2_ARG, &arg0, &arg1 ) ) return ( NULL );
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-25 06:06:05 -05:00
|
|
|
|
reference->translate ( PyInt_AsLong(arg0), PyInt_AsLong(arg1) );
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
|
// PyReference Attribute Method table.
|
|
|
|
|
|
|
|
|
|
PyMethodDef PyReference_Methods[] =
|
2008-03-17 08:54:33 -05:00
|
|
|
|
{ { "destroy" , (PyCFunction)PyReference_destroy , METH_NOARGS
|
|
|
|
|
, "destroy associated hurricane object, the python object remains." }
|
|
|
|
|
, { "getName" , (PyCFunction)PyReference_getName , METH_NOARGS , "Returns the name of the reference." }
|
|
|
|
|
, { "getPoint" , (PyCFunction)PyReference_getPoint , METH_NOARGS , "Return the reference point." }
|
2008-03-25 06:06:05 -05:00
|
|
|
|
, { "translate" , (PyCFunction)PyReference_translate , METH_VARARGS, "Translate the reference of dx and dy." }
|
2008-03-06 10:46:43 -06:00
|
|
|
|
, {NULL, NULL, 0, NULL} /* sentinel */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// x-------------------------------------------------------------x
|
|
|
|
|
// | "PyReference" Object Methods |
|
|
|
|
|
// x-------------------------------------------------------------x
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
|
// Attribute Method : "PyReference_new ()"
|
|
|
|
|
|
|
|
|
|
static PyObject* PyReference_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
|
|
|
|
|
trace << "PyReference_new()" << endl;
|
|
|
|
|
|
|
|
|
|
PyObject* arg0;
|
|
|
|
|
PyObject* arg1;
|
|
|
|
|
PyObject* arg2;
|
|
|
|
|
PyObject* arg3;
|
|
|
|
|
Reference* reference = NULL;
|
|
|
|
|
|
|
|
|
|
HTRY
|
|
|
|
|
|
|
|
|
|
__cs.Init ("Reference.new");
|
|
|
|
|
if ( ! PyArg_ParseTuple(args,"O&O&O&|O&:Reference.new"
|
|
|
|
|
,Converter,&arg0
|
|
|
|
|
,Converter,&arg1
|
|
|
|
|
,Converter,&arg2
|
|
|
|
|
,Converter,&arg3
|
|
|
|
|
) ) return ( NULL );
|
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
if ( __cs.getObjectIds() == CELL_NAME_INTS2_ARG )
|
2008-03-18 04:42:44 -05:00
|
|
|
|
reference = Reference::create ( PYCELL_O(arg0)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
, *PYNAME_O(arg1)
|
|
|
|
|
, PyInt_AsLong(arg2)
|
|
|
|
|
, PyInt_AsLong(arg3) );
|
2008-03-17 08:54:33 -05:00
|
|
|
|
else if ( __cs.getObjectIds() == CELL_NAME_POINT_ARG )
|
2008-03-18 04:42:44 -05:00
|
|
|
|
reference = Reference::create ( PYCELL_O(arg0)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
, *PYNAME_O(arg1)
|
|
|
|
|
, *PYPOINT_O(arg2) );
|
|
|
|
|
else {
|
|
|
|
|
PyErr_SetString ( ConstructorError, "invalid number of parameters for Reference constructor." );
|
|
|
|
|
return ( NULL );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (reference == NULL) { printf("error of creation of reference \n"); return (NULL) ; }
|
|
|
|
|
|
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
|
|
return PyReference_Link ( reference );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DBoDeleteMethod(Reference)
|
|
|
|
|
PyTypeObjectLinkPyType(Reference)
|
|
|
|
|
PyTypeObjectConstructor(Reference)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# else // End of Python Module Code Part.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// x=================================================================x
|
|
|
|
|
// | "PyReference" Shared Library Code Part |
|
|
|
|
|
// x=================================================================x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Link/Creation Method.
|
2008-10-12 08:37:33 -05:00
|
|
|
|
DBoLinkCreateMethod(Reference)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
|
// PyReference Object Definitions.
|
2008-10-12 08:37:33 -05:00
|
|
|
|
PyTypeObjectDefinitions(Reference)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
2008-10-12 08:37:33 -05:00
|
|
|
|
#endif // End of Shared Library Code Part.
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // End of extern "C".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // End of Isobar namespace.
|
|
|
|
|
|