* ./hurricane/src/isobar:
- Change: In PyHurricane, add type object for all subtype of Component, then we can use the Python "isinstance()" function to know the true type of a component. Useful when looping over a collection of Component. Name clash: We have used the class name as the name of the constructor inside the Hurricane module, at a time we where less acquainted with Python, so the real class are named 'PyVertical' for example, while 'Hurricane' is the constructor function. Should correct this in the future but it's a huge work as all the Python scripts must be editeds... - Change: In PyNet, adds the "getComponents()" Collection accessor. - New: In Occurrence, added method getCompactString() to display a more compact version of the occurrence. - New: PyQuery & PyQueryMask expose the Query classe. Only partially implemented, and with the start of the template based interface disabled.
This commit is contained in:
parent
e8565d0fb5
commit
9724cef332
|
@ -216,6 +216,24 @@ string Occurrence::_getString() const
|
|||
return s;
|
||||
}
|
||||
|
||||
string Occurrence::getCompactString() const
|
||||
// ****************************************
|
||||
{
|
||||
string s = "<";
|
||||
if (_entity) {
|
||||
s += getString(getOwnerCell()->getName());
|
||||
s += ":";
|
||||
if (_sharedPath) s += getString(_sharedPath->getName()) + ":";
|
||||
Instance* instance = dynamic_cast<Instance*>(_entity);
|
||||
if (instance)
|
||||
s += getString(instance->getName());
|
||||
else
|
||||
s += getString(_entity);
|
||||
}
|
||||
s += ">";
|
||||
return s;
|
||||
}
|
||||
|
||||
Record* Occurrence::_getRecord() const
|
||||
// ****************************
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
//
|
||||
// Copyright (c) BULL S.A. 2000-2009, All Rights Reserved
|
||||
// Copyright (c) BULL S.A. 2000-2013, All Rights Reserved
|
||||
//
|
||||
// This file is part of Hurricane.
|
||||
//
|
||||
|
@ -23,8 +23,7 @@
|
|||
//
|
||||
// $Id$
|
||||
//
|
||||
// x-----------------------------------------------------------------x
|
||||
// | |
|
||||
// +-----------------------------------------------------------------+
|
||||
// | H U R R I C A N E |
|
||||
// | V L S I B a c k e n d D a t a - B a s e |
|
||||
// | |
|
||||
|
@ -32,10 +31,7 @@
|
|||
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Module : "./Query.cpp" |
|
||||
// | *************************************************************** |
|
||||
// | U p d a t e s |
|
||||
// | |
|
||||
// x-----------------------------------------------------------------x
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#include <limits>
|
||||
|
@ -151,7 +147,7 @@ namespace Hurricane {
|
|||
}
|
||||
|
||||
if ( hasExtensionGoCallback() and (_filter.isSet(DoExtensionGos)) ) {
|
||||
if ( not getMasterCell()->isTerminal() or (_filter.isSet(DoTerminalCells)) ) {
|
||||
if ( (not getMasterCell()->isTerminal()) or (_filter.isSet(DoTerminalCells)) ) {
|
||||
forEach ( ExtensionSlice*, islice, getMasterCell()->getExtensionSlices() ) {
|
||||
if ( not ( (*islice)->getMask() & _extensionMask ) ) continue;
|
||||
if ( not (*islice)->getBoundingBox().intersect(getArea()) ) continue;
|
||||
|
|
|
@ -96,6 +96,7 @@ class Occurrence {
|
|||
public: string getName() const;
|
||||
public: string _getTypeName() const { return _TName("Occurrence"); };
|
||||
public: string _getString() const;
|
||||
public: string getCompactString() const;
|
||||
public: Record* _getRecord() const;
|
||||
public: SharedPath* _getSharedPath() const {return _sharedPath;};
|
||||
public: Quark* _getQuark() const;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
//
|
||||
// Copyright (c) BULL S.A. 2000-2009, All Rights Reserved
|
||||
// Copyright (c) BULL S.A. 2000-2013, All Rights Reserved
|
||||
//
|
||||
// This file is part of Hurricane.
|
||||
//
|
||||
|
@ -23,8 +23,7 @@
|
|||
//
|
||||
// $Id$
|
||||
//
|
||||
// x-----------------------------------------------------------------x
|
||||
// | |
|
||||
// +-----------------------------------------------------------------+
|
||||
// | H U R R I C A N E |
|
||||
// | V L S I B a c k e n d D a t a - B a s e |
|
||||
// | |
|
||||
|
@ -32,10 +31,7 @@
|
|||
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./hurricane/Query.h" |
|
||||
// | *************************************************************** |
|
||||
// | U p d a t e s |
|
||||
// | |
|
||||
// x-----------------------------------------------------------------x
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#ifndef __QUERY_H__
|
||||
|
@ -298,7 +294,6 @@ namespace Hurricane {
|
|||
// -------------------------------------------------------------------
|
||||
// Class : "Query".
|
||||
|
||||
|
||||
class Query {
|
||||
public:
|
||||
typedef Hurricane::Mask<int> Mask;
|
||||
|
@ -310,12 +305,12 @@ namespace Hurricane {
|
|||
, DoMarkers = 8
|
||||
, DoRubbers = 16
|
||||
, DoExtensionGos = 32
|
||||
, DoAll = DoMasterCells
|
||||
| DoTerminalCells
|
||||
| DoComponents
|
||||
| DoMarkers
|
||||
| DoRubbers
|
||||
| DoExtensionGos
|
||||
, DoAll = DoMasterCells
|
||||
| DoTerminalCells
|
||||
| DoComponents
|
||||
| DoMarkers
|
||||
| DoRubbers
|
||||
| DoExtensionGos
|
||||
};
|
||||
public:
|
||||
// Constructors & Destructors.
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
PyDbU.cpp
|
||||
PyUpdateSession.cpp
|
||||
PyVertical.cpp
|
||||
PyQueryMask.cpp
|
||||
PyQuery.cpp
|
||||
)
|
||||
set ( includes hurricane/isobar/ProxyProperty.h
|
||||
hurricane/isobar/PyBreakpoint.h
|
||||
|
@ -107,6 +109,8 @@
|
|||
hurricane/isobar/PyDbU.h
|
||||
hurricane/isobar/PyUpdateSession.h
|
||||
hurricane/isobar/PyVertical.h
|
||||
hurricane/isobar/PyQueryMask.h
|
||||
hurricane/isobar/PyQuery.h
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -94,6 +94,8 @@
|
|||
#include "hurricane/isobar/PyOccurrence.h"
|
||||
#include "hurricane/isobar/PyOccurrenceCollection.h"
|
||||
#include "hurricane/isobar/PyTechnology.h"
|
||||
#include "hurricane/isobar/PyQueryMask.h"
|
||||
#include "hurricane/isobar/PyQuery.h"
|
||||
#include "hurricane/NetExternalComponents.h"
|
||||
#include <stddef.h>
|
||||
|
||||
|
@ -583,6 +585,8 @@ extern "C" {
|
|||
PyPin_LinkPyType ();
|
||||
PyPlug_LinkPyType ();
|
||||
PyBreakpoint_LinkPyType ();
|
||||
PyQuery_LinkPyType ();
|
||||
PyQueryMask_LinkPyType ();
|
||||
|
||||
PYTYPE_READY ( UpdateSession )
|
||||
PYTYPE_READY ( Point )
|
||||
|
@ -627,6 +631,8 @@ extern "C" {
|
|||
PYTYPE_READY ( HyperNet )
|
||||
PYTYPE_READY ( NetExternalComponents )
|
||||
PYTYPE_READY ( Breakpoint )
|
||||
PYTYPE_READY ( Query )
|
||||
PYTYPE_READY ( QueryMask )
|
||||
|
||||
PYTYPE_READY_SUB ( BasicLayer , Layer )
|
||||
PYTYPE_READY_SUB ( RegularLayer , Layer )
|
||||
|
@ -702,6 +708,8 @@ extern "C" {
|
|||
__cs.addType ( "path" , &PyTypePath , "<Path>" , false );
|
||||
__cs.addType ( "occur" , &PyTypeOccurrence , "<Occurrence>" , false );
|
||||
__cs.addType ( "occurCol" , &PyTypeOccurrenceCollection , "<OccurrenceCollection>" , false );
|
||||
__cs.addType ( "query" , &PyTypeQuery , "<Query>" , false );
|
||||
__cs.addType ( "qmask" , &PyTypeQueryMask , "<Query::Mask>" , false );
|
||||
|
||||
|
||||
PyObject* module = Py_InitModule ( "Hurricane", PyHurricane_Methods );
|
||||
|
@ -737,6 +745,19 @@ extern "C" {
|
|||
PyModule_AddObject ( module, "UpdateSession" , (PyObject*)&PyTypeUpdateSession );
|
||||
Py_INCREF ( &PyTypeBreakpoint );
|
||||
PyModule_AddObject ( module, "Breakpoint" , (PyObject*)&PyTypeBreakpoint );
|
||||
Py_INCREF ( &PyTypeQuery );
|
||||
PyModule_AddObject ( module, "Query" , (PyObject*)&PyTypeQuery );
|
||||
|
||||
Py_INCREF ( &PyTypeVertical );
|
||||
PyModule_AddObject ( module, "PyVertical" , (PyObject*)&PyTypeVertical );
|
||||
Py_INCREF ( &PyTypeHorizontal );
|
||||
PyModule_AddObject ( module, "PyHorizontal" , (PyObject*)&PyTypeHorizontal );
|
||||
Py_INCREF ( &PyTypeContact );
|
||||
PyModule_AddObject ( module, "PyContact" , (PyObject*)&PyTypeContact );
|
||||
Py_INCREF ( &PyTypePlug );
|
||||
PyModule_AddObject ( module, "PyPlug" , (PyObject*)&PyTypePlug );
|
||||
Py_INCREF ( &PyTypePad );
|
||||
PyModule_AddObject ( module, "PyPad" , (PyObject*)&PyTypePad );
|
||||
|
||||
|
||||
PyObject* dictionnary = PyModule_GetDict ( module );
|
||||
|
|
|
@ -249,6 +249,30 @@ extern "C" {
|
|||
return (PyObject*)pyPinCollection;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Attribute Method : "PyNet_getComponents()"
|
||||
|
||||
static PyObject* PyNet_getComponents(PyNet *self) {
|
||||
trace << "PyNet_getComponents()" << endl;
|
||||
|
||||
METHOD_HEAD ( "Net.getComponents()" )
|
||||
|
||||
PyComponentCollection* pyComponentCollection = NULL;
|
||||
|
||||
HTRY
|
||||
Components* components = new Components(net->getComponents());
|
||||
|
||||
pyComponentCollection = PyObject_NEW(PyComponentCollection, &PyTypeComponentCollection);
|
||||
if (pyComponentCollection == NULL) return NULL;
|
||||
|
||||
pyComponentCollection->_object = components;
|
||||
HCATCH
|
||||
|
||||
return (PyObject*)pyComponentCollection;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Attribute Method : "PyNet_getExternalComponents()"
|
||||
|
||||
|
@ -274,8 +298,6 @@ extern "C" {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Attribute Method : "PyNet_setName ()"
|
||||
|
||||
|
@ -428,34 +450,31 @@ extern "C" {
|
|||
|
||||
PyMethodDef PyNet_Methods[] =
|
||||
{ { "getName" , (PyCFunction)PyNet_getName , METH_NOARGS , "Returns the net name." }
|
||||
, { "getType" , (PyCFunction)PyNet_getType , METH_NOARGS
|
||||
, "Returns the signal type (by default set to UNDEFINED)." }
|
||||
, { "getDirection" , (PyCFunction)PyNet_getDirection , METH_NOARGS
|
||||
, "Returns the signal direction (by default set to UNDEFINED)." }
|
||||
, { "getType" , (PyCFunction)PyNet_getType , METH_NOARGS , "Returns the signal type (by default set to UNDEFINED)." }
|
||||
, { "getDirection" , (PyCFunction)PyNet_getDirection , METH_NOARGS , "Returns the signal direction (by default set to UNDEFINED)." }
|
||||
, { "getX" , (PyCFunction)PyNet_getX , METH_NOARGS , "Returns net abscissa." }
|
||||
, { "getY" , (PyCFunction)PyNet_getY , METH_NOARGS , "Returns net ordinate." }
|
||||
, { "getExternalComponents", (PyCFunction)PyNet_getExternalComponents , METH_NOARGS , "Returns the collection of net's external components. (only for an external net)" }
|
||||
, { "getPlugs" , (PyCFunction)PyNet_getPlugs , METH_NOARGS , "Returns the collection of net's plugs." }
|
||||
, { "getPins" , (PyCFunction)PyNet_getPins , METH_NOARGS , "Returns the collection of net's pins." }
|
||||
, { "getSegments" , (PyCFunction)PyNet_getSegments , METH_NOARGS , "Returns the collection of net's segments." }
|
||||
, { "isGlobal" , (PyCFunction)PyNet_isGlobal , METH_NOARGS, "return true if the net is global" }
|
||||
, { "isExternal" , (PyCFunction)PyNet_isExternal , METH_NOARGS, "return true if the the net is external." }
|
||||
, { "isLogical" , (PyCFunction)PyNet_isLogical , METH_NOARGS, "return true if the net is logical ." }
|
||||
, { "isClock" , (PyCFunction)PyNet_isClock , METH_NOARGS, "return true if the net is a clock" }
|
||||
, { "isPower" , (PyCFunction)PyNet_isPower , METH_NOARGS, "return true if the net is a power" }
|
||||
, { "isGround" , (PyCFunction)PyNet_isGround , METH_NOARGS, "return true if the net is a ground" }
|
||||
, { "isSupply" , (PyCFunction)PyNet_isSupply , METH_NOARGS, "return true if the net is a supply" }
|
||||
, { "isBound" , (PyCFunction)PyNet_IsPyBound , METH_NOARGS, "return true if the net is bounded to the hurricane net" }
|
||||
, { "getComponents" , (PyCFunction)PyNet_getComponents , METH_NOARGS , "Returns the collection of net's external components. (only for an external net)" }
|
||||
, { "getExternalComponents", (PyCFunction)PyNet_getExternalComponents , METH_NOARGS , "Returns the collection of net's external components. (only for an external net)" }
|
||||
, { "getPlugs" , (PyCFunction)PyNet_getPlugs , METH_NOARGS , "Returns the collection of net's plugs." }
|
||||
, { "getPins" , (PyCFunction)PyNet_getPins , METH_NOARGS , "Returns the collection of net's pins." }
|
||||
, { "getSegments" , (PyCFunction)PyNet_getSegments , METH_NOARGS , "Returns the collection of net's segments." }
|
||||
, { "isGlobal" , (PyCFunction)PyNet_isGlobal , METH_NOARGS , "return true if the net is global" }
|
||||
, { "isExternal" , (PyCFunction)PyNet_isExternal , METH_NOARGS , "return true if the the net is external." }
|
||||
, { "isLogical" , (PyCFunction)PyNet_isLogical , METH_NOARGS , "return true if the net is logical ." }
|
||||
, { "isClock" , (PyCFunction)PyNet_isClock , METH_NOARGS , "return true if the net is a clock" }
|
||||
, { "isPower" , (PyCFunction)PyNet_isPower , METH_NOARGS , "return true if the net is a power" }
|
||||
, { "isGround" , (PyCFunction)PyNet_isGround , METH_NOARGS , "return true if the net is a ground" }
|
||||
, { "isSupply" , (PyCFunction)PyNet_isSupply , METH_NOARGS , "return true if the net is a supply" }
|
||||
, { "isBound" , (PyCFunction)PyNet_IsPyBound , METH_NOARGS , "return true if the net is bounded to the hurricane net" }
|
||||
, { "setName" , (PyCFunction)PyNet_setName , METH_VARARGS, "Allows to change net name." }
|
||||
, { "setGlobal" , (PyCFunction)PyNet_setGlobal , METH_VARARGS, "set the net global." }
|
||||
, { "setExternal" , (PyCFunction)PyNet_setExternal , METH_VARARGS, "set the net external." }
|
||||
, { "setType" , (PyCFunction)PyNet_setType , METH_VARARGS, "set the type of the net." }
|
||||
, { "setDirection" , (PyCFunction)PyNet_setDirection , METH_VARARGS, "set the direction of the net." }
|
||||
, { "setPosition" , (PyCFunction)PyNet_setPosition , METH_VARARGS, "set the X,Y location of the net." }
|
||||
, { "merge" , (PyCFunction)PyNet_merge , METH_VARARGS
|
||||
, "Merges the net <net> to the net <this> which keeps its characteristics (arity, global, external and direction)." }
|
||||
, { "destroy" , (PyCFunction)PyNet_destroy , METH_NOARGS
|
||||
, "Destroy associated hurricane object, the python object remains." }
|
||||
, { "merge" , (PyCFunction)PyNet_merge , METH_VARARGS, "Merges the net <net> to the net <this> which keeps its characteristics (arity, global, external and direction)." }
|
||||
, { "destroy" , (PyCFunction)PyNet_destroy , METH_NOARGS , "Destroy associated hurricane object, the python object remains." }
|
||||
, {NULL, NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,593 @@
|
|||
|
||||
// -*- 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é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
|
||||
//
|
||||
// +-----------------------------------------------------------------+
|
||||
// | 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@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Module : "./PyQuery.cpp" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#include "hurricane/isobar/PyBox.h"
|
||||
#include "hurricane/isobar/PyTransformation.h"
|
||||
#include "hurricane/isobar/PyBasicLayer.h"
|
||||
#include "hurricane/isobar/PyCell.h"
|
||||
#include "hurricane/isobar/PyEntity.h"
|
||||
#include "hurricane/isobar/PyQuery.h"
|
||||
#include "hurricane/isobar/PyQueryMask.h"
|
||||
|
||||
|
||||
namespace Isobar {
|
||||
|
||||
using namespace Hurricane;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
class BaseQuery : public Query {
|
||||
public:
|
||||
BaseQuery ( PyQuery* );
|
||||
public:
|
||||
virtual bool hasGoCallback () const;
|
||||
virtual bool hasMarkerCallback () const;
|
||||
virtual bool hasRubberCallback () const;
|
||||
virtual bool hasExtensionGoCallback () const;
|
||||
virtual bool hasMasterCellCallback () const;
|
||||
virtual void goCallback ( Go* );
|
||||
virtual void markerCallback ( Marker* );
|
||||
virtual void rubberCallback ( Rubber* );
|
||||
virtual void extensionGoCallback ( Go* );
|
||||
virtual void masterCellCallback ();
|
||||
inline void setGoCallback ( PyObject* );
|
||||
inline void setMarkerCallback ( PyObject* );
|
||||
inline void setRubberCallback ( PyObject* );
|
||||
inline void setExtensionGoCallback ( PyObject* );
|
||||
inline void setMasterCellCallback ( PyObject* );
|
||||
private:
|
||||
PyQuery* _self;
|
||||
PyObject* _goCallback;
|
||||
PyObject* _markerCallback;
|
||||
PyObject* _rubberCallback;
|
||||
PyObject* _extensionGoCallback;
|
||||
PyObject* _masterCellCallback;
|
||||
};
|
||||
|
||||
|
||||
BaseQuery::BaseQuery ( PyQuery* self )
|
||||
: Query()
|
||||
, _self (self)
|
||||
, _goCallback (NULL)
|
||||
, _markerCallback (NULL)
|
||||
, _rubberCallback (NULL)
|
||||
, _extensionGoCallback(NULL)
|
||||
, _masterCellCallback (NULL)
|
||||
{ }
|
||||
|
||||
inline void BaseQuery::setGoCallback ( PyObject* cb ) { _goCallback = cb; cerr << "BaseQuery::setGoCallback()" << endl; }
|
||||
inline void BaseQuery::setMarkerCallback ( PyObject* cb ) { _markerCallback = cb; }
|
||||
inline void BaseQuery::setRubberCallback ( PyObject* cb ) { _rubberCallback = cb; }
|
||||
inline void BaseQuery::setExtensionGoCallback ( PyObject* cb ) { _extensionGoCallback = cb; }
|
||||
inline void BaseQuery::setMasterCellCallback ( PyObject* cb ) { _masterCellCallback = cb; }
|
||||
|
||||
bool BaseQuery::hasGoCallback () const { cerr << "BaseQuery::hasGoCallback():" << _goCallback << endl; return _goCallback != NULL; }
|
||||
bool BaseQuery::hasMarkerCallback () const { return _markerCallback != NULL; }
|
||||
bool BaseQuery::hasRubberCallback () const { return _rubberCallback != NULL; }
|
||||
bool BaseQuery::hasExtensionGoCallback () const { return _extensionGoCallback != NULL; }
|
||||
bool BaseQuery::hasMasterCellCallback () const { return _masterCellCallback != NULL; }
|
||||
|
||||
void BaseQuery::goCallback ( Go* go )
|
||||
{
|
||||
cerr << "BaseQuery::goCallback():" << go << endl;
|
||||
if (PyCallable_Check(_goCallback)) {
|
||||
PyObject_CallFunctionObjArgs( _goCallback, _self, PyEntity_NEW(go), NULL );
|
||||
}
|
||||
}
|
||||
|
||||
void BaseQuery::markerCallback ( Marker* marker )
|
||||
{
|
||||
if (PyCallable_Check(_markerCallback))
|
||||
PyObject_CallFunctionObjArgs( _markerCallback, _self, NULL );
|
||||
}
|
||||
|
||||
void BaseQuery::rubberCallback ( Rubber* rubber )
|
||||
{
|
||||
if (PyCallable_Check(_rubberCallback))
|
||||
PyObject_CallFunctionObjArgs( _rubberCallback, _self, NULL );
|
||||
}
|
||||
|
||||
void BaseQuery::extensionGoCallback ( Go* go )
|
||||
{
|
||||
if (PyCallable_Check(_extensionGoCallback))
|
||||
PyObject_CallFunctionObjArgs( _extensionGoCallback, _self, NULL );
|
||||
}
|
||||
|
||||
void BaseQuery::masterCellCallback ()
|
||||
{
|
||||
if (PyCallable_Check(_masterCellCallback))
|
||||
PyObject_CallFunctionObjArgs( _masterCellCallback, _self, NULL );
|
||||
}
|
||||
|
||||
|
||||
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Query,query,function)
|
||||
|
||||
|
||||
// +=================================================================+
|
||||
// | "PyQuery" Python Module Code Part |
|
||||
// +=================================================================+
|
||||
|
||||
#if defined(__PYTHON_MODULE__)
|
||||
|
||||
|
||||
#if 0
|
||||
template< typename PySelf, typename Self, typename RType, typename... Args >
|
||||
class PySetFunctor {
|
||||
public:
|
||||
typedef PyObject* (PySet_fp) ( PySelf*, PyObject* );
|
||||
typedef RType (Self::* CppSet_fp) ( Args... );
|
||||
public:
|
||||
inline PySet_fp wrapper() const;
|
||||
private:
|
||||
static PyObject* _wrapper ( PySelf* self, PyObject* args )
|
||||
{
|
||||
}
|
||||
private:
|
||||
CppSet_fp _fp;
|
||||
string _name;
|
||||
};
|
||||
|
||||
template< typename PySelf, typename Self, typename RType, typename... Args >
|
||||
inline PySetFunctor<PySelf,Self,RType,Args>::PySet_fp PySetFunctor<PySelf,Self,RType,Args>::wrapper() const
|
||||
{ return _wrapper; }
|
||||
#endif
|
||||
|
||||
|
||||
// +-------------------------------------------------------------+
|
||||
// | "PyQuery" Attribute Methods |
|
||||
// +-------------------------------------------------------------+
|
||||
|
||||
|
||||
#if WORK_IN_PROGRESS
|
||||
static MethodDefTable<PyQuery,64> pyObjectMethods;
|
||||
|
||||
template< typename CppType, typename PySelf >
|
||||
inline CppType* getCppObject ( PySelf* self, const string& methodName )
|
||||
{
|
||||
if (self._object == NULL) {
|
||||
string message = "Attempt to call "+methodName+"on an unbound hurricane object.";
|
||||
PyErr_SetString( ProxyError, message.c_str() );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CppType* cppObject = dynamic_cast<CppType*>(self._object);
|
||||
if (cppObject == NULL) {
|
||||
string message = "Invalid dynamic_cast<>() in "+methodName+" (internal error).";
|
||||
PyErr_SetString( ProxyError, message.c_str() );
|
||||
return NULL;
|
||||
}
|
||||
return cppObject;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template< typename CppType, typename PySelf, typename ReturnType, typename PyReturnType, int fdefindex >
|
||||
PyType* accessor ( PySelf* self ) {
|
||||
string methodName = pyObjectMethods.getFullMethodName(fdefindex);
|
||||
|
||||
trace << methodName << endl;
|
||||
|
||||
ReturnType* value = NULL;
|
||||
try {
|
||||
CppType* cppThis = getCppObject<CppType,PySelf>( self );
|
||||
if (cppThis == NULL) return NULL;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static PyObject* PyQuery_getMasterCell ( PyQuery *self ) {
|
||||
trace << "PyQuery.getMasterCell()" << endl;
|
||||
|
||||
Cell* cell = NULL;
|
||||
|
||||
HTRY
|
||||
METHOD_HEAD("PyQuery.getMasterCell()")
|
||||
cell = query->getMasterCell();
|
||||
HCATCH
|
||||
|
||||
return PyCell_Link(cell);
|
||||
}
|
||||
|
||||
|
||||
static PyObject* PyQuery_setCell ( PyQuery* self, PyObject* args )
|
||||
{
|
||||
trace << "PyQuery.setCell()" << endl;
|
||||
METHOD_HEAD("PyQuery.setCell()")
|
||||
|
||||
HTRY
|
||||
PyObject* pyCell = NULL;
|
||||
|
||||
if (PyArg_ParseTuple(args,"O:Query.setCell()",&pyCell) ) {
|
||||
if (not IsPyCell(pyCell)) {
|
||||
PyErr_SetString ( ConstructorError, "Query.setCell(): Argument is not of type Cell." );
|
||||
return NULL;
|
||||
}
|
||||
query->setCell( PYCELL_O(pyCell) );
|
||||
} else {
|
||||
PyErr_SetString ( ConstructorError, "Bad parameters given to Query.setCell()." );
|
||||
return NULL;
|
||||
}
|
||||
HCATCH
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
static PyObject* PyQuery_setArea ( PyQuery* self, PyObject* args )
|
||||
{
|
||||
trace << "PyQuery.setArea()" << endl;
|
||||
METHOD_HEAD("PyQuery.setArea()")
|
||||
|
||||
HTRY
|
||||
PyObject* pyBox = NULL;
|
||||
|
||||
if (PyArg_ParseTuple(args,"O:Query.setArea()",&pyBox) ) {
|
||||
if (not IsPyBox(pyBox)) {
|
||||
PyErr_SetString ( ConstructorError, "Query.setArea(): Argument is not of type Box." );
|
||||
return NULL;
|
||||
}
|
||||
query->setArea( *PYBOX_O(pyBox) );
|
||||
} else {
|
||||
PyErr_SetString ( ConstructorError, "Bad parameters given to Query.setArea()." );
|
||||
return NULL;
|
||||
}
|
||||
HCATCH
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
static PyObject* PyQuery_setTransformation ( PyQuery* self, PyObject* args )
|
||||
{
|
||||
trace << "PyQuery.setTransformation()" << endl;
|
||||
METHOD_HEAD("PyQuery.setTransformation()")
|
||||
|
||||
HTRY
|
||||
PyObject* pyTransformation = NULL;
|
||||
|
||||
if (PyArg_ParseTuple(args,"O:Query.setTransformation()",&pyTransformation) ) {
|
||||
if (not IsPyTransformation(pyTransformation)) {
|
||||
PyErr_SetString ( ConstructorError, "Query.setTransformation(): Argument is not of type Transformation." );
|
||||
return NULL;
|
||||
}
|
||||
query->setTransformation( *PYTRANSFORMATION_O(pyTransformation) );
|
||||
} else {
|
||||
PyErr_SetString ( ConstructorError, "Bad parameters given to Query.setTransformation()." );
|
||||
return NULL;
|
||||
}
|
||||
HCATCH
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
static PyObject* PyQuery_setBasicLayer ( PyQuery* self, PyObject* args )
|
||||
{
|
||||
trace << "PyQuery.setBasicLayer()" << endl;
|
||||
METHOD_HEAD("PyQuery.setBasicLayer()")
|
||||
|
||||
HTRY
|
||||
PyObject* pyBasicLayer = NULL;
|
||||
|
||||
if (PyArg_ParseTuple(args,"O:Query.setBasicLayer()",&pyBasicLayer) ) {
|
||||
if (not IsPyBasicLayer(pyBasicLayer)) {
|
||||
PyErr_SetString ( ConstructorError, "Query.setBasicLayer(): Argument is not of type BasicLayer." );
|
||||
return NULL;
|
||||
}
|
||||
query->setBasicLayer( PYBASICLAYER_O(pyBasicLayer) );
|
||||
} else {
|
||||
PyErr_SetString ( ConstructorError, "Bad parameters given to Query.setBasicLayer()." );
|
||||
return NULL;
|
||||
}
|
||||
HCATCH
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
static PyObject* PyQuery_setMasterCellCallback ( PyQuery* self, PyObject* args )
|
||||
{
|
||||
trace << "PyQuery.setMasterCellCallback()" << endl;
|
||||
METHOD_HEAD("PyQuery.setMasterCellCallback()")
|
||||
|
||||
HTRY
|
||||
PyObject* pyCallback = NULL;
|
||||
|
||||
if (PyArg_ParseTuple(args,"O:Query.setMasterCellCallback()",&pyCallback) ) {
|
||||
if (not PyCallable_Check(pyCallback)) {
|
||||
PyErr_SetString ( ConstructorError, "Query.setMasterCellCallback(): Argument is not callable." );
|
||||
return NULL;
|
||||
}
|
||||
dynamic_cast<BaseQuery*>(query)->setMasterCellCallback( pyCallback );
|
||||
} else {
|
||||
PyErr_SetString ( ConstructorError, "Bad parameters given to Query.setMasterCellCallback()." );
|
||||
return NULL;
|
||||
}
|
||||
HCATCH
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
static PyObject* PyQuery_setGoCallback ( PyQuery* self, PyObject* args )
|
||||
{
|
||||
trace << "PyQuery.setGoCallback()" << endl;
|
||||
METHOD_HEAD("PyQuery.setGoCallback()")
|
||||
|
||||
HTRY
|
||||
PyObject* pyCallback = NULL;
|
||||
|
||||
if (PyArg_ParseTuple(args,"O:Query.setGoCallback()",&pyCallback) ) {
|
||||
if (not PyCallable_Check(pyCallback)) {
|
||||
PyErr_SetString ( ConstructorError, "Query.setGoCallback(): Argument is not callable." );
|
||||
return NULL;
|
||||
}
|
||||
dynamic_cast<BaseQuery*>(query)->setGoCallback( pyCallback );
|
||||
} else {
|
||||
PyErr_SetString ( ConstructorError, "Bad parameters given to Query.setGoCallback()." );
|
||||
return NULL;
|
||||
}
|
||||
HCATCH
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
static PyObject* PyQuery_setMarkerCallback ( PyQuery* self, PyObject* args )
|
||||
{
|
||||
trace << "PyQuery.setMarkerCallback()" << endl;
|
||||
METHOD_HEAD("PyQuery.setMarkerCallback()")
|
||||
|
||||
HTRY
|
||||
PyObject* pyCallback = NULL;
|
||||
|
||||
if (PyArg_ParseTuple(args,"O:Query.setMarkerCallback()",&pyCallback) ) {
|
||||
if (not PyCallable_Check(pyCallback)) {
|
||||
PyErr_SetString ( ConstructorError, "Query.setMarkerCallback(): Argument is not callable." );
|
||||
return NULL;
|
||||
}
|
||||
dynamic_cast<BaseQuery*>(query)->setMarkerCallback( pyCallback );
|
||||
} else {
|
||||
PyErr_SetString ( ConstructorError, "Bad parameters given to Query.setMarkerCallback()." );
|
||||
return NULL;
|
||||
}
|
||||
HCATCH
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
static PyObject* PyQuery_setRubberCallback ( PyQuery* self, PyObject* args )
|
||||
{
|
||||
trace << "PyQuery.setRubberCallback()" << endl;
|
||||
METHOD_HEAD("PyQuery.setRubberCallback()")
|
||||
|
||||
HTRY
|
||||
PyObject* pyCallback = NULL;
|
||||
|
||||
if (PyArg_ParseTuple(args,"O:Query.setRubberCallback()",&pyCallback) ) {
|
||||
if (not PyCallable_Check(pyCallback)) {
|
||||
PyErr_SetString ( ConstructorError, "Query.setRubberCallback(): Argument is not callable." );
|
||||
return NULL;
|
||||
}
|
||||
dynamic_cast<BaseQuery*>(query)->setRubberCallback( pyCallback );
|
||||
} else {
|
||||
PyErr_SetString ( ConstructorError, "Bad parameters given to Query.setRubberCallback()." );
|
||||
return NULL;
|
||||
}
|
||||
HCATCH
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
static PyObject* PyQuery_setExtensionGoCallback ( PyQuery* self, PyObject* args )
|
||||
{
|
||||
trace << "PyQuery.setExtensionGoCallback()" << endl;
|
||||
METHOD_HEAD("PyQuery.setExtensionGoCallback()")
|
||||
|
||||
HTRY
|
||||
PyObject* pyCallback = NULL;
|
||||
|
||||
if (PyArg_ParseTuple(args,"O:Query.setExtensionGoCallback()",&pyCallback) ) {
|
||||
if (not PyCallable_Check(pyCallback)) {
|
||||
PyErr_SetString ( ConstructorError, "Query.setExtensionGoCallback(): Argument is not callable." );
|
||||
return NULL;
|
||||
}
|
||||
dynamic_cast<BaseQuery*>(query)->setExtensionGoCallback( pyCallback );
|
||||
} else {
|
||||
PyErr_SetString ( ConstructorError, "Bad parameters given to Query.setExtensionGoCallback()." );
|
||||
return NULL;
|
||||
}
|
||||
HCATCH
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyObject* PyQuery_NEW ( PyObject* module, PyObject* args )
|
||||
{
|
||||
trace << "PyQuery.new()" << endl;
|
||||
|
||||
Query* query = NULL;
|
||||
PyQuery* pyQuery = NULL;
|
||||
|
||||
HTRY
|
||||
pyQuery = PyObject_NEW( PyQuery, &PyTypeQuery );
|
||||
if (pyQuery == NULL) return NULL;
|
||||
query = new BaseQuery( pyQuery );
|
||||
pyQuery->_object = query;
|
||||
|
||||
cerr << "PyQuery_NEW(): " << (void*)pyQuery << endl;
|
||||
HCATCH
|
||||
|
||||
return (PyObject*)pyQuery;
|
||||
}
|
||||
|
||||
|
||||
int PyQuery_Init ( PyQuery* self, PyObject* args, PyObject* kwargs )
|
||||
{
|
||||
cerr << "PyQuery_Init(): " << (void*)self << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DirectVoidMethod(Query,query,doQuery)
|
||||
|
||||
// Standart destroy (Attribute).
|
||||
//DBoDestroyAttribute(PyQuery_destroy, PyQuery)
|
||||
|
||||
|
||||
PyMethodDef PyQuery_Methods[] =
|
||||
{ { "getMasterCell" , (PyCFunction)PyQuery_getMasterCell , METH_NOARGS
|
||||
, "Returns the master Cell currently under exploration." }
|
||||
, { "setCell" , (PyCFunction)PyQuery_setCell , METH_VARARGS
|
||||
, "Set the cell upon which perform the query." }
|
||||
, { "setArea" , (PyCFunction)PyQuery_setArea , METH_VARARGS
|
||||
, "Set the area into which perform the query." }
|
||||
, { "setTransformation" , (PyCFunction)PyQuery_setTransformation , METH_VARARGS
|
||||
, "Set the initial transformation applied to the query area." }
|
||||
, { "setBasicLayer" , (PyCFunction)PyQuery_setBasicLayer , METH_VARARGS
|
||||
, "Set the BasicLayer on which perform the query." }
|
||||
, { "setGoCallback" , (PyCFunction)PyQuery_setGoCallback , METH_VARARGS
|
||||
, "Set the callback function for the Gos." }
|
||||
, { "setMarkerCallback" , (PyCFunction)PyQuery_setMarkerCallback , METH_VARARGS
|
||||
, "Set the callback function for the Markers." }
|
||||
, { "setRubberCallback" , (PyCFunction)PyQuery_setRubberCallback , METH_VARARGS
|
||||
, "Set the callback function for the Rubbers." }
|
||||
, { "setExtensionGoCallback", (PyCFunction)PyQuery_setExtensionGoCallback, METH_VARARGS
|
||||
, "Set the callback function for the ExtensionGos." }
|
||||
, { "setMasterCellCallback" , (PyCFunction)PyQuery_setMasterCellCallback, METH_VARARGS
|
||||
, "Set the callback function for the MasterCell." }
|
||||
, { "doQuery" , (PyCFunction)PyQuery_doQuery , METH_NOARGS
|
||||
, "Perform the actual Query walk." }
|
||||
, {NULL, NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// PyQuery Type Methods.
|
||||
|
||||
|
||||
DirectDeleteMethod(PyQuery_DeAlloc,PyQuery)
|
||||
PyTypeObjectLinkPyTypeNewInit(Query)
|
||||
|
||||
#if WORK_IN_PROGRESS
|
||||
DirectReprMethod(PyQuery_Repr, PyQuery, Query)
|
||||
DirectStrMethod (PyQuery_Str, PyQuery, Query)
|
||||
DirectCmpMethod (PyQuery_Cmp, IsPyQuery, PyQuery)
|
||||
DirectHashMethod(PyQuery_Hash, PyQuery)
|
||||
|
||||
|
||||
extern void PyQuery_LinkPyType ()
|
||||
{
|
||||
trace << "PyQuery_LinkType()" << endl;
|
||||
|
||||
PyTypeQuery.tp_dealloc = (destructor) PyQuery_DeAlloc;
|
||||
PyTypeQuery.tp_compare = (cmpfunc) PyQuery_Cmp;
|
||||
PyTypeQuery.tp_repr = (reprfunc) PyQuery_Repr;
|
||||
PyTypeQuery.tp_str = (reprfunc) PyQuery_Str;
|
||||
PyTypeQuery.tp_hash = (hashfunc) PyQuery_Hash;
|
||||
PyTypeQuery.tp_new = (newfunc) PyQuery_NEW;
|
||||
PyTypeQuery.tp_init = (initproc) PyQuery_Init;
|
||||
//PyTypeQuery.tp_methods = PyQuery_Methods;
|
||||
|
||||
if (not pyObjectMethods.size()) {
|
||||
pyObjectMethods
|
||||
( "getMasterCell" , (PyCFunction)PyQuery_getMasterCell, METH_NOARGS
|
||||
, "Returns the master Cell currently under exploration." )
|
||||
( "setCell" , (PyCFunction)PyQuery_setCell, METH_VARARGS
|
||||
, "Set the cell upon which perform the query." )
|
||||
( "setArea" , (PyCFunction)PyQuery_setArea, METH_VARARGS
|
||||
, "Set the area into which perform the query." )
|
||||
( "setTransformation" , (PyCFunction)PyQuery_setTransformation, METH_VARARGS
|
||||
, "Set the initial transformation applied to the query area." )
|
||||
( "setBasicLayer" , (PyCFunction)PyQuery_setBasicLayer, METH_VARARGS
|
||||
, "Set the BasicLayer on which perform the query." )
|
||||
( "setGoCallback" , (PyCFunction)PyQuery_setGoCallback, METH_VARARGS
|
||||
, "Set the callback function for the Gos." )
|
||||
( "setMarkerCallback" , (PyCFunction)PyQuery_setMarkerCallback, METH_VARARGS
|
||||
, "Set the callback function for the Markers." )
|
||||
( "setRubberCallback" , (PyCFunction)PyQuery_setRubberCallback, METH_VARARGS
|
||||
, "Set the callback function for the Rubbers." )
|
||||
( "setExtensionGoCallback", (PyCFunction)PyQuery_setExtensionGoCallback, METH_VARARGS
|
||||
, "Set the callback function for the ExtensionGos." )
|
||||
( "setMasterCellCallback" , (PyCFunction)PyQuery_setMasterCellCallback, METH_VARARGS
|
||||
, "Set the callback function for the MasterCell." )
|
||||
( "doQuery" , (PyCFunction)PyQuery_doQuery, METH_NOARGS
|
||||
, "Perform the actual Query walk." );
|
||||
}
|
||||
|
||||
PyTypeQuery.tp_methods = pyObjectMethods.getMethods();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#else // End of Python Module Code Part.
|
||||
|
||||
|
||||
// +=================================================================+
|
||||
// | "PyQuery" Shared Library Code Part |
|
||||
// +=================================================================+
|
||||
|
||||
|
||||
PyTypeRootObjectDefinitions(Query)
|
||||
|
||||
|
||||
extern void PyQuery_postModuleInit ()
|
||||
{
|
||||
PyDict_SetItemString ( PyTypeQuery.tp_dict, "Mask", (PyObject*)&PyTypeQueryMask );
|
||||
|
||||
PyObject* constant;
|
||||
LoadObjectConstant(PyTypeQuery.tp_dict,Query::DoMasterCells ,"DoMasterCells");
|
||||
LoadObjectConstant(PyTypeQuery.tp_dict,Query::DoTerminalCells,"DoTerminalCells");
|
||||
LoadObjectConstant(PyTypeQuery.tp_dict,Query::DoComponents ,"DoComponents");
|
||||
LoadObjectConstant(PyTypeQuery.tp_dict,Query::DoMarkers ,"DoMarkers");
|
||||
LoadObjectConstant(PyTypeQuery.tp_dict,Query::DoRubbers ,"DoRubbers");
|
||||
LoadObjectConstant(PyTypeQuery.tp_dict,Query::DoExtensionGos ,"DoExtensionGos");
|
||||
LoadObjectConstant(PyTypeQuery.tp_dict,Query::DoAll ,"DoAll");
|
||||
}
|
||||
|
||||
|
||||
#endif // End of Shared Library Code Part.
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar namespace.
|
|
@ -0,0 +1,384 @@
|
|||
|
||||
// -*- 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é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
|
||||
//
|
||||
// +-----------------------------------------------------------------+
|
||||
// | 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@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Module : "./PyQueryMask.cpp" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#include "hurricane/isobar/PyQueryMask.h"
|
||||
|
||||
|
||||
namespace Isobar {
|
||||
|
||||
using namespace Hurricane;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
// +=================================================================+
|
||||
// | "PyQueryMask" Python Module Code Part |
|
||||
// +=================================================================+
|
||||
|
||||
#if defined(__PYTHON_MODULE__)
|
||||
|
||||
|
||||
#define methodRMaskFromMask(FUNC_NAME) \
|
||||
PyObject* PyQueryMask_##FUNC_NAME ( PyQueryMask* self, PyObject* args ) \
|
||||
{ \
|
||||
PyObject* arg0; \
|
||||
if (PyArg_ParseTuple( args, "O:Query.Mask."#FUNC_NAME"()", &arg0)) { \
|
||||
if (not IsPyQueryMask(arg0)) { \
|
||||
PyErr_SetString ( ConstructorError \
|
||||
, "Query.Mask."#FUNC_NAME"(): Argument is not of Query.Mask type." ); \
|
||||
return NULL; \
|
||||
} \
|
||||
} else { \
|
||||
PyErr_SetString ( ConstructorError \
|
||||
, "Invalid number of parameters passed to Query.Mask."#FUNC_NAME"()." ); \
|
||||
return NULL; \
|
||||
} \
|
||||
self->_object.FUNC_NAME(PYQUERYMASK_O(arg0)); \
|
||||
Py_INCREF(self); \
|
||||
return (PyObject*)self; \
|
||||
}
|
||||
|
||||
|
||||
#define predicateFromMask(FUNC_NAME) \
|
||||
PyObject* PyQueryMask_##FUNC_NAME ( PyQueryMask* self, PyObject* args ) \
|
||||
{ \
|
||||
PyObject* arg0; \
|
||||
if (PyArg_ParseTuple( args, "O:Query.Mask."#FUNC_NAME"()", &arg0)) { \
|
||||
if (not IsPyQueryMask(arg0)) { \
|
||||
PyErr_SetString ( ConstructorError \
|
||||
, "Query.Mask."#FUNC_NAME"(): Argument is not of Query.Mask type." ); \
|
||||
return NULL; \
|
||||
} \
|
||||
} else { \
|
||||
PyErr_SetString ( ConstructorError \
|
||||
, "Invalid number of parameters passed to Query.Mask."#FUNC_NAME"()." ); \
|
||||
return NULL; \
|
||||
} \
|
||||
if (self->_object.FUNC_NAME(PYQUERYMASK_O(arg0))) Py_RETURN_TRUE; \
|
||||
Py_RETURN_FALSE; \
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// PyQuery Attribute Methods.
|
||||
|
||||
static PyObject* PyQueryMask_new ( PyTypeObject* type, PyObject* args, PyObject* kwds )
|
||||
{
|
||||
trace << "PyQueryMask_new()" << endl;
|
||||
|
||||
PyQueryMask* pyMask = (PyQueryMask*)type->tp_alloc(type,0);
|
||||
|
||||
if ( pyMask ) {
|
||||
unsigned long long value = 0;
|
||||
if (PyArg_ParseTuple(args,"K:QueryMask.new", &value)) {
|
||||
pyMask->_object = Query::Mask(value);
|
||||
} else {
|
||||
PyErr_SetString ( ConstructorError, "Invalid/bad number of parameters for QueryMask()." );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return (PyObject*)pyMask;
|
||||
}
|
||||
|
||||
|
||||
PyObject* PyQueryMask_zero ( PyQueryMask* self )
|
||||
{
|
||||
self->_object.zero();
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyObject* PyQueryMask_nthbit ( PyQueryMask* self, PyObject* pyInt )
|
||||
{
|
||||
Query::Mask result;
|
||||
result = self->_object.nthbit(PyInt_AsLong(pyInt));
|
||||
return PyQueryMask_Link(result);
|
||||
}
|
||||
|
||||
|
||||
predicateFromMask (isSet)
|
||||
predicateFromMask (contains)
|
||||
predicateFromMask (intersect)
|
||||
methodRMaskFromMask(set)
|
||||
methodRMaskFromMask(unset)
|
||||
|
||||
|
||||
PyMethodDef PyQueryMask_Methods[] =
|
||||
{ { "zero" , (PyCFunction)PyQueryMask_zero , METH_NOARGS
|
||||
, "Reset all the bits." }
|
||||
, { "set" , (PyCFunction)PyQueryMask_set , METH_VARARGS
|
||||
, "Sets to one the bits given in the argument (aka bitwise or)." }
|
||||
, { "unset" , (PyCFunction)PyQueryMask_unset , METH_VARARGS
|
||||
, "Sets to zero the bits given in the argument (aka bitwise and with complement)." }
|
||||
, { "isSet" , (PyCFunction)PyQueryMask_isSet , METH_VARARGS
|
||||
, "Returns true if some of bits at the mask's position are set (aka bitwise and)." }
|
||||
, { "contains" , (PyCFunction)PyQueryMask_contains , METH_VARARGS
|
||||
, "Returns true if all the bits at the mask's position are set (aka bitwise and)." }
|
||||
, { "intersect" , (PyCFunction)PyQueryMask_intersect , METH_VARARGS
|
||||
, "Returns true if some of bits at the mask's position are set (aka bitwise and)." }
|
||||
, { "nthbit" , (PyCFunction)PyQueryMask_nthbit , METH_VARARGS
|
||||
, "Returns a new mask with only the Nth bit copied." }
|
||||
, {NULL, NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// PyQuery Number Protocol Methods.
|
||||
|
||||
|
||||
#define binaryInFunctionMaskMask(FUNC_NAME,OP) \
|
||||
PyObject* PyQueryMask_##FUNC_NAME ( PyQueryMask* pyMask0, PyQueryMask* pyMask1 ) \
|
||||
{ \
|
||||
pyMask0->_object OP pyMask1->_object; \
|
||||
Py_INCREF(pyMask0); \
|
||||
return (PyObject*)pyMask0; \
|
||||
}
|
||||
|
||||
|
||||
#define binaryInFunctionMaskInt(FUNC_NAME,OP) \
|
||||
PyObject* PyQueryMask_##FUNC_NAME ( PyQueryMask* pyMask0, PyObject* pyInt ) \
|
||||
{ \
|
||||
pyMask0->_object OP= PyInt_AsLong(pyInt); \
|
||||
Py_INCREF(pyMask0); \
|
||||
return (PyObject*)pyMask0; \
|
||||
}
|
||||
|
||||
|
||||
#define binaryFunctionMaskMask(FUNC_NAME,OP) \
|
||||
PyObject* PyQueryMask_##FUNC_NAME ( PyQueryMask* pyMask0, PyQueryMask* pyMask1 ) \
|
||||
{ \
|
||||
Query::Mask result; \
|
||||
result = pyMask0->_object OP pyMask1->_object; \
|
||||
return PyQueryMask_Link(result); \
|
||||
}
|
||||
|
||||
|
||||
#define binaryFunctionMaskInt(FUNC_NAME,OP) \
|
||||
PyObject* PyQueryMask_##FUNC_NAME ( PyQueryMask* pyMask0, PyObject* pyInt ) \
|
||||
{ \
|
||||
Query::Mask result; \
|
||||
result = pyMask0->_object OP PyInt_AsLong(pyInt); \
|
||||
return PyQueryMask_Link(result); \
|
||||
}
|
||||
|
||||
|
||||
int PyQueryMask_nonzero ( PyQueryMask* pyMask )
|
||||
{ return pyMask->_object != Query::Mask(0); }
|
||||
|
||||
|
||||
int PyQueryMask_invert ( PyQueryMask* pyMask )
|
||||
{ return not pyMask->_object; }
|
||||
|
||||
|
||||
binaryFunctionMaskInt (lshift,<<)
|
||||
binaryFunctionMaskInt (rshift,>>)
|
||||
binaryFunctionMaskMask (and ,bitand)
|
||||
binaryFunctionMaskMask (xor ,^)
|
||||
binaryFunctionMaskMask (or ,bitor)
|
||||
binaryInFunctionMaskMask(andIn ,&=)
|
||||
binaryInFunctionMaskMask(orIn ,|=)
|
||||
|
||||
|
||||
PyNumberMethods PyQueryMask_NumberMethods = {
|
||||
0 // binaryfunc nb_add;
|
||||
, 0 // binaryfunc nb_subtract;
|
||||
, 0 // binaryfunc nb_multiply;
|
||||
, 0 // binaryfunc nb_divide;
|
||||
, 0 // binaryfunc nb_remainder;
|
||||
, 0 // binaryfunc nb_divmod;
|
||||
, 0 // ternaryfunc nb_power;
|
||||
, 0 // unaryfunc nb_negative;
|
||||
, 0 // unaryfunc nb_positive;
|
||||
, 0 // unaryfunc nb_absolute;
|
||||
, (inquiry) PyQueryMask_nonzero // inquiry nb_nonzero; -- Used by PyObject_IsTrue
|
||||
, (unaryfunc) PyQueryMask_invert // unaryfunc nb_invert;
|
||||
, (binaryfunc)PyQueryMask_lshift // binaryfunc nb_lshift;
|
||||
, (binaryfunc)PyQueryMask_rshift // binaryfunc nb_rshift;
|
||||
, (binaryfunc)PyQueryMask_and // binaryfunc nb_and;
|
||||
, (binaryfunc)PyQueryMask_xor // binaryfunc nb_xor;
|
||||
, (binaryfunc)PyQueryMask_or // binaryfunc nb_or;
|
||||
, 0 // coercion nb_coerce; -- Used by the coerce() function
|
||||
, 0 // unaryfunc nb_int;
|
||||
, 0 // unaryfunc nb_long;
|
||||
, 0 // unaryfunc nb_float;
|
||||
, 0 // unaryfunc nb_oct;
|
||||
, 0 // unaryfunc nb_hex;
|
||||
// Added in release 2.0
|
||||
, 0 // binaryfunc nb_inplace_add;
|
||||
, 0 // binaryfunc nb_inplace_subtract;
|
||||
, 0 // binaryfunc nb_inplace_multiply;
|
||||
, 0 // binaryfunc nb_inplace_divide;
|
||||
, 0 // binaryfunc nb_inplace_remainder;
|
||||
, 0 // ternaryfunc nb_inplace_power;
|
||||
, 0 // binaryfunc nb_inplace_lshift;
|
||||
, 0 // binaryfunc nb_inplace_rshift;
|
||||
, (binaryfunc)PyQueryMask_andIn // binaryfunc nb_inplace_and;
|
||||
, 0 // binaryfunc nb_inplace_xor;
|
||||
, (binaryfunc)PyQueryMask_orIn // binaryfunc nb_inplace_or;
|
||||
// Added in release 2.2
|
||||
, 0 // binaryfunc nb_floor_divide;
|
||||
, 0 // binaryfunc nb_true_divide;
|
||||
, 0 // binaryfunc nb_inplace_floor_divide;
|
||||
, 0 // binaryfunc nb_inplace_true_divide;
|
||||
// Added in release 2.5
|
||||
, 0 // unaryfunc nb_index;
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// PyQuery Type Methods.
|
||||
|
||||
|
||||
static PyObject* PyQueryMask_Repr ( PyQueryMask *self )
|
||||
{
|
||||
ostringstream repr;
|
||||
repr << "[" << hex << self << "<->" << (void*)&(self->_object) << " " << self->_object << "]";
|
||||
return ( PyString_FromString(repr.str().c_str()) );
|
||||
}
|
||||
|
||||
|
||||
static PyObject* PyQueryMask_Str ( PyQueryMask *self )
|
||||
{
|
||||
return ( PyString_FromString(getString(self->_object).c_str()) );
|
||||
}
|
||||
|
||||
|
||||
static void PyQueryMask_DeAlloc ( PyQueryMask *self )
|
||||
{
|
||||
trace << "PyQueryMask_DeAlloc(" << hex << self << ") " << self->_object << endl;
|
||||
PyObject_DEL ( self );
|
||||
}
|
||||
|
||||
|
||||
static int PyQueryMask_Cmp ( PyQueryMask *self, PyObject* other )
|
||||
{
|
||||
if ( not IsPyQueryMask(other) ) return -1;
|
||||
|
||||
PyQueryMask* otherPyObject = (PyQueryMask*)other;
|
||||
if ( self->_object == otherPyObject->_object ) return 0;
|
||||
if ( self->_object < otherPyObject->_object ) return -1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int PyQueryMask_Hash ( PyQueryMask *self)
|
||||
{
|
||||
return (long)&(self->_object);
|
||||
}
|
||||
|
||||
|
||||
extern void PyQueryMask_LinkPyType()
|
||||
{
|
||||
trace << "PyQueryMask_LinkType()" << endl;
|
||||
|
||||
PyTypeQueryMask.tp_new = PyQueryMask_new;
|
||||
PyTypeQueryMask.tp_dealloc = (destructor) PyQueryMask_DeAlloc;
|
||||
PyTypeQueryMask.tp_compare = (cmpfunc) PyQueryMask_Cmp;
|
||||
PyTypeQueryMask.tp_repr = (reprfunc) PyQueryMask_Repr;
|
||||
PyTypeQueryMask.tp_str = (reprfunc) PyQueryMask_Str;
|
||||
PyTypeQueryMask.tp_hash = (hashfunc) PyQueryMask_Hash;
|
||||
PyTypeQueryMask.tp_methods = PyQueryMask_Methods;
|
||||
PyTypeQueryMask.tp_as_number = &PyQueryMask_NumberMethods;
|
||||
}
|
||||
|
||||
|
||||
#else // End of Python Module Code Part.
|
||||
|
||||
|
||||
// x=================================================================x
|
||||
// | "PyQuery" Shared Library Code Part |
|
||||
// x=================================================================x
|
||||
|
||||
|
||||
// Link/Creation Method.
|
||||
PyObject* PyQueryMask_Link ( const Query::Mask& mask )
|
||||
{
|
||||
PyQueryMask* pyMask = NULL;
|
||||
pyMask = PyObject_NEW(PyQueryMask, &PyTypeQueryMask);
|
||||
if (pyMask == NULL) return NULL;
|
||||
|
||||
pyMask->_object = mask;
|
||||
|
||||
return (PyObject*)pyMask;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// PyQuery Object Definitions.
|
||||
|
||||
PyTypeObject PyTypeQueryMask =
|
||||
{ PyObject_HEAD_INIT(NULL)
|
||||
0 /* ob_size. */
|
||||
, "Hurricane.Query.Mask" /* tp_name. */
|
||||
, sizeof(PyQueryMask) /* tp_basicsize. */
|
||||
, 0 /* tp_itemsize. */
|
||||
/* methods. */
|
||||
, 0 /* tp_dealloc. */
|
||||
, 0 /* tp_print. */
|
||||
, 0 /* tp_getattr. */
|
||||
, 0 /* tp_setattr. */
|
||||
, 0 /* tp_compare. */
|
||||
, 0 /* tp_repr. */
|
||||
, 0 /* tp_as_number. */
|
||||
, 0 /* tp_as_sequence. */
|
||||
, 0 /* tp_as_mapping. */
|
||||
, 0 /* tp_hash. */
|
||||
, 0 /* tp_call. */
|
||||
, 0 /* tp_str */
|
||||
, 0 /* tp_getattro. */
|
||||
, 0 /* tp_setattro. */
|
||||
, 0 /* tp_as_buffer. */
|
||||
, Py_TPFLAGS_DEFAULT /* tp_flags */
|
||||
, "Query::Mask objects" /* tp_doc. */
|
||||
};
|
||||
|
||||
|
||||
#endif // End of Shared Library Code Part.
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar namespace.
|
|
@ -2,7 +2,7 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// This file is part of the Coriolis Software.
|
||||
// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved
|
||||
// Copyright (c) UPMC/LIP6 2008-2013, All Rights Reserved
|
||||
//
|
||||
// +-----------------------------------------------------------------+
|
||||
// | C O R I O L I S |
|
||||
|
@ -1089,14 +1089,31 @@ extern "C" {
|
|||
}
|
||||
|
||||
|
||||
|
||||
#define PyTypeObjectLinkPyTypeWithClassNewInit(PY_SELF_TYPE,SELF_TYPE) \
|
||||
DirectReprMethod(Py##PY_SELF_TYPE##_Repr, Py##PY_SELF_TYPE, SELF_TYPE) \
|
||||
DirectStrMethod (Py##PY_SELF_TYPE##_Str, Py##PY_SELF_TYPE, SELF_TYPE) \
|
||||
DirectCmpMethod (Py##PY_SELF_TYPE##_Cmp, IsPy##PY_SELF_TYPE, Py##PY_SELF_TYPE) \
|
||||
DirectHashMethod(Py##PY_SELF_TYPE##_Hash, Py##SELF_TYPE) \
|
||||
extern void Py##PY_SELF_TYPE##_LinkPyType() { \
|
||||
trace << "Py" #PY_SELF_TYPE "_LinkType()" << endl; \
|
||||
\
|
||||
PyType##PY_SELF_TYPE.tp_dealloc = (destructor) Py##PY_SELF_TYPE##_DeAlloc; \
|
||||
PyType##PY_SELF_TYPE.tp_compare = (cmpfunc) Py##PY_SELF_TYPE##_Cmp; \
|
||||
PyType##PY_SELF_TYPE.tp_repr = (reprfunc) Py##PY_SELF_TYPE##_Repr; \
|
||||
PyType##PY_SELF_TYPE.tp_str = (reprfunc) Py##PY_SELF_TYPE##_Str; \
|
||||
PyType##PY_SELF_TYPE.tp_hash = (hashfunc) Py##PY_SELF_TYPE##_Hash; \
|
||||
PyType##PY_SELF_TYPE.tp_new = (newfunc) Py##PY_SELF_TYPE##_NEW; \
|
||||
PyType##PY_SELF_TYPE.tp_init = (initproc) Py##PY_SELF_TYPE##_Init; \
|
||||
PyType##PY_SELF_TYPE.tp_methods = Py##PY_SELF_TYPE##_Methods; \
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Initialisation Function for PyTypeObject Runtime Link.
|
||||
|
||||
#define PyTypeObjectLinkPyType(SELF_TYPE) \
|
||||
PyTypeObjectLinkPyTypeWithClass(SELF_TYPE,SELF_TYPE)
|
||||
|
||||
#define PyTypeObjectLinkPyTypeNewInit(SELF_TYPE) \
|
||||
PyTypeObjectLinkPyTypeWithClassNewInit(SELF_TYPE,SELF_TYPE)
|
||||
|
||||
|
||||
// Special Initialisation Function for Locator PyTypeObject Runtime Link.
|
||||
#define LocatorPyTypeObjectLinkPyType(PY_SELF_TYPE, SELF_TYPE) \
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
|
||||
// -*- 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é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
|
||||
//
|
||||
// +-----------------------------------------------------------------+
|
||||
// | C O R I O L I S |
|
||||
// | I s o b a r - Hurricane / Python Interface |
|
||||
// | |
|
||||
// | Author : Damien DUPUIS |
|
||||
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./hurricane/isobar/PyQuery.h" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#ifndef HURRICANE_PYQUERY_H
|
||||
#define HURRICANE_PYQUERY_H
|
||||
|
||||
#include "hurricane/isobar/PyHurricane.h"
|
||||
#include "hurricane/Query.h"
|
||||
|
||||
namespace Isobar {
|
||||
|
||||
using namespace Hurricane;
|
||||
|
||||
|
||||
#if WORK_IN_PROGRESS
|
||||
template< typename CppObject, int TableSize >
|
||||
class MethodDefTable {
|
||||
public:
|
||||
MethodDefTable ();
|
||||
PyMethodDef* getMethods ();
|
||||
const PyMethodDef& operator[] ( size_t );
|
||||
MethodDefTable& addMethod ( const char* fname, PyCFunction, int flags, const char* fdoc );
|
||||
MethodDefTable& operator() ( const char* fname, PyCFunction, int flags, const char* fdoc );
|
||||
template< typename R, typename... Ps >
|
||||
MethodDefTable& addMethod ( const char* fname, PyCFunction, int flags, const char* fdoc, R(CppObject::* mfp)(Ps...) );
|
||||
template< typename R, typename... Ps >
|
||||
MethodDefTable& operator() ( const char* fname, PyCFunction, int flags, const char* fdoc, R(CppObject::* mfp)(Ps...) );
|
||||
inline size_t size () const;
|
||||
private:
|
||||
size_t _size;
|
||||
PyMethodDef _pyMethods [TableSize];
|
||||
void* _cppMethods[TableSize];
|
||||
};
|
||||
|
||||
|
||||
template< typename CppObject, int TableSize >
|
||||
size_t MethodDefTable<CppObject,TableSize>::size () const
|
||||
{ return _size; }
|
||||
|
||||
|
||||
template< typename CppObject, int TableSize >
|
||||
MethodDefTable<CppObject,TableSize>::MethodDefTable ()
|
||||
: _size (0)
|
||||
//, _pyMethods(new PyMethodDef[TableSize+1])
|
||||
{
|
||||
for ( size_t i=0 ; i<TableSize+1 ; ++i ) {
|
||||
_pyMethods [i].ml_name = NULL;
|
||||
_pyMethods [i].ml_meth = NULL;
|
||||
_pyMethods [i].ml_flags = 0;
|
||||
_pyMethods [i].ml_doc = NULL;
|
||||
_cppMethods[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template< typename CppObject, int TableSize >
|
||||
PyMethodDef* MethodDefTable<CppObject,TableSize>::getMethods ()
|
||||
{ return _pyMethods; }
|
||||
|
||||
|
||||
template< typename CppObject, int TableSize >
|
||||
const PyMethodDef& MethodDefTable<CppObject,TableSize>::operator[] ( size_t i )
|
||||
{ return _pyMethods[i]; }
|
||||
|
||||
|
||||
template< typename CppObject, int TableSize >
|
||||
MethodDefTable<CppObject,TableSize>& MethodDefTable<CppObject,TableSize>::addMethod ( const char* fname, PyCFunction fp, int flags, const char* fdoc )
|
||||
{
|
||||
_pyMethods [_size].ml_name = fname;
|
||||
_pyMethods [_size].ml_meth = fp;
|
||||
_pyMethods [_size].ml_flags = flags;
|
||||
_pyMethods [_size].ml_doc = fdoc;
|
||||
_cppMethods[_size] = NULL;
|
||||
++_size;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template< typename CppObject, int TableSize >
|
||||
template< typename R, typename... Ps >
|
||||
MethodDefTable<CppObject,TableSize>& MethodDefTable<CppObject,TableSize>::addMethod
|
||||
( const char* fname, PyCFunction fp, int flags, const char* fdoc, R(CppObject::* mfp)(Ps...) )
|
||||
{
|
||||
_pyMethods[_size].ml_name = fname;
|
||||
_pyMethods[_size].ml_meth = fp;
|
||||
_pyMethods[_size].ml_flags = flags;
|
||||
_pyMethods[_size].ml_doc = fdoc;
|
||||
_cppMethods[_size] = (void*)mfp;
|
||||
++_size;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template< typename CppObject, int TableSize >
|
||||
MethodDefTable<CppObject,TableSize>& MethodDefTable<CppObject,TableSize>::operator() ( const char* fname, PyCFunction fp, int flags, const char* fdoc )
|
||||
{ return addMethod( fname, fp, flags, fdoc ); }
|
||||
|
||||
|
||||
template< typename CppObject, int TableSize >
|
||||
template< typename R, typename... Ps >
|
||||
MethodDefTable<CppObject,TableSize>& MethodDefTable<CppObject,TableSize>::operator()
|
||||
( const char* fname, PyCFunction fp, int flags, const char* fdoc, R(CppObject::* mfp)(Ps...) )
|
||||
{ return addMethod( fname, fp, flags, fdoc, mfp ); }
|
||||
#endif
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Python Object : "PyQuery".
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Query* _object;
|
||||
} PyQuery;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Functions & Types exported to "PyHurricane.ccp".
|
||||
|
||||
extern PyTypeObject PyTypeQuery;
|
||||
extern PyMethodDef PyQuery_Methods[];
|
||||
|
||||
extern PyObject* PyQuery_Link ( Hurricane::Query* object );
|
||||
extern void PyQuery_LinkPyType ();
|
||||
extern void PyQuery_postModuleInit ();
|
||||
|
||||
#define IsPyQuery(v) ( (v)->ob_type == &PyTypeQuery )
|
||||
#define PYQUERY(v) ( (PyQuery*)(v) )
|
||||
#define PYQUERY_O(v) ( PYQUERY(v)->_object )
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar namespace.
|
||||
|
||||
#endif
|
|
@ -0,0 +1,85 @@
|
|||
|
||||
// -*- 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é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
|
||||
//
|
||||
// +-----------------------------------------------------------------+
|
||||
// | 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@lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./hurricane/isobar/PyQueryMask.h" |
|
||||
// +-----------------------------------------------------------------+
|
||||
|
||||
|
||||
#ifndef __PY_QUERY_MASK__
|
||||
#define __PY_QUERY_MASK__
|
||||
|
||||
#include "hurricane/isobar/PyHurricane.h"
|
||||
#include "hurricane/Query.h"
|
||||
|
||||
namespace Isobar {
|
||||
|
||||
using namespace Hurricane;
|
||||
|
||||
extern "C" {
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Python Object : "PyQueryMask".
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Query::Mask _object;
|
||||
} PyQueryMask;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Functions & Types exported to "PyHurricane.ccp".
|
||||
|
||||
extern PyTypeObject PyTypeQueryMask;
|
||||
extern PyMethodDef PyQueryMask_Methods[];
|
||||
|
||||
extern PyObject* PyQueryMask_Link ( const Query::Mask& object );
|
||||
extern void PyQueryMask_LinkPyType ();
|
||||
|
||||
# define IsPyQueryMask(v) ( (v)->ob_type == &PyTypeQueryMask )
|
||||
# define PYQUERYMASK(v) ( (PyQueryMask*)(v) )
|
||||
# define PYQUERYMASK_O(v) ( PYQUERYMASK(v)->_object )
|
||||
|
||||
|
||||
} // extern "C".
|
||||
|
||||
} // Isobar namespace.
|
||||
|
||||
# endif
|
|
@ -1272,7 +1272,10 @@ namespace Hurricane {
|
|||
|
||||
if ( isDrawable((*iLayer)->getName()) ) {
|
||||
_drawingQuery.setBasicLayer ( *iLayer );
|
||||
_drawingQuery.setFilter ( getQueryFilter().unset(Query::DoMasterCells|Query::DoRubbers|Query::DoMarkers) );
|
||||
_drawingQuery.setFilter ( getQueryFilter().unset(Query::DoMasterCells
|
||||
|Query::DoRubbers
|
||||
|Query::DoMarkers
|
||||
|Query::DoExtensionGos) );
|
||||
_drawingQuery.doQuery ();
|
||||
}
|
||||
if ( _enableRedrawInterrupt ) QApplication::processEvents();
|
||||
|
@ -1289,7 +1292,10 @@ namespace Hurricane {
|
|||
_drawingPlanes.setBrush ( Graphics::getBrush("boundaries",getDarkening()) );
|
||||
|
||||
_drawingQuery.setBasicLayer ( NULL );
|
||||
_drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents|Query::DoRubbers|Query::DoMarkers) );
|
||||
_drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents
|
||||
|Query::DoRubbers
|
||||
|Query::DoMarkers
|
||||
|Query::DoExtensionGos) );
|
||||
_drawingQuery.doQuery ();
|
||||
}
|
||||
}
|
||||
|
@ -1300,7 +1306,9 @@ namespace Hurricane {
|
|||
_drawingPlanes.setBrush ( Graphics::getBrush("text.reference",getDarkening()) );
|
||||
|
||||
_drawingQuery.setBasicLayer ( NULL );
|
||||
_drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents|Query::DoMasterCells) );
|
||||
_drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents
|
||||
|Query::DoExtensionGos
|
||||
|Query::DoMasterCells) );
|
||||
_drawingQuery.doQuery ();
|
||||
}
|
||||
}
|
||||
|
@ -1311,7 +1319,10 @@ namespace Hurricane {
|
|||
_drawingPlanes.setBrush ( Graphics::getBrush("rubber",getDarkening()) );
|
||||
|
||||
_drawingQuery.setBasicLayer ( NULL );
|
||||
_drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents|Query::DoMasterCells|Query::DoMarkers) );
|
||||
_drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents
|
||||
|Query::DoExtensionGos
|
||||
|Query::DoMasterCells
|
||||
|Query::DoMarkers) );
|
||||
_drawingQuery.doQuery ();
|
||||
}
|
||||
}
|
||||
|
@ -1336,7 +1347,7 @@ namespace Hurricane {
|
|||
if ( isDrawableExtension((*islice)->getName()) ) {
|
||||
_drawingQuery.setExtensionMask ( (*islice)->getMask() );
|
||||
_drawingQuery.setDrawExtensionGo ( (*islice)->getName() );
|
||||
_drawingQuery.setFilter ( Query::DoExtensionGos );
|
||||
_drawingQuery.setFilter ( getQueryFilter().set(Query::DoExtensionGos).unset(Query::DoMasterCells) );
|
||||
_drawingQuery.doQuery ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -227,7 +227,6 @@ namespace Hurricane {
|
|||
{
|
||||
if ( event->key() == Qt::Key_N ) {
|
||||
event->accept();
|
||||
cerr << "_selectMode:" << _selectMode << endl;
|
||||
_selectMode = (++_selectMode) % 3;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue