coriolis/hurricane/src/isobar/PyPin.cpp

262 lines
10 KiB
C++
Raw Normal View History

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: PyPin.cpp,v 1.18 2008/02/07 17:09:41 xtof Exp $
//
// 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/PyName.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;
__cs.Init ("Pin.new");
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
)) {
PyErr_SetString ( ConstructorError, "invalid number of parameters for Pin constructor." );
return NULL;
}
2008-03-06 10:46:43 -06:00
string pin_arg1 = ":ent:name:int:int:layer:int:int:int:int";
string pin_arg2 = ":ent:name:int:int:layer:int:int:int";
string pin_arg3 = ":ent:name:int:int:layer:int:int";
2008-03-18 04:42:44 -05:00
if ( __cs.getObjectIds() == pin_arg1 ) { pin = Pin::create ( PYNET_O ( arg0 )
2008-03-06 10:46:43 -06:00
, *PYNAME_O ( arg1 )
, PyInt_AsAccessDirection ( arg2 )
, PyInt_AsPlacementStatus ( arg3 )
, PYLAYER_O ( arg4 )
, PyInt_AsLong ( arg5 )
, PyInt_AsLong ( arg6 )
, PyInt_AsLong ( arg7 )
, PyInt_AsLong ( arg8 ) ); }
2008-03-18 04:42:44 -05:00
else if ( __cs.getObjectIds() == pin_arg2 ) { pin = Pin::create ( PYNET_O ( arg0 )
2008-03-06 10:46:43 -06:00
, *PYNAME_O ( arg1 )
, PyInt_AsAccessDirection ( arg2 )
, PyInt_AsPlacementStatus ( arg3 )
, PYLAYER_O ( arg4 )
, PyInt_AsLong ( arg5 )
, PyInt_AsLong ( arg6 )
, PyInt_AsLong ( arg7 ) ); }
2008-03-18 04:42:44 -05:00
else if ( __cs.getObjectIds() == pin_arg3 ) { pin = Pin::create ( PYNET_O ( arg0 )
2008-03-06 10:46:43 -06:00
, *PYNAME_O ( 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;
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.
DBoLinkCreateMethod(Pin)
2008-03-06 10:46:43 -06:00
// ---------------------------------------------------------------
// PyPin Object Definitions.
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.