coriolis/hurricane/src/isobar/PyPin.cpp

226 lines
8.1 KiB
C++

// x-----------------------------------------------------------------x
// | |
// | C O R I O L I S |
// | I s o b a r - Hurricane / Python Interface |
// | |
// | Author : Damien DUPUIS |
// | E-mail : Damien.Dupuis@asim.lip6.fr |
// | =============================================================== |
// | C++ Module : "./PyPin.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/isobar/PyPin.h"
#include "hurricane/isobar/PyNet.h"
#include "hurricane/isobar/PyLayer.h"
namespace Isobar {
using namespace Hurricane;
extern "C" {
#undef ACCESS_OBJECT
#undef ACCESS_CLASS
#define ACCESS_OBJECT _baseObject._baseObject._baseObject._object
#define ACCESS_CLASS(_pyObject) &(_pyObject->_baseObject._baseObject._baseObject)
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Pin,pin,function)
// x=================================================================x
// | "PyPin" Python Module Code Part |
// x=================================================================x
#if defined(__PYTHON_MODULE__)
// x-------------------------------------------------------------x
// | Global Constants Loading |
// x-------------------------------------------------------------x
extern void PinLoadConstants ( PyObject* dictionnary ) {
PyObject* constant;
LOAD_CONSTANT ( Pin::PlacementStatus::UNPLACED , "PinPlacementStatusUNPLACED" )
LOAD_CONSTANT ( Pin::PlacementStatus::PLACED , "PinPlacementStatusPLACED" )
LOAD_CONSTANT ( Pin::PlacementStatus::FIXED , "PinPlacementStatusFIXED" )
LOAD_CONSTANT ( Pin::AccessDirection::UNDEFINED, "PinAccessDirectionUNDEFINED" )
LOAD_CONSTANT ( Pin::AccessDirection::NORTH , "PinAccessDirectionNORTH" )
LOAD_CONSTANT ( Pin::AccessDirection::SOUTH , "PinAccessDirectionSOUTH" )
LOAD_CONSTANT ( Pin::AccessDirection::EAST , "PinAccessDirectionEAST" )
LOAD_CONSTANT ( Pin::AccessDirection::WEST , "PinAccessDirectionWEST" )
}
// x-------------------------------------------------------------x
// | "PyPin" Attribute Methods |
// x-------------------------------------------------------------x
// Standart Accessors (Attributes).
PyObject* PyPin_getAccessDirection( PyPin* self ) {
trace << "PyNet_getAccessDirection ()" << endl;
METHOD_HEAD ( "Net.getAccessDirection()" )
return (PyObject *)Py_BuildValue("l", pin->getAccessDirection().getCode() );
}
// ---------------------------------------------------------------
// PyPin Attribute Method table.
PyMethodDef PyPin_Methods[] =
{ { "getAccessDirection" , (PyCFunction)PyPin_getAccessDirection , METH_NOARGS
, "Returns the pin accessdirection (by default set to UNDEFINED) ." }
, {NULL, NULL, 0, NULL} /* sentinel */
};
// x-------------------------------------------------------------x
// | "PyPin" Object Methods |
// x-------------------------------------------------------------x
static Pin::PlacementStatus PyInt_AsPlacementStatus ( PyObject* object ) {
switch ( PyInt_AsLong(object) ) {
case Pin::PlacementStatus::UNPLACED : return ( Pin::PlacementStatus(Pin::PlacementStatus::UNPLACED) );
case Pin::PlacementStatus::PLACED : return ( Pin::PlacementStatus(Pin::PlacementStatus::PLACED) );
case Pin::PlacementStatus::FIXED : return ( Pin::PlacementStatus(Pin::PlacementStatus::FIXED) );
}
return ( Pin::PlacementStatus(Pin::PlacementStatus::UNPLACED) );
}
static Pin::AccessDirection PyInt_AsAccessDirection ( PyObject* object ) {
switch ( PyInt_AsLong(object) ) {
case Pin::AccessDirection::UNDEFINED : return ( Pin::AccessDirection(Pin::AccessDirection::UNDEFINED) );
case Pin::AccessDirection::NORTH : return ( Pin::AccessDirection(Pin::AccessDirection::NORTH) );
case Pin::AccessDirection::SOUTH : return ( Pin::AccessDirection(Pin::AccessDirection::SOUTH) );
case Pin::AccessDirection::EAST : return ( Pin::AccessDirection(Pin::AccessDirection::EAST) );
case Pin::AccessDirection::WEST : return ( Pin::AccessDirection(Pin::AccessDirection::WEST) );
}
return ( Pin::AccessDirection(Pin::AccessDirection::UNDEFINED) );
}
// ---------------------------------------------------------------
// Attribute Method : "PyPin_new ()"
static PyObject* PyPin_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
Pin* pin = NULL;
HTRY
trace << "PyPin_new()" << endl;
PyObject* arg0;
PyObject* arg1;
PyObject* arg2;
PyObject* arg3;
PyObject* arg4;
PyObject* arg5;
PyObject* arg6;
PyObject* arg7;
PyObject* arg8;
__cs.init ("Pin.new");
if (!PyArg_ParseTuple(args,"O&O&O&O&O&O&O&|O&O&:Pin.new"
, Converter, &arg0
, Converter, &arg1
, Converter, &arg2
, Converter, &arg3
, Converter, &arg4
, Converter, &arg5
, Converter, &arg6
, Converter, &arg7
, Converter, &arg8
)) {
PyErr_SetString ( ConstructorError, "invalid number of parameters for Pin constructor." );
return NULL;
}
string pin_arg1 = ":ent:string:int:int:layer:int:int:int:int";
string pin_arg2 = ":ent:string:int:int:layer:int:int:int";
string pin_arg3 = ":ent:string:int:int:layer:int:int";
if ( __cs.getObjectIds() == pin_arg1 ) {
pin = Pin::create(
PYNET_O ( arg0 ),
Name(PyString_AsString(arg1)),
PyInt_AsAccessDirection ( arg2 ),
PyInt_AsPlacementStatus ( arg3 ),
PYLAYER_O ( arg4 ),
PyInt_AsLong ( arg5 ),
PyInt_AsLong ( arg6 ),
PyInt_AsLong ( arg7 ),
PyInt_AsLong ( arg8 ) );
} else if ( __cs.getObjectIds() == pin_arg2 ) {
pin = Pin::create (
PYNET_O ( arg0 ),
Name(PyString_AsString(arg1)),
PyInt_AsAccessDirection ( arg2 ),
PyInt_AsPlacementStatus ( arg3 ),
PYLAYER_O ( arg4 ),
PyInt_AsLong ( arg5 ),
PyInt_AsLong ( arg6 ),
PyInt_AsLong ( arg7 ) );
} else if ( __cs.getObjectIds() == pin_arg3 ) {
pin = Pin::create ( PYNET_O ( arg0 ),
Name(PyString_AsString(arg1)),
PyInt_AsAccessDirection ( arg2 ),
PyInt_AsPlacementStatus ( arg3 ),
PYLAYER_O ( arg4 ),
PyInt_AsLong ( arg5 ),
PyInt_AsLong ( arg6 ) );
} else {
PyErr_SetString ( ConstructorError, "invalid number of parameters for Pin constructor." );
return NULL;
}
HCATCH
return PyPin_Link ( pin );
}
DBoDeleteMethod(Pin)
PyTypeObjectLinkPyType(Pin)
PyTypeObjectConstructor(Pin)
#else // End of Python Module Code Part.
// x=================================================================x
// | "PyPin" Shared Library Code Part |
// x=================================================================x
// Link/Creation Method.
DBoLinkCreateMethod(Pin)
// ---------------------------------------------------------------
// PyPin Object Definitions.
PyTypeObjectDefinitions(Pin)
#endif // End of Shared Library Code Part.
} // End of extern "C".
} // End of Isobar namespace.