2008-03-06 10:46:43 -06:00
|
|
|
// 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
|
|
|
|
|
2008-05-21 17:46:29 -05:00
|
|
|
#include "hurricane/isobar/PyPin.h"
|
|
|
|
#include "hurricane/isobar/PyNet.h"
|
|
|
|
#include "hurricane/isobar/PyLayer.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" {
|
|
|
|
|
|
|
|
|
|
|
|
#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).
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
PyObject* PyPin_getAccessDirection( PyPin* self ) {
|
|
|
|
trace << "PyNet_getAccessDirection ()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
METHOD_HEAD ( "Net.getAccessDirection()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
return (PyObject *)Py_BuildValue("l", pin->getAccessDirection().getCode() );
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// PyPin Attribute Method table.
|
|
|
|
|
|
|
|
PyMethodDef PyPin_Methods[] =
|
2008-03-17 08:54:33 -05:00
|
|
|
{ { "getAccessDirection" , (PyCFunction)PyPin_getAccessDirection , METH_NOARGS
|
2008-03-06 10:46:43 -06:00
|
|
|
, "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;
|
|
|
|
|
2008-11-17 15:55:03 -06:00
|
|
|
__cs.init ("Pin.new");
|
2008-10-14 13:44:20 -05:00
|
|
|
if (!PyArg_ParseTuple(args,"O&O&O&O&O&O&O&|O&O&:Pin.new"
|
2008-03-06 10:46:43 -06:00
|
|
|
, Converter, &arg0
|
|
|
|
, Converter, &arg1
|
|
|
|
, Converter, &arg2
|
|
|
|
, Converter, &arg3
|
|
|
|
, Converter, &arg4
|
|
|
|
, Converter, &arg5
|
|
|
|
, Converter, &arg6
|
|
|
|
, Converter, &arg7
|
|
|
|
, Converter, &arg8
|
2008-10-14 13:44:20 -05:00
|
|
|
)) {
|
|
|
|
PyErr_SetString ( ConstructorError, "invalid number of parameters for Pin constructor." );
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-03-06 10:46:43 -06:00
|
|
|
|
2008-12-12 12:49:17 -06:00
|
|
|
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 {
|
2008-03-06 10:46:43 -06:00
|
|
|
PyErr_SetString ( ConstructorError, "invalid number of parameters for Pin constructor." );
|
2008-10-14 13:44:20 -05:00
|
|
|
return NULL;
|
2008-03-06 10:46:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
2008-10-12 08:37:33 -05:00
|
|
|
DBoLinkCreateMethod(Pin)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// PyPin Object Definitions.
|
|
|
|
|
2008-10-12 08:37:33 -05:00
|
|
|
PyTypeObjectDefinitions(Pin)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
#endif // End of Shared Library Code Part.
|
|
|
|
|
|
|
|
|
|
|
|
} // End of extern "C".
|
|
|
|
|
|
|
|
|
|
|
|
} // End of Isobar namespace.
|
|
|
|
|