New implementation for the Python hash and compare methods.

* Change: In Hurricane::Isobar/PyHurricane.h, make the hash function use
    the DBo id whenever possible instead of the object pointer, fall back
    to it for standalone objects (Box like one). The DirectHashMethod()
    macro generate a C style function (linkage) which call a template
    function "getPyHash<>()" that uses a SFINAE mechanism to select
    the right variant.
      Create two comparison macros DirectCmpByPtrMethod() and
    DirectCmpByValueMethod() to customize the comparison for objects that
    have C++ operator==(). So now two boxes with the same contents will
    be seen equal by Python. For DBo objects we keep the previous
    comparison by C++ pointer.
This commit is contained in:
Jean-Paul Chaput 2019-11-14 23:56:01 +01:00
parent 85540c9a58
commit 92edd9ba31
48 changed files with 199 additions and 155 deletions

View File

@ -34,6 +34,7 @@ namespace Bora {
using std::cerr;
using std::endl;
using Hurricane::tab;
using Isobar::getPyHash;
using Isobar::__cs;
using CRL::PyTypeToolEngine;
using CRL::PyTypeGraphicTool;

View File

@ -39,6 +39,7 @@ namespace Bora {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::PyCell;

View File

@ -181,7 +181,7 @@ rg.addLayerGauge( RoutingLayerGauge.create( tech.getLayer('METAL3') # meta
, 2 # depth.
, 0.0 # density (deprecated).
, l(0) # track offset from AB.
, l(8) # track pitch.
, l(10) # track pitch.
, l(3) # wire width.
, l(2) # VIA side (that is VIA12).
, l(8) # obstacle dW.

View File

@ -39,6 +39,7 @@ namespace CRL {
using Isobar::HurricaneWarning;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::getPyHash;
using Isobar::__cs;
using Isobar::PyCell_Link;

View File

@ -44,6 +44,7 @@ namespace CRL {
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::PyAny_AsLong;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::PyLibrary;

View File

@ -38,6 +38,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::__cs;
@ -111,7 +112,7 @@ extern "C" {
PythonOnlyDeleteMethod(AllianceLibrary)
DirectHashMethod(PyAllianceLibrary_Hash, PyAllianceLibrary)
DirectHashMethod(PyAllianceLibrary_Hash, AllianceLibrary)
extern void PyAllianceLibrary_LinkPyType() {
cdebug_log(30,0) << "PyAllianceLibrary_LinkType()" << endl;

View File

@ -37,6 +37,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::__cs;
@ -177,7 +178,7 @@ extern "C" {
PythonOnlyDeleteMethod(Banner)
DirectHashMethod(PyBanner_Hash, PyBanner)
DirectHashMethod(PyBanner_Hash, Banner)
extern void PyBanner_LinkPyType() {
cdebug_log(30,0) << "PyBanner_LinkType()" << endl;

View File

@ -38,6 +38,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::__cs;

View File

@ -54,6 +54,7 @@ namespace CRL {
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::__cs;
using Isobar::getPyHash;
using Vhdl::EntityExtension;

View File

@ -44,6 +44,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::PyLibrary;

View File

@ -36,6 +36,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::PyLibrary;
@ -108,10 +109,10 @@ extern "C" {
PythonOnlyDeleteMethod(CatalogState)
DirectReprMethod(PyCatalogState_Repr, PyCatalogState, Catalog::State)
DirectStrMethod (PyCatalogState_Str, PyCatalogState, Catalog::State)
DirectCmpMethod (PyCatalogState_Cmp, IsPyCatalogState, PyCatalogState)
DirectHashMethod(PyCatalogState_Hash, PyCatalogState)
DirectReprMethod (PyCatalogState_Repr, PyCatalogState, Catalog::State)
DirectStrMethod (PyCatalogState_Str, PyCatalogState, Catalog::State)
DirectCmpByPtrMethod(PyCatalogState_Cmp, IsPyCatalogState, PyCatalogState)
DirectHashMethod (PyCatalogState_Hash, CatalogState)
extern void PyCatalogState_LinkPyType() {
cdebug_log(30,0) << "PyCatalogState_LinkType()" << endl;

View File

@ -36,6 +36,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::__cs;

View File

@ -33,6 +33,7 @@ namespace Constant {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::__cs;

View File

@ -38,6 +38,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::__cs;

View File

@ -36,6 +36,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::__cs;
@ -262,7 +263,7 @@ extern "C" {
PythonOnlyDeleteMethod(Environment)
DirectHashMethod(PyEnvironment_Hash, PyEnvironment)
DirectHashMethod(PyEnvironment_Hash, Environment)
extern void PyEnvironment_LinkPyType() {
cdebug_log(30,0) << "PyEnvironment_LinkType()" << endl;

View File

@ -38,6 +38,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::__cs;

View File

@ -38,6 +38,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::__cs;

View File

@ -38,6 +38,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::__cs;

View File

@ -40,6 +40,7 @@ namespace CRL {
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::PyAny_AsLong;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::__cs;

View File

@ -37,6 +37,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::__cs;

View File

@ -37,6 +37,7 @@ namespace CRL {
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::PyAny_AsLong;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;

View File

@ -44,6 +44,7 @@ namespace CRL {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::PyCell;

View File

@ -27,6 +27,7 @@ namespace Etesian {
using std::endl;
using Hurricane::tab;
using Isobar::__cs;
using Isobar::getPyHash;
using CRL::PyTypeToolEngine;
using CRL::PyTypeGraphicTool;

View File

@ -45,6 +45,7 @@ namespace Etesian {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::PyCell;

View File

@ -26,13 +26,6 @@ namespace Isobar {
using std::endl;
using std::hex;
using std::ostringstream;
using Isobar::ProxyProperty;
using Isobar::ProxyError;
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using namespace Analog;
@ -315,7 +308,7 @@ extern "C" {
DirectDeleteMethod(PyLayoutGenerator_DeAlloc,PyLayoutGenerator)
DirectHashMethod(PyLayoutGenerator_Hash, PyLayoutGenerator)
DirectHashMethod(PyLayoutGenerator_Hash,LayoutGenerator)
extern void PyLayoutGenerator_LinkPyType() {
cdebug.log(49) << "PyLayoutGenerator_LinkType()" << endl;

View File

@ -58,9 +58,6 @@ extern "C" {
DirectDestroyAttribute(PyBox_destroy, PyBox)
// ---------------------------------------------------------------
// Class Method : "PyBox_NEW ()"
static PyObject* PyBox_NEW (PyObject *module, PyObject *args) {
cdebug_log(20,0) << "PyBox_NEW()" << endl;
@ -150,9 +147,6 @@ extern "C" {
}
// ---------------------------------------------------------------
// Attribute Method : "PyBox_getIntersection ()"
static PyObject* PyBox_getIntersection ( PyBox *self, PyObject* args ) {
cdebug_log(20,0) << "PyBox_getIntersection()" << endl;
@ -175,9 +169,6 @@ extern "C" {
}
// ---------------------------------------------------------------
// Attribute Method : "PyBox_contains ()"
static PyObject* PyBox_contains ( PyBox *self, PyObject* args ) {
cdebug_log(20,0) << "PyBox_contains ()" << endl;
@ -210,8 +201,6 @@ extern "C" {
}
}
// ---------------------------------------------------------------
// Attribute Method : "PyBox_intersect ()"
static PyObject* PyBox_intersect ( PyBox *self, PyObject* args ) {
cdebug_log(20,0) << "PyBox_intersect ()" << endl;
@ -238,11 +227,6 @@ extern "C" {
}
// ---------------------------------------------------------------
// Attribute Method : "PyBox_isConstrainedBy ()"
static PyObject* PyBox_isConstrainedBy ( PyBox *self, PyObject* args ) {
cdebug_log(20,0) << "PyBox_isConstrainedBy ()" << endl;
@ -267,11 +251,6 @@ extern "C" {
}
// ---------------------------------------------------------------
// Attribute Method : "PyBox_makeEmpty ()"
static PyObject* PyBox_makeEmpty ( PyBox *self, PyObject* args ) {
cdebug_log(20,0) << "PyBox_makeEmpty ()" << endl;
@ -285,8 +264,6 @@ extern "C" {
return (PyObject*)self;
}
// ---------------------------------------------------------------
// Attribute Method : "PyBox_inflate ()"
static PyObject* PyBox_inflate ( PyBox *self, PyObject* args ) {
cdebug_log(20,0) << "PyBox_inflate ()" << endl;
@ -322,8 +299,6 @@ extern "C" {
return ( (PyObject*)self );
}
// ---------------------------------------------------------------
// Attribute Method : "PyBox_merge ()"
static PyObject* PyBox_merge ( PyBox *self, PyObject* args ) {
cdebug_log(20,0) << "Box_merge()" << endl;
@ -360,8 +335,6 @@ extern "C" {
return ( (PyObject*)self );
}
// ---------------------------------------------------------------
// Attribute Method : "PyBox_translate ()"
static PyObject* PyBox_translate ( PyBox *self, PyObject* args ) {
cdebug_log(20,0) << "PyBox_translate ()" << endl;
@ -387,8 +360,6 @@ extern "C" {
}
// ---------------------------------------------------------------
// PyBox Attribute Method table.
@ -421,25 +392,22 @@ extern "C" {
, {NULL, NULL, 0, NULL} /* sentinel */
};
// x-------------------------------------------------------------x
// +-------------------------------------------------------------+
// | "PyBox" Object Methods |
// x-------------------------------------------------------------x
// +-------------------------------------------------------------+
DirectDeleteMethod(PyBox_DeAlloc,PyBox)
PyTypeObjectLinkPyTypeNewInit(Box)
//PyTypeObjectLinkPyType(Box)
PyTypeObjectLinkPyTypeAsValue(Box)
#else // End of Python Module Code Part.
// x=================================================================x
// +=================================================================+
// | "PyBox" Shared Library Code Part |
// x=================================================================x
// +=================================================================+
// ---------------------------------------------------------------
// PyBox Object Definitions.
PyTypeObjectDefinitions(Box)

View File

@ -140,7 +140,7 @@ extern "C" {
return 1;
}
DirectHashMethod (PyMaterial_Hash , PyMaterial)
DirectHashMethod (PyMaterial_Hash , Material)
DirectReprMethod (PyMaterial_Repr , PyMaterial, BasicLayer::Material)
DirectStrMethod (PyMaterial_Str , PyMaterial, BasicLayer::Material)
DirectDeleteMethod(PyMaterial_DeAlloc, PyMaterial)

View File

@ -62,10 +62,10 @@ extern "C" {
PythonOnlyDeleteMethod(NetDirection)
DirectReprMethod(PyNetDirection_Repr, PyNetDirection, Net::Direction)
DirectStrMethod (PyNetDirection_Str, PyNetDirection, Net::Direction)
DirectCmpMethod (PyNetDirection_Cmp, IsPyNetDirection, PyNetDirection)
DirectHashMethod(PyNetDirection_Hash, PyNetDirection)
DirectReprMethod (PyNetDirection_Repr, PyNetDirection, Net::Direction)
DirectStrMethod (PyNetDirection_Str, PyNetDirection, Net::Direction)
DirectCmpByValueMethod(PyNetDirection_Cmp, IsPyNetDirection, PyNetDirection)
DirectHashMethod (PyNetDirection_Hash, NetDirection)
extern void PyNetDirection_LinkPyType() {
cdebug_log(20,0) << "PyNetDirection_LinkType()" << endl;

View File

@ -61,10 +61,10 @@ extern "C" {
PythonOnlyDeleteMethod(NetType)
DirectReprMethod(PyNetType_Repr, PyNetType, Net::Type)
DirectStrMethod (PyNetType_Str, PyNetType, Net::Type)
DirectCmpMethod (PyNetType_Cmp, IsPyNetType, PyNetType)
DirectHashMethod(PyNetType_Hash, PyNetType)
DirectReprMethod (PyNetType_Repr, PyNetType, Net::Type)
DirectStrMethod (PyNetType_Str, PyNetType, Net::Type)
DirectCmpByValueMethod(PyNetType_Cmp, IsPyNetType, PyNetType)
DirectHashMethod (PyNetType_Hash, NetType)
extern void PyNetType_LinkPyType() {
cdebug_log(20,0) << "PyNetType_LinkType()" << endl;

View File

@ -66,10 +66,10 @@ extern "C" {
PythonOnlyDeleteMethod(Orientation)
DirectReprMethod(PyOrientation_Repr, PyOrientation, Transformation::Orientation)
DirectStrMethod (PyOrientation_Str, PyOrientation, Transformation::Orientation)
DirectCmpMethod (PyOrientation_Cmp, IsPyOrientation, PyOrientation)
DirectHashMethod(PyOrientation_Hash, PyOrientation)
DirectReprMethod (PyOrientation_Repr, PyOrientation, Transformation::Orientation)
DirectStrMethod (PyOrientation_Str, PyOrientation, Transformation::Orientation)
DirectCmpByValueMethod(PyOrientation_Cmp, IsPyOrientation, PyOrientation)
DirectHashMethod (PyOrientation_Hash, Orientation)
extern void PyOrientation_LinkPyType() {
cdebug_log(20,0) << "PyOrientation_LinkType()" << endl;

View File

@ -62,10 +62,10 @@ extern "C" {
PythonOnlyDeleteMethod(PinDirection)
DirectReprMethod(PyPinDirection_Repr, PyPinDirection, Pin::AccessDirection)
DirectStrMethod (PyPinDirection_Str, PyPinDirection, Pin::AccessDirection)
DirectCmpMethod (PyPinDirection_Cmp, IsPyPinDirection, PyPinDirection)
DirectHashMethod(PyPinDirection_Hash, PyPinDirection)
DirectReprMethod (PyPinDirection_Repr, PyPinDirection, Pin::AccessDirection)
DirectStrMethod (PyPinDirection_Str, PyPinDirection, Pin::AccessDirection)
DirectCmpByValueMethod(PyPinDirection_Cmp, IsPyPinDirection, PyPinDirection)
DirectHashMethod (PyPinDirection_Hash, PinDirection)
extern void PyPinDirection_LinkPyType() {
cdebug_log(20,0) << "PyPinDirection_LinkType()" << endl;

View File

@ -62,10 +62,10 @@ extern "C" {
PythonOnlyDeleteMethod(PinPlacementStatus)
DirectReprMethod(PyPinPlacementStatus_Repr, PyPinPlacementStatus, Pin::PlacementStatus)
DirectStrMethod (PyPinPlacementStatus_Str, PyPinPlacementStatus, Pin::PlacementStatus)
DirectCmpMethod (PyPinPlacementStatus_Cmp, IsPyPinPlacementStatus, PyPinPlacementStatus)
DirectHashMethod(PyPinPlacementStatus_Hash, PyPinPlacementStatus)
DirectReprMethod (PyPinPlacementStatus_Repr, PyPinPlacementStatus, Pin::PlacementStatus)
DirectStrMethod (PyPinPlacementStatus_Str, PyPinPlacementStatus, Pin::PlacementStatus)
DirectCmpByValueMethod(PyPinPlacementStatus_Cmp, IsPyPinPlacementStatus, PyPinPlacementStatus)
DirectHashMethod (PyPinPlacementStatus_Hash, PinPlacementStatus)
extern void PyPinPlacementStatus_LinkPyType() {
cdebug_log(20,0) << "PyPinPlacementStatus_LinkType()" << endl;

View File

@ -66,10 +66,10 @@ extern "C" {
PythonOnlyDeleteMethod(PlacementStatus)
DirectReprMethod(PyPlacementStatus_Repr, PyPlacementStatus, Instance::PlacementStatus)
DirectStrMethod (PyPlacementStatus_Str, PyPlacementStatus, Instance::PlacementStatus)
DirectCmpMethod (PyPlacementStatus_Cmp, IsPyPlacementStatus, PyPlacementStatus)
DirectHashMethod(PyPlacementStatus_Hash, PyPlacementStatus)
DirectReprMethod (PyPlacementStatus_Repr, PyPlacementStatus, Instance::PlacementStatus)
DirectStrMethod (PyPlacementStatus_Str, PyPlacementStatus, Instance::PlacementStatus)
DirectCmpByValueMethod(PyPlacementStatus_Cmp, IsPyPlacementStatus, PyPlacementStatus)
DirectHashMethod (PyPlacementStatus_Hash, PlacementStatus)
extern void PyPlacementStatus_LinkPyType() {
cdebug_log(20,0) << "PyPlacementStatus_LinkType()" << endl;

View File

@ -22,6 +22,7 @@
// #define DEBUG 1
#include "Python.h"
#include <type_traits>
#include <exception>
#include <iostream>
#include <sstream>
@ -42,6 +43,7 @@ namespace Isobar {
using Hurricane::Bug;
using Hurricane::Error;
using Hurricane::Warning;
using Hurricane::DBo;
// -------------------------------------------------------------------
@ -165,6 +167,14 @@ namespace Isobar {
inline PyObject* PyDbU_FromLong ( T unit ) { return PyLong_FromLongLong( unit ); }
template< typename T , typename enable_if<is_base_of<DBo,T>::value,int>::type = 0 >
static int getPyHash ( T* cppObject ) { return cppObject->getId(); }
template< typename T , typename enable_if<!is_base_of<DBo,T>::value,int>::type = 0 >
static int getPyHash ( T* cppObject ) { return (long)cppObject; }
extern "C" {
@ -1116,29 +1126,45 @@ extern "C" {
// -------------------------------------------------------------------
// Attribute Method For Cmp.
// Attribute Method For Cmp, compare pointer value (unicity)
# define DirectCmpMethod(PY_FUNC_NAME,IS_PY_OBJECT,PY_SELF_TYPE) \
# define DirectCmpByPtrMethod(PY_FUNC_NAME,IS_PY_OBJECT,PY_SELF_TYPE) \
static int PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* other ) \
{ \
if ( ! IS_PY_OBJECT(other) ) { return ( -1 ); } \
if (not IS_PY_OBJECT(other)) return -1; \
\
PY_SELF_TYPE* otherPyObject = (PY_SELF_TYPE *)other; \
if ( self->ACCESS_OBJECT == otherPyObject->ACCESS_OBJECT ) return ( 0 ); \
if ( self->ACCESS_OBJECT < otherPyObject->ACCESS_OBJECT ) return ( -1 ); \
PY_SELF_TYPE* otherPyObject = (PY_SELF_TYPE*)other; \
if (self->ACCESS_OBJECT == otherPyObject->ACCESS_OBJECT) return 0; \
if (self->ACCESS_OBJECT < otherPyObject->ACCESS_OBJECT) return -1; \
\
return ( 1 ); \
return 1; \
}
// -------------------------------------------------------------------
// Attribute Method For Cmp, compare object contents
# define DirectCmpByValueMethod(PY_FUNC_NAME,IS_PY_OBJECT,PY_SELF_TYPE) \
static int PY_FUNC_NAME ( PY_SELF_TYPE *self, PyObject* other ) \
{ \
if (not IS_PY_OBJECT(other)) return -1; \
\
PY_SELF_TYPE* otherPyObject = (PY_SELF_TYPE*)other; \
if (*(self->ACCESS_OBJECT) == *(otherPyObject->ACCESS_OBJECT)) return 0; \
if ( self->ACCESS_OBJECT < otherPyObject->ACCESS_OBJECT ) return -1; \
\
return 1; \
}
// -------------------------------------------------------------------
// Attribute Method For Hash.
# define DirectHashMethod(PY_FUNC_NAME,PY_SELF_TYPE) \
static int PY_FUNC_NAME ( PY_SELF_TYPE *self) \
{ \
return (long)self->ACCESS_OBJECT; \
}
# define DirectHashMethod(PY_FUNC_NAME,SELF_TYPE) \
static int PY_FUNC_NAME ( Py##SELF_TYPE* self ) \
{ return getPyHash( self->ACCESS_OBJECT ); }
// -------------------------------------------------------------------
@ -1297,39 +1323,39 @@ extern "C" {
// -------------------------------------------------------------------
// Initialisation Function for PyTypeObject Runtime Link.
#define PyTypeObjectLinkPyTypeWithClass(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() { \
cdebug_log(20,0) << "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_methods = Py##PY_SELF_TYPE##_Methods; \
#define PyTypeObjectLinkPyTypeWithClass(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) \
DirectCmpByPtrMethod(Py##PY_SELF_TYPE##_Cmp, IsPy##PY_SELF_TYPE, Py##PY_SELF_TYPE) \
DirectHashMethod (Py##PY_SELF_TYPE##_Hash, SELF_TYPE) \
extern void Py##PY_SELF_TYPE##_LinkPyType() { \
cdebug_log(20,0) << "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_methods = Py##PY_SELF_TYPE##_Methods; \
}
#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() { \
cdebug_log(20,0) << "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; \
#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) \
DirectCmpByPtrMethod (Py##PY_SELF_TYPE##_Cmp, IsPy##PY_SELF_TYPE, Py##PY_SELF_TYPE) \
DirectHashMethod (Py##PY_SELF_TYPE##_Hash, SELF_TYPE) \
extern void Py##PY_SELF_TYPE##_LinkPyType() { \
cdebug_log(20,0) << "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; \
}
@ -1340,20 +1366,39 @@ extern "C" {
PyTypeObjectLinkPyTypeWithClassNewInit(SELF_TYPE,SELF_TYPE)
#define PyTypeObjectLinkPyTypeAsValue(SELF_TYPE) \
DirectReprMethod (Py##SELF_TYPE##_Repr, Py##SELF_TYPE, SELF_TYPE) \
DirectStrMethod (Py##SELF_TYPE##_Str, Py##SELF_TYPE, SELF_TYPE) \
DirectCmpByValueMethod(Py##SELF_TYPE##_Cmp, IsPy##SELF_TYPE, Py##SELF_TYPE) \
DirectHashMethod (Py##SELF_TYPE##_Hash, SELF_TYPE) \
extern void Py##SELF_TYPE##_LinkPyType() { \
cdebug_log(20,0) << "Py" #SELF_TYPE "_LinkType()" << endl; \
\
PyType##SELF_TYPE.tp_dealloc = (destructor) Py##SELF_TYPE##_DeAlloc; \
PyType##SELF_TYPE.tp_compare = (cmpfunc) Py##SELF_TYPE##_Cmp; \
PyType##SELF_TYPE.tp_repr = (reprfunc) Py##SELF_TYPE##_Repr; \
PyType##SELF_TYPE.tp_str = (reprfunc) Py##SELF_TYPE##_Str; \
PyType##SELF_TYPE.tp_hash = (hashfunc) Py##SELF_TYPE##_Hash; \
PyType##SELF_TYPE.tp_new = (newfunc) Py##SELF_TYPE##_NEW; \
PyType##SELF_TYPE.tp_init = (initproc) Py##SELF_TYPE##_Init; \
PyType##SELF_TYPE.tp_methods = Py##SELF_TYPE##_Methods; \
}
// Special Initialisation Function for Locator PyTypeObject Runtime Link.
#define LocatorPyTypeObjectLinkPyType(PY_SELF_TYPE, SELF_TYPE) \
DirectReprMethod(Py##PY_SELF_TYPE##Locator_Repr, Py##PY_SELF_TYPE##Locator, Locator<SELF_TYPE>) \
DirectStrMethod (Py##PY_SELF_TYPE##Locator_Str, Py##PY_SELF_TYPE##Locator, Locator<SELF_TYPE>) \
DirectCmpMethod (Py##PY_SELF_TYPE##Locator_Cmp, IsPy##PY_SELF_TYPE##Locator, Py##PY_SELF_TYPE##Locator) \
extern void Py##PY_SELF_TYPE##Locator_LinkPyType () \
{ \
cdebug_log(20,0) << "Py" #PY_SELF_TYPE "Locator_LinkType()" << endl; \
\
PyType##PY_SELF_TYPE##Locator.tp_dealloc = (destructor)Py##PY_SELF_TYPE##Locator_DeAlloc; \
PyType##PY_SELF_TYPE##Locator.tp_compare = (cmpfunc) Py##PY_SELF_TYPE##Locator_Cmp; \
PyType##PY_SELF_TYPE##Locator.tp_repr = (reprfunc) Py##PY_SELF_TYPE##Locator_Repr; \
PyType##PY_SELF_TYPE##Locator.tp_str = (reprfunc) Py##PY_SELF_TYPE##Locator_Str; \
PyType##PY_SELF_TYPE##Locator.tp_methods = Py##PY_SELF_TYPE##Locator_Methods; \
#define LocatorPyTypeObjectLinkPyType(PY_SELF_TYPE, SELF_TYPE) \
DirectReprMethod (Py##PY_SELF_TYPE##Locator_Repr, Py##PY_SELF_TYPE##Locator, Locator<SELF_TYPE>) \
DirectStrMethod (Py##PY_SELF_TYPE##Locator_Str, Py##PY_SELF_TYPE##Locator, Locator<SELF_TYPE>) \
DirectCmpByPtrMethod(Py##PY_SELF_TYPE##Locator_Cmp, IsPy##PY_SELF_TYPE##Locator, Py##PY_SELF_TYPE##Locator) \
extern void Py##PY_SELF_TYPE##Locator_LinkPyType () \
{ \
cdebug_log(20,0) << "Py" #PY_SELF_TYPE "Locator_LinkType()" << endl; \
\
PyType##PY_SELF_TYPE##Locator.tp_dealloc = (destructor)Py##PY_SELF_TYPE##Locator_DeAlloc; \
PyType##PY_SELF_TYPE##Locator.tp_compare = (cmpfunc) Py##PY_SELF_TYPE##Locator_Cmp; \
PyType##PY_SELF_TYPE##Locator.tp_repr = (reprfunc) Py##PY_SELF_TYPE##Locator_Repr; \
PyType##PY_SELF_TYPE##Locator.tp_str = (reprfunc) Py##PY_SELF_TYPE##Locator_Str; \
PyType##PY_SELF_TYPE##Locator.tp_methods = Py##PY_SELF_TYPE##Locator_Methods; \
}
#define PyTypeObjectDefinitions(SELF_TYPE) \

View File

@ -41,6 +41,7 @@ namespace Hurricane {
using Isobar::HurricaneWarning;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::getPyHash;
extern "C" {
@ -374,7 +375,7 @@ extern "C" {
PythonOnlyDeleteMethod(DisplayStyle)
DirectHashMethod(PyDisplayStyle_Hash, PyDisplayStyle)
DirectHashMethod(PyDisplayStyle_Hash, DisplayStyle)
extern void PyDisplayStyle_LinkPyType() {
cdebug_log(20,0) << "PyDisplayStyle_LinkType()" << endl;

View File

@ -38,6 +38,7 @@ namespace Hurricane {
using Isobar::HurricaneWarning;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::getPyHash;
extern "C" {
@ -184,7 +185,7 @@ extern "C" {
PythonOnlyDeleteMethod(DrawingGroup)
DirectHashMethod(PyDrawingGroup_Hash, PyDrawingGroup)
DirectHashMethod(PyDrawingGroup_Hash, DrawingGroup)
extern void PyDrawingGroup_LinkPyType() {
cdebug_log(20,0) << "PyDrawingGroup_LinkType()" << endl;

View File

@ -30,6 +30,7 @@ namespace Hurricane {
using Isobar::HurricaneWarning;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::getPyHash;
extern "C" {

View File

@ -33,6 +33,7 @@ namespace Hurricane {
using Isobar::HurricaneWarning;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::getPyHash;
extern "C" {

View File

@ -36,6 +36,7 @@ namespace Hurricane {
using Isobar::HurricaneWarning;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::getPyHash;
extern "C" {

View File

@ -34,18 +34,20 @@ namespace Hurricane {
using Isobar::HurricaneWarning;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::getPyHash;
typedef DisplayStyle::HSVr HSVr;
extern "C" {
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(DisplayStyle::HSVr,hsvr,function)
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(HSVr,hsvr,function)
#if defined(__PYTHON_MODULE__)
// +=================================================================+
// | "PyHSVr" Python Module Code Part |
// | "PyHSVr" Python Module Code Part |
// +=================================================================+
@ -53,8 +55,8 @@ extern "C" {
{
cdebug_log(20,0) << "PyHSVr_new()" << endl;
DisplayStyle::HSVr* hsvr = NULL;
PyHSVr* pyHSVr = (PyHSVr*)type->tp_alloc(type,0);
HSVr* hsvr = NULL;
PyHSVr* pyHSVr = (PyHSVr*)type->tp_alloc(type,0);
HTRY
if ( pyHSVr ) {
@ -62,7 +64,7 @@ extern "C" {
float saturation = 1.0;
float value = 1.0;
if (PyArg_ParseTuple(args,"fff:HSVr.new", &hue, &saturation, &value)) {
hsvr = new DisplayStyle::HSVr(hue,saturation,value);
hsvr = new HSVr(hue,saturation,value);
} else {
PyErr_SetString ( ConstructorError, "invalid number of parameters for HSVr()." );
return NULL;
@ -77,7 +79,7 @@ extern "C" {
static PyObject* PyHSVr_Repr ( PyHSVr* self )
{
DisplayStyle::HSVr* hsvr = self->_object;
HSVr* hsvr = self->_object;
if ( hsvr == NULL )
return PyString_FromString("<PyObject unbound>");
@ -92,15 +94,15 @@ extern "C" {
// Standart Accessors (Attributes).
DirectGetDoubleAttribute(PyHSVr_GetHue ,getHue ,PyHSVr,DisplayStyle::HSVr)
DirectGetDoubleAttribute(PyHSVr_GetSaturation,getSaturation,PyHSVr,DisplayStyle::HSVr)
DirectGetDoubleAttribute(PyHSVr_GetValue ,getValue ,PyHSVr,DisplayStyle::HSVr)
DirectSetDoubleAttribute(PyHSVr_SetHue ,setHue ,PyHSVr,DisplayStyle::HSVr)
DirectSetDoubleAttribute(PyHSVr_SetSaturation,setSaturation,PyHSVr,DisplayStyle::HSVr)
DirectSetDoubleAttribute(PyHSVr_SetValue ,setValue ,PyHSVr,DisplayStyle::HSVr)
DirectGetDoubleAttribute(PyHSVr_GetHue ,getHue ,PyHSVr,HSVr)
DirectGetDoubleAttribute(PyHSVr_GetSaturation,getSaturation,PyHSVr,HSVr)
DirectGetDoubleAttribute(PyHSVr_GetValue ,getValue ,PyHSVr,HSVr)
DirectSetDoubleAttribute(PyHSVr_SetHue ,setHue ,PyHSVr,HSVr)
DirectSetDoubleAttribute(PyHSVr_SetSaturation,setSaturation,PyHSVr,HSVr)
DirectSetDoubleAttribute(PyHSVr_SetValue ,setValue ,PyHSVr,HSVr)
// Standart Predicates (Attributes).
DirectGetBoolAttribute(PyHSVr_IsId,isId,PyHSVr,DisplayStyle::HSVr)
DirectGetBoolAttribute(PyHSVr_IsId,isId,PyHSVr,HSVr)
PyMethodDef PyHSVr_Methods[] =
@ -116,7 +118,7 @@ extern "C" {
DirectDeleteMethod(PyHSVr_DeAlloc,PyHSVr)
DirectHashMethod(PyHSVr_Hash, PyHSVr)
DirectHashMethod(PyHSVr_Hash,HSVr)
extern void PyHSVr_LinkPyType() {
cdebug_log(20,0) << "PyHSVr_LinkType()" << endl;
@ -137,7 +139,7 @@ extern "C" {
// +=================================================================+
// Link/Creation Method.
PyObject* PyHSVr_Link ( DisplayStyle::HSVr* object )
PyObject* PyHSVr_Link ( HSVr* object )
{
if ( object == NULL ) Py_RETURN_NONE;

View File

@ -29,6 +29,7 @@ namespace Hurricane {
using std::cerr;
using std::endl;
using Isobar::__cs;
using Isobar::getPyHash;
#if !defined(__PYTHON_MODULE__)

View File

@ -27,6 +27,7 @@ namespace Katana {
using std::cerr;
using std::endl;
using Hurricane::tab;
using Isobar::getPyHash;
using Isobar::__cs;
using CRL::PyTypeToolEngine;
using CRL::PyTypeGraphicTool;

View File

@ -49,6 +49,7 @@ namespace Katana {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::PyNet;

View File

@ -31,6 +31,7 @@ namespace Katana {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
@ -61,10 +62,10 @@ extern "C" {
PythonOnlyDeleteMethod(KatanaFlags)
DirectReprMethod(PyKatanaFlags_Repr, PyKatanaFlags, Katana::Flags)
DirectStrMethod (PyKatanaFlags_Str, PyKatanaFlags, Katana::Flags)
DirectCmpMethod (PyKatanaFlags_Cmp, IsPyKatanaFlags, PyKatanaFlags)
DirectHashMethod(PyKatanaFlags_Hash, PyKatanaFlags)
DirectReprMethod (PyKatanaFlags_Repr, PyKatanaFlags, Katana::Flags)
DirectStrMethod (PyKatanaFlags_Str, PyKatanaFlags, Katana::Flags)
DirectCmpByValueMethod(PyKatanaFlags_Cmp, IsPyKatanaFlags, PyKatanaFlags)
DirectHashMethod (PyKatanaFlags_Hash, KatanaFlags)
extern void PyKatanaFlags_LinkPyType() {
cdebug_log(20,0) << "PyKatanaFlags_LinkType()" << endl;

View File

@ -27,6 +27,7 @@ namespace Kite {
using std::endl;
using Hurricane::tab;
using Isobar::__cs;
using Isobar::getPyHash;
using CRL::PyTypeToolEngine;
using CRL::PyTypeGraphicTool;

View File

@ -45,6 +45,7 @@ namespace Kite {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::PyCell;

View File

@ -27,6 +27,7 @@ namespace Tutorial {
using std::endl;
using Hurricane::tab;
using Isobar::__cs;
using Isobar::getPyHash;
using CRL::PyTypeToolEngine;
using CRL::PyTypeGraphicTool;

View File

@ -46,6 +46,7 @@ namespace Tutorial {
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::PyCell;