Made the Freestyle Python API compatible with Python 3.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 27 Sep 2009 00:32:20 +0000 (00:32 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 27 Sep 2009 00:32:20 +0000 (00:32 +0000)
205 files changed:
source/blender/CMakeLists.txt
source/blender/SConscript
source/blender/freestyle/CMakeLists.txt
source/blender/freestyle/intern/python/BPy_BBox.cpp
source/blender/freestyle/intern/python/BPy_BBox.h
source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.h
source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.h
source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
source/blender/freestyle/intern/python/BPy_ContextFunctions.h
source/blender/freestyle/intern/python/BPy_Convert.cpp
source/blender/freestyle/intern/python/BPy_Convert.h
source/blender/freestyle/intern/python/BPy_Freestyle.cpp
source/blender/freestyle/intern/python/BPy_Freestyle.h
source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp
source/blender/freestyle/intern/python/BPy_FrsMaterial.h
source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
source/blender/freestyle/intern/python/BPy_FrsNoise.h
source/blender/freestyle/intern/python/BPy_Id.cpp
source/blender/freestyle/intern/python/BPy_Id.h
source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
source/blender/freestyle/intern/python/BPy_IntegrationType.h
source/blender/freestyle/intern/python/BPy_Interface0D.cpp
source/blender/freestyle/intern/python/BPy_Interface0D.h
source/blender/freestyle/intern/python/BPy_Interface1D.cpp
source/blender/freestyle/intern/python/BPy_Interface1D.h
source/blender/freestyle/intern/python/BPy_Iterator.cpp
source/blender/freestyle/intern/python/BPy_Iterator.h
source/blender/freestyle/intern/python/BPy_MediumType.cpp
source/blender/freestyle/intern/python/BPy_MediumType.h
source/blender/freestyle/intern/python/BPy_Nature.cpp
source/blender/freestyle/intern/python/BPy_Nature.h
source/blender/freestyle/intern/python/BPy_Operators.cpp
source/blender/freestyle/intern/python/BPy_Operators.h
source/blender/freestyle/intern/python/BPy_SShape.cpp
source/blender/freestyle/intern/python/BPy_SShape.h
source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
source/blender/freestyle/intern/python/BPy_StrokeShader.h
source/blender/freestyle/intern/python/BPy_UnaryFunction0D.cpp
source/blender/freestyle/intern/python/BPy_UnaryFunction0D.h
source/blender/freestyle/intern/python/BPy_UnaryFunction1D.cpp
source/blender/freestyle/intern/python/BPy_UnaryFunction1D.h
source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.h
source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.h
source/blender/freestyle/intern/python/BPy_ViewMap.cpp
source/blender/freestyle/intern/python/BPy_ViewMap.h
source/blender/freestyle/intern/python/BPy_ViewShape.cpp
source/blender/freestyle/intern/python/BPy_ViewShape.h
source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp
source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp
source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp
source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp
source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
source/blender/freestyle/intern/python/Director.cpp
source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp
source/blender/freestyle/intern/python/Interface0D/BPy_ViewVertex.cpp
source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp
source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp
source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.cpp
source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.h
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.h
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.h
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.h
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.h
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.h
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.h
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.h
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.h
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Id/BPy_ShapeIdF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Material/BPy_MaterialF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_Normal2DF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetOccludeeF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_ViewShape/BPy_GetShapeF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_Curvature2DAngleF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_DensityF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedXF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedYF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetProjectedZF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetXF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetYF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_GetZF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_LocalAverageDepthF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_double/BPy_ZDiscontinuityF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetParameterF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadMapPixelF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.h
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.h
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.h
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.h
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.h
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.h
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.h
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludeeF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetOccludersF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_vector_ViewShape/BPy_GetShapeF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_ChainingTimeStampF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp
source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_TimeStampF1D.cpp
source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp
source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp
source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp
source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp
source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp
source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp
source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp
source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp
source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp
source/blender/python/CMakeLists.txt
source/blender/python/SConscript
source/blender/python/intern/bpy_interface.c

index 703c5acd8a204194002ff2563fb085b0a944cdac..e4f80cf322349e90e4ae76f49e8b63bec0b900e1 100644 (file)
@@ -40,6 +40,7 @@ ADD_SUBDIRECTORY(makesrna)
 ADD_SUBDIRECTORY(readblenfile)
 ADD_SUBDIRECTORY(render)
 ADD_SUBDIRECTORY(blenfont)
+ADD_SUBDIRECTORY(freestyle)
 
 IF(WITH_OPENEXR)
        ADD_SUBDIRECTORY(imbuf/intern/openexr)
index a064850c170deae9b1355b2208cbe6168c72bc1e..0882c8143c64950e32c695f695bf036669b8f127 100644 (file)
@@ -32,3 +32,6 @@ if env['WITH_BF_OPENEXR']:
 
 if env['WITH_BF_QUICKTIME']:
     SConscript (['quicktime/SConscript'])
+
+if env['WITH_BF_FREESTYLE']:
+    SConscript (['freestyle/SConscript'])
index eb2569c464922f84705622426ac92d8543a15269..74b0beca4217cbe80183726a0e5b8ea6398bf287 100644 (file)
@@ -27,7 +27,7 @@
 FILE(GLOB_RECURSE SRC *.cpp)
 
 SET(INC 
-  ../blenkernel ../blenloader ../blenlib ../imbuf ../makesdna ../python
+  ../blenkernel ../blenloader ../blenlib ../imbuf ../makesdna ../makesrna ../python
   ../render/extern/include ../render/intern/include ../include ../src
   ../../../extern/glew/include ../../../intern/guardedalloc ../freestyle
   ${PYTHON_INC}
index ac15672580d415d9616fb1ca76236a3b8ca0238e..3e73e871c3e1e445a3009ec704cd943ece996cef 100644 (file)
@@ -19,105 +19,66 @@ static PyMethodDef BPy_BBox_methods[] = {
 /*-----------------------BPy_BBox type definition ------------------------------*/
 
 PyTypeObject BBox_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "BBox",                         /* tp_name */
-       sizeof( BPy_BBox ),     /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)BBox___dealloc__,   /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       (reprfunc)BBox___repr__,                                        /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_BBox_methods,       /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)BBox___init__, /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "BBox",                         /* tp_name */
+       sizeof(BPy_BBox),               /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)BBox___dealloc__,   /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)BBox___repr__,        /* 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 | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "BBox objects",                 /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_BBox_methods,               /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       (initproc)BBox___init__,        /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC BBox_Init( PyObject *module )
+int BBox_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &BBox_Type ) < 0 )
-               return;
+               return -1;
 
        Py_INCREF( &BBox_Type );
        PyModule_AddObject(module, "BBox", (PyObject *)&BBox_Type);
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
 
 int BBox___init__(BPy_BBox *self, PyObject *args, PyObject *kwds)
 {
+       if(!( PyArg_ParseTuple(args, "") ))
+               return -1;
        self->bb = new BBox< Vec3r>();
        return 0;
 }
@@ -125,13 +86,13 @@ int BBox___init__(BPy_BBox *self, PyObject *args, PyObject *kwds)
 void BBox___dealloc__(BPy_BBox* self)
 {
        delete self->bb;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 
 PyObject * BBox___repr__(BPy_BBox* self)
 {
-    return PyString_FromFormat("BBox - address: %p", self->bb );
+    return PyUnicode_FromFormat("BBox - address: %p", self->bb );
 }
 
 
index 90fbc565b33ae561f19c49f7ab4715a0a6070b74..96a61e18c2f16471bc200852be093c50e9e706fd 100644 (file)
@@ -25,7 +25,7 @@ typedef struct {
 
 /*---------------------------Python BPy_BBox visible prototypes-----------*/
 
-PyMODINIT_FUNC BBox_Init( PyObject *module );
+int BBox_Init( PyObject *module );
 
 
 ///////////////////////////////////////////////////////////////////////////////////////////
index 79a4bae3b3ef853e4b36535fd29e56994dfbc670..c6b418d727a57f76c53191af92373474df70cfca 100644 (file)
@@ -19,106 +19,65 @@ static PyObject * BinaryPredicate0D___call__( BPy_BinaryPredicate0D *self, PyObj
 
 /*----------------------BinaryPredicate0D instance definitions ----------------------------*/
 static PyMethodDef BPy_BinaryPredicate0D_methods[] = {
-       {"getName", ( PyCFunction ) BinaryPredicate0D_getName, METH_NOARGS, "( )Returns the string of the name of the binary predicate."},
+       {"getName", ( PyCFunction ) BinaryPredicate0D_getName, METH_NOARGS, "() Returns the string of the name of the binary predicate."},
        {NULL, NULL, 0, NULL}
 };
 
 /*-----------------------BPy_BinaryPredicate0D type definition ------------------------------*/
 
 PyTypeObject BinaryPredicate0D_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "BinaryPredicate0D",                            /* tp_name */
-       sizeof( BPy_BinaryPredicate0D ),        /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)BinaryPredicate0D___dealloc__,      /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       (reprfunc)BinaryPredicate0D___repr__,                                   /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       (ternaryfunc)BinaryPredicate0D___call__,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_BinaryPredicate0D_methods,  /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)BinaryPredicate0D___init__, /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "BinaryPredicate0D",            /* tp_name */
+       sizeof(BPy_BinaryPredicate0D),  /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)BinaryPredicate0D___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)BinaryPredicate0D___repr__, /* tp_repr */
+       0,                              /* tp_as_number */
+       0,                              /* tp_as_sequence */
+       0,                              /* tp_as_mapping */
+       0,                              /* tp_hash  */
+       (ternaryfunc)BinaryPredicate0D___call__, /* tp_call */
+       0,                              /* tp_str */
+       0,                              /* tp_getattro */
+       0,                              /* tp_setattro */
+       0,                              /* tp_as_buffer */
+       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "BinaryPredicate0D objects",    /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_BinaryPredicate0D_methods,  /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       (initproc)BinaryPredicate0D___init__, /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC BinaryPredicate0D_Init( PyObject *module )
+int BinaryPredicate0D_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &BinaryPredicate0D_Type ) < 0 )
-               return;
+               return -1;
 
        Py_INCREF( &BinaryPredicate0D_Type );
        PyModule_AddObject(module, "BinaryPredicate0D", (PyObject *)&BinaryPredicate0D_Type);
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
@@ -137,19 +96,19 @@ void BinaryPredicate0D___dealloc__(BPy_BinaryPredicate0D* self)
 {
        if (self->bp0D)
                delete self->bp0D;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 
 PyObject * BinaryPredicate0D___repr__(BPy_BinaryPredicate0D* self)
 {
-    return PyString_FromFormat("type: %s - address: %p", self->bp0D->getName().c_str(), self->bp0D );
+    return PyUnicode_FromFormat("type: %s - address: %p", self->bp0D->getName().c_str(), self->bp0D );
 }
 
 
 PyObject * BinaryPredicate0D_getName( BPy_BinaryPredicate0D *self, PyObject *args)
 {
-       return PyString_FromString( self->bp0D->getName().c_str() );
+       return PyUnicode_FromFormat( self->bp0D->getName().c_str() );
 }
 
 PyObject * BinaryPredicate0D___call__( BPy_BinaryPredicate0D *self, PyObject *args, PyObject *kwds)
index 8b92fbe4e35416ad3026e095a8f2e443b08b8b2e..d27b6cc0fe8159f3e62ceb89ce1b0fd747d24026 100644 (file)
@@ -23,7 +23,7 @@ typedef struct {
 
 /*---------------------------Python BPy_BinaryPredicate0D visible prototypes-----------*/
 
-PyMODINIT_FUNC BinaryPredicate0D_Init( PyObject *module );
+int BinaryPredicate0D_Init( PyObject *module );
 
 
 ///////////////////////////////////////////////////////////////////////////////////////////
index 1f38aa42096f4b4a90e114c41fe0f138e43cc770..384aafeb56762a60ec82d0c586b52ab0ce1dea92 100644 (file)
@@ -25,131 +25,89 @@ static PyObject * BinaryPredicate1D___call__( BPy_BinaryPredicate1D *self, PyObj
 
 /*----------------------BinaryPredicate1D instance definitions ----------------------------*/
 static PyMethodDef BPy_BinaryPredicate1D_methods[] = {
-       {"getName", ( PyCFunction ) BinaryPredicate1D_getName, METH_NOARGS, "( )Returns the string of the name of the binary predicate."},
+       {"getName", ( PyCFunction ) BinaryPredicate1D_getName, METH_NOARGS, "() Returns the string of the name of the binary predicate."},
        {NULL, NULL, 0, NULL}
 };
 
 /*-----------------------BPy_BinaryPredicate1D type definition ------------------------------*/
 PyTypeObject BinaryPredicate1D_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                                      /* ob_size */
-       "BinaryPredicate1D",                            /* tp_name */
-       sizeof( BPy_BinaryPredicate1D ),        /* tp_basicsize */
-       0,                                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)BinaryPredicate1D___dealloc__,              /* tp_dealloc */
-       NULL,                                                           /* printfunc tp_print; */
-       NULL,                                                           /* getattrfunc tp_getattr; */
-       NULL,                                                           /* setattrfunc tp_setattr; */
-       NULL,                                                                                   /* tp_compare */
-       (reprfunc)BinaryPredicate1D___repr__,                                           /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       (ternaryfunc)BinaryPredicate1D___call__,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_BinaryPredicate1D_methods,  /* struct PyMethodDef *tp_methods; */
-       NULL,                                                   /*  struct PyMemberDef *tp_members; */
-       NULL,                                                   /*  struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /*  struct _typeobject *tp_base; */
-       NULL,                           /* PyObject *tp_dict; */
-       NULL,                           /* descrgetfunc tp_descr_get; */
-       NULL,                           /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)BinaryPredicate1D___init__,                           /* initproc tp_init; */
-       NULL,                           /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "BinaryPredicate1D",            /* tp_name */
+       sizeof(BPy_BinaryPredicate1D),  /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)BinaryPredicate1D___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)BinaryPredicate1D___repr__, /* tp_repr */
+       0,                              /* tp_as_number */
+       0,                              /* tp_as_sequence */
+       0,                              /* tp_as_mapping */
+       0,                              /* tp_hash  */
+       (ternaryfunc)BinaryPredicate1D___call__, /* tp_call */
+       0,                              /* tp_str */
+       0,                              /* tp_getattro */
+       0,                              /* tp_setattro */
+       0,                              /* tp_as_buffer */
+       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "BinaryPredicate1D objects",    /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_BinaryPredicate1D_methods,  /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       (initproc)BinaryPredicate1D___init__, /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC BinaryPredicate1D_Init( PyObject *module )
+int BinaryPredicate1D_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &BinaryPredicate1D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &BinaryPredicate1D_Type );
        PyModule_AddObject(module, "BinaryPredicate1D", (PyObject *)&BinaryPredicate1D_Type);
        
        if( PyType_Ready( &FalseBP1D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &FalseBP1D_Type );
        PyModule_AddObject(module, "FalseBP1D", (PyObject *)&FalseBP1D_Type);
        
        if( PyType_Ready( &Length2DBP1D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &Length2DBP1D_Type );
        PyModule_AddObject(module, "Length2DBP1D", (PyObject *)&Length2DBP1D_Type);
        
        if( PyType_Ready( &SameShapeIdBP1D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &SameShapeIdBP1D_Type );
        PyModule_AddObject(module, "SameShapeIdBP1D", (PyObject *)&SameShapeIdBP1D_Type);
        
        if( PyType_Ready( &TrueBP1D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &TrueBP1D_Type );
        PyModule_AddObject(module, "TrueBP1D", (PyObject *)&TrueBP1D_Type);
        
        if( PyType_Ready( &ViewMapGradientNormBP1D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ViewMapGradientNormBP1D_Type );
        PyModule_AddObject(module, "ViewMapGradientNormBP1D", (PyObject *)&ViewMapGradientNormBP1D_Type);
        
-       
+       return 0;
 }
 
 
@@ -168,17 +126,17 @@ void BinaryPredicate1D___dealloc__(BPy_BinaryPredicate1D* self)
 {
        if (self->bp1D)
                delete self->bp1D;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 PyObject * BinaryPredicate1D___repr__(BPy_BinaryPredicate1D* self)
 {
-    return PyString_FromFormat("type: %s - address: %p", self->bp1D->getName().c_str(), self->bp1D );
+    return PyUnicode_FromFormat("type: %s - address: %p", self->bp1D->getName().c_str(), self->bp1D );
 }
 
 PyObject *BinaryPredicate1D_getName( BPy_BinaryPredicate1D *self, PyObject *args)
 {
-       return PyString_FromString( self->bp1D->getName().c_str() );
+       return PyUnicode_FromFormat( self->bp1D->getName().c_str() );
 }
 
 PyObject *BinaryPredicate1D___call__( BPy_BinaryPredicate1D *self, PyObject *args, PyObject *kwds)
index 66f5e2fd4dfe435f7ccaf6e1572bc39bd1d9557d..42419ce71299c9802f7937f46458ce93735c9269 100644 (file)
@@ -23,7 +23,7 @@ typedef struct {
 
 /*---------------------------Python BPy_BinaryPredicate1D visible prototypes-----------*/
 
-PyMODINIT_FUNC BinaryPredicate1D_Init( PyObject *module );
+int BinaryPredicate1D_Init( PyObject *module );
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
index 942540844001d3acb19d8aced2c8d68ef3a48bfa..43db0f0eb29832b87e7445861f75f6c7bc82b788 100644 (file)
@@ -22,7 +22,7 @@ static PyObject * ContextFunctions_GetSelectedFEdgeCF( PyObject *self );
 
 /*-----------------------ContextFunctions module docstring-------------------------------*/
 
-static char module_docstring[] = "The Blender.Freestyle.ContextFunctions submodule";
+static char module_docstring[] = "The Blender Freestyle.ContextFunctions submodule\n\n";
 
 /*-----------------------ContextFunctions module functions definitions-------------------*/
 
@@ -38,18 +38,28 @@ static PyMethodDef module_functions[] = {
   {NULL, NULL, 0, NULL}
 };
 
+/*-----------------------ContextFunctions module definition--------------------------------*/
+
+static PyModuleDef module_definition = {
+    PyModuleDef_HEAD_INIT,
+    "Freestyle.ContextFunctions",
+    module_docstring,
+    -1,
+    module_functions
+};
+
 //------------------- MODULE INITIALIZATION --------------------------------
 
-void ContextFunctions_Init( PyObject *module )
+int ContextFunctions_Init( PyObject *module )
 {      
   PyObject *m, *d, *f;
 
   if( module == NULL )
-    return;
+    return -1;
 
-  m = Py_InitModule3("Blender.Freestyle.ContextFunctions", module_functions, module_docstring);
+  m = PyModule_Create(&module_definition);
   if (m == NULL)
-    return;
+    return -1;
   Py_INCREF(m);
   PyModule_AddObject(module, "ContextFunctions", m);
 
@@ -60,6 +70,8 @@ void ContextFunctions_Init( PyObject *module )
        Py_INCREF(f);
        PyModule_AddObject(module, p->ml_name, f);
   }
+
+  return 0;
 }
 
 //------------------------ MODULE FUNCTIONS ----------------------------------
@@ -67,19 +79,19 @@ void ContextFunctions_Init( PyObject *module )
 static PyObject *
 ContextFunctions_GetTimeStampCF( PyObject* self )
 {
-  return PyInt_FromLong( ContextFunctions::GetTimeStampCF() );
+  return PyLong_FromLong( ContextFunctions::GetTimeStampCF() );
 }
 
 static PyObject *
 ContextFunctions_GetCanvasWidthCF( PyObject* self )
 {
-  return PyInt_FromLong( ContextFunctions::GetCanvasWidthCF() );
+  return PyLong_FromLong( ContextFunctions::GetCanvasWidthCF() );
 }
 
 static PyObject *
 ContextFunctions_GetCanvasHeightCF( PyObject* self )
 {
-  return PyInt_FromLong( ContextFunctions::GetCanvasHeightCF() );
+  return PyLong_FromLong( ContextFunctions::GetCanvasHeightCF() );
 }
 
 static PyObject *
index b02145c455a9008aa81622ca0e2d455cbb5d4c42..5ec70f1a261d04f3d7ee6ed678128c2c89a2da7a 100644 (file)
@@ -9,7 +9,7 @@ extern "C" {
 
 /*---------------------------Python BPy_ContextFunctions visible prototypes-----------*/
 
-PyMODINIT_FUNC ContextFunctions_Init( PyObject *module );
+int ContextFunctions_Init( PyObject *module );
 
 #ifdef __cplusplus
 }
index cdf20ea4e5f38cd8c69202e3873df76c16c4ceb2..e3f979fea8f28440b36faae637ecfeb3bb02a235 100644 (file)
@@ -58,21 +58,21 @@ PyObject * Vector_from_Vec2f( Vec2f& vec ) {
        float vec_data[2]; // because vec->_coord is protected
 
        vec_data[0] = vec.x();          vec_data[1] = vec.y();
-       return newVectorObject( vec_data, 2, Py_NEW);
+       return newVectorObject( vec_data, 2, Py_NEW, NULL);
 }
 
 PyObject * Vector_from_Vec3f( Vec3f& vec ) {
        float vec_data[3]; // because vec->_coord is protected
        
        vec_data[0] = vec.x();          vec_data[1] = vec.y();          vec_data[2] = vec.z(); 
-       return newVectorObject( vec_data, 3, Py_NEW);
+       return newVectorObject( vec_data, 3, Py_NEW, NULL);
 }
 
 PyObject * Vector_from_Vec3r( Vec3r& vec ) {
        float vec_data[3]; // because vec->_coord is protected
        
        vec_data[0] = vec.x();          vec_data[1] = vec.y();          vec_data[2] = vec.z(); 
-       return newVectorObject( vec_data, 3, Py_NEW);
+       return newVectorObject( vec_data, 3, Py_NEW, NULL);
 }
 
 PyObject * BPy_Id_from_Id( Id& id ) {
@@ -208,7 +208,7 @@ PyObject * BPy_Nature_from_Nature( unsigned short n ) {
        PyObject *py_n;
 
        PyObject *args = PyTuple_New(1);
-       PyTuple_SetItem( args, 0, PyInt_FromLong(n) );
+       PyTuple_SetItem( args, 0, PyLong_FromLong(n) );
        py_n =  Nature_Type.tp_new(&Nature_Type, args, NULL);
        Py_DECREF(args);
 
@@ -231,12 +231,12 @@ PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa ) {
        return py_sa;   
 }
 
-PyObject * BPy_MediumType_from_MediumType( int n ) {
-       PyObject *py_mt =  MediumType_Type.tp_new( &MediumType_Type, 0, 0 );
+PyObject * BPy_MediumType_from_MediumType( Stroke::MediumType n ) {
+       PyObject *py_mt;
 
        PyObject *args = PyTuple_New(1);
-       PyTuple_SetItem( args, 0, PyInt_FromLong(n) );
-       MediumType_Type.tp_init( py_mt, args, 0 );
+       PyTuple_SetItem( args, 0, PyLong_FromLong(n) );
+       py_mt = MediumType_Type.tp_new( &MediumType_Type, args, NULL );
        Py_DECREF(args);
 
        return py_mt;
@@ -330,12 +330,12 @@ PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m ){
        return py_m;
 }
 
-PyObject * BPy_IntegrationType_from_IntegrationType( int i ) {
-       PyObject *py_it = IntegrationType_Type.tp_new( &IntegrationType_Type, 0, 0 );
+PyObject * BPy_IntegrationType_from_IntegrationType( IntegrationType i ) {
+       PyObject *py_it;
 
        PyObject *args = PyTuple_New(1);
-       PyTuple_SetItem( args, 0, PyInt_FromLong(i) );
-       IntegrationType_Type.tp_init( py_it, args, 0 );
+       PyTuple_SetItem( args, 0, PyLong_FromLong(i) );
+       py_it = IntegrationType_Type.tp_new( &IntegrationType_Type, args, NULL );
        Py_DECREF(args);
 
        return py_it;
@@ -457,15 +457,15 @@ bool bool_from_PyBool( PyObject *b ) {
 }
 
 IntegrationType IntegrationType_from_BPy_IntegrationType( PyObject* obj ) {
-       return static_cast<IntegrationType>( PyInt_AsLong(obj) );
+       return static_cast<IntegrationType>( PyLong_AsLong(obj) );
 }
 
 Stroke::MediumType MediumType_from_BPy_MediumType( PyObject* obj ) {
-       return static_cast<Stroke::MediumType>( PyInt_AsLong(obj) );
+       return static_cast<Stroke::MediumType>( PyLong_AsLong(obj) );
 }
 
 Nature::EdgeNature EdgeNature_from_BPy_Nature( PyObject* obj ) {
-       return static_cast<Nature::EdgeNature>( PyInt_AsLong(obj) );
+       return static_cast<Nature::EdgeNature>( PyLong_AsLong(obj) );
 }
 
 Vec2f * Vec2f_ptr_from_PyObject( PyObject* obj ) {
index ad3fc3fc328222191098bb002901f8bddf218220..3c0ada2ce764ef465dd21a5a6964b10ff7ba22f2 100644 (file)
@@ -62,8 +62,7 @@ extern "C" {
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 #include <Python.h>
-#include "api2_2x/vector.h"
-#include "api2_2x/gen_utils.h"
+#include "generic/Mathutils.h"
 
 //==============================
 // C++ => Python
@@ -88,10 +87,10 @@ PyObject * BPy_FEdgeSmooth_from_FEdgeSmooth( FEdgeSmooth& fes );
 PyObject * BPy_Id_from_Id( Id& id );
 PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D );
 PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D );
-PyObject * BPy_IntegrationType_from_IntegrationType( int i );
+PyObject * BPy_IntegrationType_from_IntegrationType( IntegrationType i );
 PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m );
 PyObject * BPy_Nature_from_Nature( unsigned short n );
-PyObject * BPy_MediumType_from_MediumType( int n );
+PyObject * BPy_MediumType_from_MediumType( Stroke::MediumType n );
 PyObject * BPy_SShape_from_SShape( SShape& ss );
 PyObject * BPy_Stroke_from_Stroke( Stroke& s );
 PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa );
index 1afc3cc903edba723275a5c5d52d89b66442868a..3f53619cdbd1ae1b853dfa0b76dd3fd913a2edd2 100644 (file)
@@ -32,99 +32,27 @@ extern "C" {
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 
-/*-----------------------Python API function prototypes for the Freestyle module--*/
 //static PyObject *Freestyle_testOutput( BPy_Freestyle * self );
-/*-----------------------Freestyle module doc strings-----------------------------*/
-static char M_Freestyle_doc[] = "The Blender.Freestyle submodule";
-/*----------------------Freestyle module method def----------------------------*/
-struct PyMethodDef M_Freestyle_methods[] = {
+
+/*-----------------------Freestyle module doc strings--------------------------*/
+
+static char module_docstring[] = "The Blender Freestyle module\n\n";
+
+/*-----------------------Freestyle module method def---------------------------*/
+
+static PyMethodDef module_functions[] = {
 //     {"testOutput", ( PyCFunction ) Freestyle_testOutput, METH_NOARGS, "() - Return Curve Data name"},
        {NULL, NULL, 0, NULL}
 };
 
-/*-----------------------BPy_Freestyle method def------------------------------*/
+/*-----------------------Freestyle module definition---------------------------*/
 
-PyTypeObject Freestyle_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "Freestyle",                            /* tp_name */
-       sizeof( BPy_Freestyle ),        /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       NULL,                                           /* tp_dealloc */
-       NULL,                       /* printfunc tp_print; */
-       NULL,                       /* getattrfunc tp_getattr; */
-       NULL,                       /* setattrfunc tp_setattr; */
-       NULL,                                           /* tp_compare */
-       NULL,                                           /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT,             /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       NULL,                                           /* struct PyMethodDef *tp_methods; */
-       NULL,                       /* struct PyMemberDef *tp_members; */
-       NULL,                                   /* struct PyGetSetDef *tp_getset; */
-       NULL,                       /* struct _typeobject *tp_base; */
-       NULL,                       /* PyObject *tp_dict; */
-       NULL,                       /* descrgetfunc tp_descr_get; */
-       NULL,                       /* descrsetfunc tp_descr_set; */
-       0,                          /* long tp_dictoffset; */
-       NULL,                       /* initproc tp_init; */
-       NULL,                       /* allocfunc tp_alloc; */
-       NULL,                       /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+static PyModuleDef module_definition = {
+    PyModuleDef_HEAD_INIT,
+    "Freestyle",
+    module_docstring,
+    -1,
+    module_functions
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
@@ -132,12 +60,11 @@ PyObject *Freestyle_Init( void )
 {
        PyObject *module;
        
-       if( PyType_Ready( &Freestyle_Type ) < 0 )
-               return NULL;
-       
        // initialize modules
-       module = Py_InitModule3( "Blender.Freestyle", M_Freestyle_methods, M_Freestyle_doc );
-       
+       module = PyModule_Create(&module_definition);
+    if (!module)
+               return NULL;
+       PyDict_SetItemString(PySys_GetObject("modules"), module_definition.m_name, module);
        
        // attach its classes (adding the object types to the module)
        
index 4990a2e685d1d776d08f6ae168824b9a3801b53f..4a280cee5af1168ee2dbdf5e6355082078496c62 100644 (file)
@@ -9,15 +9,6 @@ extern "C" {
 
 #include <Python.h>
 
-extern PyTypeObject Freestyle_Type;
-
-#define BPy_Freestyle_Check(v) (  PyObject_IsInstance( (PyObject *) v, (PyObject *) &Freestyle_Type)  )
-
-/*---------------------------Python BPy_Freestyle structure definition----------*/
-typedef struct {
-       PyObject_HEAD 
-} BPy_Freestyle;
-
 /*---------------------------Python BPy_Freestyle visible prototypes-----------*/
 
 PyObject *Freestyle_Init( void );
index 453c71cbfd5b61e4b3bdf9498ac4c9994fdf758c..462ea7e34303d04db297c830b9db59ac524e384e 100644 (file)
@@ -74,99 +74,58 @@ static PyMethodDef BPy_FrsMaterial_methods[] = {
 /*-----------------------BPy_FrsMaterial type definition ------------------------------*/
 
 PyTypeObject FrsMaterial_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "FrsMaterial",                          /* tp_name */
-       sizeof( BPy_FrsMaterial ),      /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)FrsMaterial___dealloc__,    /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       (reprfunc)FrsMaterial___repr__,                                 /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_FrsMaterial_methods,        /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)FrsMaterial___init__, /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "FrsMaterial",                  /* tp_name */
+       sizeof(BPy_FrsMaterial),        /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)FrsMaterial___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)FrsMaterial___repr__, /* 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 | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "FrsMaterial objects",          /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_FrsMaterial_methods,        /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       (initproc)FrsMaterial___init__, /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC FrsMaterial_Init( PyObject *module )
+int FrsMaterial_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &FrsMaterial_Type ) < 0 )
-               return;
+               return -1;
 
        Py_INCREF( &FrsMaterial_Type );
        PyModule_AddObject(module, "FrsMaterial", (PyObject *)&FrsMaterial_Type);
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
@@ -223,13 +182,13 @@ void FrsMaterial___dealloc__( BPy_FrsMaterial* self)
 {
        if( self->m && !self->borrowed )
                delete self->m;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 
 PyObject * FrsMaterial___repr__( BPy_FrsMaterial* self)
 {
-    return PyString_FromFormat("FrsMaterial - address: %p", self->m );
+    return PyUnicode_FromFormat("FrsMaterial - address: %p", self->m );
 }
 
 PyObject * FrsMaterial_diffuse( BPy_FrsMaterial* self) {
index 9d6629127f9d4480ba1b8a89c9b9387ed278de28..01bdabc09d931936805a514cf724ae2d42558fde 100644 (file)
@@ -24,7 +24,7 @@ typedef struct {
 
 /*---------------------------Python BPy_FrsMaterial visible prototypes-----------*/
 
-PyMODINIT_FUNC FrsMaterial_Init( PyObject *module );
+int FrsMaterial_Init( PyObject *module );
 
 
 ///////////////////////////////////////////////////////////////////////////////////////////
index 945cd9921cc66e446ad2f9831a7c40576266473a..8c21fa63ba16355a3175ef42ace871dcb597b88c 100644 (file)
@@ -23,117 +23,78 @@ static PyObject * FrsNoise_smoothNoise3( BPy_FrsNoise *self, PyObject *args);
 
 /*----------------------FrsNoise instance definitions ----------------------------*/
 static PyMethodDef BPy_FrsNoise_methods[] = {
-       {"turbulence1", ( PyCFunction ) FrsNoise_turbulence1, METH_VARARGS, "(float arg, float freq, float amp, unsigned oct=4)Returns a noise value for a 1D element"},
-       {"turbulence2", ( PyCFunction ) FrsNoise_turbulence2, METH_VARARGS, "([x, y], float freq, float amp, unsigned oct=4)))Returns a noise value for a 2D element"},
-       {"turbulence3", ( PyCFunction ) FrsNoise_turbulence3, METH_VARARGS, "([x, y, z], float freq, float amp, unsigned oct=4)))Returns a noise value for a 3D element"},
-       {"smoothNoise1", ( PyCFunction ) FrsNoise_smoothNoise1, METH_VARARGS, "(float arg)Returns a smooth noise value for a 1D element "},
-       {"smoothNoise2", ( PyCFunction ) FrsNoise_smoothNoise2, METH_VARARGS, "([x, y])Returns a smooth noise value for a 2D element "},
-       {"smoothNoise3", ( PyCFunction ) FrsNoise_smoothNoise3, METH_VARARGS, "([x, y, z))Returns a smooth noise value for a 3D element "},
+       {"turbulence1", ( PyCFunction ) FrsNoise_turbulence1, METH_VARARGS, "(float arg, float freq, float amp, unsigned oct=4) Returns a noise value for a 1D element"},
+       {"turbulence2", ( PyCFunction ) FrsNoise_turbulence2, METH_VARARGS, "([x, y], float freq, float amp, unsigned oct=4) Returns a noise value for a 2D element"},
+       {"turbulence3", ( PyCFunction ) FrsNoise_turbulence3, METH_VARARGS, "([x, y, z], float freq, float amp, unsigned oct=4) Returns a noise value for a 3D element"},
+       {"smoothNoise1", ( PyCFunction ) FrsNoise_smoothNoise1, METH_VARARGS, "(float arg) Returns a smooth noise value for a 1D element "},
+       {"smoothNoise2", ( PyCFunction ) FrsNoise_smoothNoise2, METH_VARARGS, "([x, y]) Returns a smooth noise value for a 2D element "},
+       {"smoothNoise3", ( PyCFunction ) FrsNoise_smoothNoise3, METH_VARARGS, "([x, y, z]) Returns a smooth noise value for a 3D element "},
        {NULL, NULL, 0, NULL}
 };
 
 /*-----------------------BPy_FrsNoise type definition ------------------------------*/
 
 PyTypeObject FrsNoise_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "FrsNoise",                             /* tp_name */
-       sizeof( BPy_FrsNoise ), /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)FrsNoise___dealloc__,       /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       (reprfunc)FrsNoise___repr__,                                    /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_FrsNoise_methods,   /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)FrsNoise___init__, /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "FrsNoise",                     /* tp_name */
+       sizeof(BPy_FrsNoise),           /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)FrsNoise___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)FrsNoise___repr__,    /* 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 | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "FrsNoise objects",             /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_FrsNoise_methods,           /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       (initproc)FrsNoise___init__,    /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC FrsNoise_Init( PyObject *module )
+int FrsNoise_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &FrsNoise_Type ) < 0 )
-               return;
+               return -1;
 
        Py_INCREF( &FrsNoise_Type );
        PyModule_AddObject(module, "FrsNoise", (PyObject *)&FrsNoise_Type);
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
 
 int FrsNoise___init__(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
 {
+       if(!( PyArg_ParseTuple(args, "") ))
+               return -1;
        self->n = new Noise();
        return 0;
 }
@@ -141,13 +102,13 @@ int FrsNoise___init__(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
 void FrsNoise___dealloc__(BPy_FrsNoise* self)
 {
        delete self->n;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 
 PyObject * FrsNoise___repr__(BPy_FrsNoise* self)
 {
-    return PyString_FromFormat("FrsNoise - address: %p", self->n );
+    return PyUnicode_FromFormat("FrsNoise - address: %p", self->n );
 }
 
 
index d0215fda9afeb74ff335a9ecb35dcbd89724d586..9b06ea0c37d84ca06226ec8a901b828e69bb606a 100644 (file)
@@ -23,7 +23,7 @@ typedef struct {
 
 /*---------------------------Python BPy_FrsNoise visible prototypes-----------*/
 
-PyMODINIT_FUNC FrsNoise_Init( PyObject *module );
+int FrsNoise_Init( PyObject *module );
 
 
 ///////////////////////////////////////////////////////////////////////////////////////////
index 0396e4a36ffbfc36534c6fa29401e0f295ef8af6..fbc22c2bffc69ff2d6348bb49d7efe798cfca6c1 100644 (file)
@@ -31,99 +31,58 @@ static PyMethodDef BPy_Id_methods[] = {
 /*-----------------------BPy_Id type definition ------------------------------*/
 
 PyTypeObject Id_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "Id",                                           /* tp_name */
-       sizeof( BPy_Id ),                       /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)Id___dealloc__,     /* tp_dealloc */
-       NULL,                       /* printfunc tp_print; */
-       NULL,                       /* getattrfunc tp_getattr; */
-       NULL,                       /* setattrfunc tp_setattr; */
-       NULL,                                           /* tp_compare */
-       (reprfunc)Id___repr__,                          /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       (richcmpfunc)Id_RichCompare,                   /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_Id_methods, /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)Id___init__,           /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,                                              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "Id",                           /* tp_name */
+       sizeof(BPy_Id),                 /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)Id___dealloc__,     /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)Id___repr__,          /* 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 | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "Id objects",                   /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       (richcmpfunc)Id_RichCompare,    /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_Id_methods,                 /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       (initproc)Id___init__,          /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC Id_Init( PyObject *module )
+int Id_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &Id_Type ) < 0 )
-               return;
+               return -1;
 
        Py_INCREF( &Id_Type );
        PyModule_AddObject(module, "Id", (PyObject *)&Id_Type);
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
@@ -144,21 +103,21 @@ int Id___init__(BPy_Id *self, PyObject *args, PyObject *kwds)
 void Id___dealloc__(BPy_Id* self)
 {
        delete self->id;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 PyObject * Id___repr__(BPy_Id* self)
 {
-    return PyString_FromFormat("[ first: %i, second: %i ](BPy_Id)", self->id->getFirst(), self->id->getSecond() );
+    return PyUnicode_FromFormat("[ first: %i, second: %i ](BPy_Id)", self->id->getFirst(), self->id->getSecond() );
 }
 
 PyObject *Id_getFirst( BPy_Id *self ) {
-       return PyInt_FromLong( self->id->getFirst() );
+       return PyLong_FromLong( self->id->getFirst() );
 }
 
 
 PyObject *Id_getSecond( BPy_Id *self) {
-       return PyInt_FromLong( self->id->getSecond() );
+       return PyLong_FromLong( self->id->getSecond() );
 }
 
 
index fd9446618b8ecf2cba762baf7f68631346909250..3063334f0754363494c32651bdaea4904283d982 100644 (file)
@@ -26,7 +26,7 @@ typedef struct {
 
 /*---------------------------Python BPy_Id visible prototypes-----------*/
 
-PyMODINIT_FUNC Id_Init( PyObject *module );
+int Id_Init( PyObject *module );
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
index adab3636b0dbb964fc73dcb813b0d327d30aa92d..b40780a7778f77423d72cffd3bfa29a3b8ee455d 100644 (file)
@@ -12,13 +12,11 @@ extern "C" {
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
-static PyObject *BPy_IntegrationType_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
-
 static PyObject * Integrator_integrate( PyObject *self, PyObject *args );
 
 /*-----------------------Integrator module docstring---------------------------------------*/
 
-static char module_docstring[] = "The Blender.Freestyle.Integrator submodule";
+static char module_docstring[] = "The Blender Freestyle.Integrator submodule\n\n";
 
 /*-----------------------Integrator module functions definitions---------------------------*/
 
@@ -27,150 +25,110 @@ static PyMethodDef module_functions[] = {
   {NULL, NULL, 0, NULL}
 };
 
+/*-----------------------Integrator module definition--------------------------------------*/
+
+static PyModuleDef module_definition = {
+    PyModuleDef_HEAD_INIT,
+    "Freestyle.Integrator",
+    module_docstring,
+    -1,
+    module_functions
+};
+
 /*-----------------------BPy_IntegrationType type definition ------------------------------*/
 
 PyTypeObject IntegrationType_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "IntegrationType",                              /* tp_name */
-       sizeof( BPy_IntegrationType ),  /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       NULL,   /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       NULL,                                   /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       NULL,                                                   /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       &PyInt_Type,                                                    /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       NULL,                           /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       BPy_IntegrationType_new,                /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyObject_HEAD_INIT(NULL)
+       "IntegrationType",              /* tp_name */
+       sizeof(PyLongObject),           /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       0,                              /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       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 */
+       "IntegrationType objects",      /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       0,                              /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       &PyLong_Type,                   /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       0,                              /* tp_init */
+       0,                              /* tp_alloc */
+       0,                              /* tp_new */
 };
 
-static PyObject *
-BPy_IntegrationType_FromIntegrationType(int t)
-{
-       BPy_IntegrationType *obj;
-
-       obj = PyObject_New(BPy_IntegrationType, &IntegrationType_Type);
-       if (!obj)
-               return NULL;
-       ((PyIntObject *)obj)->ob_ival = t;
-       return (PyObject *)obj;
-}
+/*-----------------------BPy_IntegrationType instance definitions -------------------------*/
 
-static PyObject *
-BPy_IntegrationType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-       int x = 0;
-       static char *kwlist[] = {"x", 0};
+static PyLongObject _IntegrationType_MEAN = {
+       PyVarObject_HEAD_INIT(&IntegrationType_Type, 1)
+       { MEAN }
+};
+static PyLongObject _IntegrationType_MIN = {
+       PyVarObject_HEAD_INIT(&IntegrationType_Type, 1)
+       { MIN }
+};
+static PyLongObject _IntegrationType_MAX = {
+       PyVarObject_HEAD_INIT(&IntegrationType_Type, 1)
+       { MAX }
+};
+static PyLongObject _IntegrationType_FIRST = {
+       PyVarObject_HEAD_INIT(&IntegrationType_Type, 1)
+       { FIRST }
+};
+static PyLongObject _IntegrationType_LAST = {
+       PyVarObject_HEAD_INIT(&IntegrationType_Type, 1)
+       { LAST }
+};
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist, &x))
-               return NULL;
-       return BPy_IntegrationType_FromIntegrationType(x);
-}
+#define BPy_IntegrationType_MEAN  ((PyObject *)&_IntegrationType_MEAN)
+#define BPy_IntegrationType_MIN   ((PyObject *)&_IntegrationType_MIN)
+#define BPy_IntegrationType_MAX   ((PyObject *)&_IntegrationType_MAX)
+#define BPy_IntegrationType_FIRST ((PyObject *)&_IntegrationType_FIRST)
+#define BPy_IntegrationType_LAST  ((PyObject *)&_IntegrationType_LAST)
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC IntegrationType_Init( PyObject *module )
+int IntegrationType_Init( PyObject *module )
 {      
-       PyObject *tmp, *m, *d, *f;
+       PyObject *m, *d, *f;
        
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &IntegrationType_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &IntegrationType_Type );
        PyModule_AddObject(module, "IntegrationType", (PyObject *)&IntegrationType_Type);
 
-       tmp = BPy_IntegrationType_FromIntegrationType( MEAN );
-       PyDict_SetItemString( IntegrationType_Type.tp_dict, "MEAN", tmp);
-       Py_DECREF(tmp);
-       
-       tmp = BPy_IntegrationType_FromIntegrationType( MIN );
-       PyDict_SetItemString( IntegrationType_Type.tp_dict, "MIN", tmp);
-       Py_DECREF(tmp);
-       
-       tmp = BPy_IntegrationType_FromIntegrationType( MAX );
-       PyDict_SetItemString( IntegrationType_Type.tp_dict, "MAX", tmp);
-       Py_DECREF(tmp);
+       PyDict_SetItemString( IntegrationType_Type.tp_dict, "MEAN", BPy_IntegrationType_MEAN);
+       PyDict_SetItemString( IntegrationType_Type.tp_dict, "MIN", BPy_IntegrationType_MIN);
+       PyDict_SetItemString( IntegrationType_Type.tp_dict, "MAX", BPy_IntegrationType_MAX);
+       PyDict_SetItemString( IntegrationType_Type.tp_dict, "FIRST", BPy_IntegrationType_FIRST);
+       PyDict_SetItemString( IntegrationType_Type.tp_dict, "LAST", BPy_IntegrationType_LAST);
        
-       tmp = BPy_IntegrationType_FromIntegrationType( FIRST );
-       PyDict_SetItemString( IntegrationType_Type.tp_dict, "FIRST", tmp);
-       Py_DECREF(tmp);
-       
-       tmp = BPy_IntegrationType_FromIntegrationType( LAST );
-       PyDict_SetItemString( IntegrationType_Type.tp_dict, "LAST", tmp);
-       Py_DECREF(tmp);
-       
-       m = Py_InitModule3("Blender.Freestyle.Integrator", module_functions, module_docstring);
-       if (m == NULL)
-               return;
+    m = PyModule_Create(&module_definition);
+    if (m == NULL)
+        return -1;
        Py_INCREF(m);
        PyModule_AddObject(module, "Integrator", m);
 
@@ -181,6 +139,8 @@ PyMODINIT_FUNC IntegrationType_Init( PyObject *module )
                Py_INCREF(f);
                PyModule_AddObject(module, p->ml_name, f);
        }
+
+       return 0;
 }
 
 //------------------------ MODULE FUNCTIONS ----------------------------------
@@ -232,7 +192,7 @@ static PyObject * Integrator_integrate( PyObject *self, PyObject *args )
        } else if( BPy_UnaryFunction0DUnsigned_Check(obj1) ) {
                UnaryFunction0D<unsigned int> *fun = ((BPy_UnaryFunction0DUnsigned *)obj1)->uf0D_unsigned;
                unsigned int res = integrate( *fun, it, it_end, t );
-               return PyInt_FromLong( res );
+               return PyLong_FromLong( res );
 
        } else {
                string msg("unsupported function type: " + string(obj1->ob_type->tp_name));
index a31fe9599963899a36a5396a534f2afb4b00f2b8..176d8750c455dfe561b8464b6b69436499d700f7 100644 (file)
@@ -15,14 +15,9 @@ extern PyTypeObject IntegrationType_Type;
 
 #define BPy_IntegrationType_Check(v)   (  PyObject_IsInstance( (PyObject *) v, (PyObject *) &IntegrationType_Type)  )
 
-/*---------------------------Python BPy_IntegrationType structure definition----------*/
-typedef struct {
-       PyIntObject i;
-} BPy_IntegrationType;
-
 /*---------------------------Python BPy_IntegrationType visible prototypes-----------*/
 
-PyMODINIT_FUNC IntegrationType_Init( PyObject *module );
+int IntegrationType_Init( PyObject *module );
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
index 8b016eca9056023aee288ca02429e36a8b28b204..6e170e8e0b7032c69884df172a8bd2695ef36606 100644 (file)
@@ -36,10 +36,10 @@ static PyObject *Interface0D_getNature( BPy_Interface0D *self );
 
 /*----------------------Interface0D instance definitions ----------------------------*/
 static PyMethodDef BPy_Interface0D_methods[] = {
-       {"getExactTypeName", ( PyCFunction ) Interface0D_getExactTypeName, METH_NOARGS, "( )Returns the string of the name of the interface."},
-       {"getX", ( PyCFunction ) Interface0D_getX, METH_NOARGS, "( )Returns the 3D x coordinate of the point. "},
-       {"getY", ( PyCFunction ) Interface0D_getY, METH_NOARGS, "( )Returns the 3D y coordinate of the point. "},
-       {"getZ", ( PyCFunction ) Interface0D_getZ, METH_NOARGS, "( )Returns the 3D z coordinate of the point. "},
+       {"getExactTypeName", ( PyCFunction ) Interface0D_getExactTypeName, METH_NOARGS, "() Returns the string of the name of the interface."},
+       {"getX", ( PyCFunction ) Interface0D_getX, METH_NOARGS, "() Returns the 3D x coordinate of the point. "},
+       {"getY", ( PyCFunction ) Interface0D_getY, METH_NOARGS, "() Returns the 3D y coordinate of the point. "},
+       {"getZ", ( PyCFunction ) Interface0D_getZ, METH_NOARGS, "() Returns the 3D z coordinate of the point. "},
        {"getPoint3D", ( PyCFunction ) Interface0D_getPoint3D, METH_NOARGS, "() Returns the 3D point."},
        {"getProjectedX", ( PyCFunction ) Interface0D_getProjectedX, METH_NOARGS, "() Returns the 2D x coordinate of the point."},
        {"getProjectedY", ( PyCFunction ) Interface0D_getProjectedY, METH_NOARGS, "() Returns the 2D y coordinate of the point."},
@@ -54,128 +54,88 @@ static PyMethodDef BPy_Interface0D_methods[] = {
 /*-----------------------BPy_Interface0D type definition ------------------------------*/
 
 PyTypeObject Interface0D_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "Interface0D",                          /* tp_name */
-       sizeof( BPy_Interface0D ),      /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)Interface0D___dealloc__,    /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       (reprfunc)Interface0D___repr__,                                 /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_Interface0D_methods,        /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)Interface0D___init__,                         /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "Interface0D",                  /* tp_name */
+       sizeof(BPy_Interface0D),        /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)Interface0D___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)Interface0D___repr__, /* 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 | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "Interface0D objects",          /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_Interface0D_methods,        /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       (initproc)Interface0D___init__, /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC Interface0D_Init( PyObject *module )
+int Interface0D_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &Interface0D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &Interface0D_Type );
        PyModule_AddObject(module, "Interface0D", (PyObject *)&Interface0D_Type);
        
        if( PyType_Ready( &CurvePoint_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &CurvePoint_Type );
        PyModule_AddObject(module, "CurvePoint", (PyObject *)&CurvePoint_Type);
        
        if( PyType_Ready( &SVertex_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &SVertex_Type );
        PyModule_AddObject(module, "SVertex", (PyObject *)&SVertex_Type);       
        
        if( PyType_Ready( &ViewVertex_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ViewVertex_Type );
        PyModule_AddObject(module, "ViewVertex", (PyObject *)&ViewVertex_Type);
        
        if( PyType_Ready( &StrokeVertex_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &StrokeVertex_Type );
        PyModule_AddObject(module, "StrokeVertex", (PyObject *)&StrokeVertex_Type);
        
        if( PyType_Ready( &NonTVertex_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &NonTVertex_Type );
        PyModule_AddObject(module, "NonTVertex", (PyObject *)&NonTVertex_Type);
        
        if( PyType_Ready( &TVertex_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &TVertex_Type );
        PyModule_AddObject(module, "TVertex", (PyObject *)&TVertex_Type);
+
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
@@ -193,16 +153,16 @@ void Interface0D___dealloc__(BPy_Interface0D* self)
 {
        if( self->if0D && !self->borrowed )
                delete self->if0D;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 PyObject * Interface0D___repr__(BPy_Interface0D* self)
 {
-    return PyString_FromFormat("type: %s - address: %p", self->if0D->getExactTypeName().c_str(), self->if0D );
+    return PyUnicode_FromFormat("type: %s - address: %p", self->if0D->getExactTypeName().c_str(), self->if0D );
 }
 
 PyObject *Interface0D_getExactTypeName( BPy_Interface0D *self ) {
-       return PyString_FromString( self->if0D->getExactTypeName().c_str() );   
+       return PyUnicode_FromFormat( self->if0D->getExactTypeName().c_str() );  
 }
 
 
index 673c12e6b8d64f2f8ce8169c773701725da38a83..cd8a8e19749242dc167c705ad492325aa9330752 100644 (file)
@@ -24,7 +24,7 @@ typedef struct {
 
 /*---------------------------Python BPy_Interface0D visible prototypes-----------*/
 
-PyMODINIT_FUNC Interface0D_Init( PyObject *module );
+int Interface0D_Init( PyObject *module );
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
index 4293921d44c1e20f4014465a65ca34ca91e219a6..9f4bb75411d1b6a4a15969875957da0767a699ef 100644 (file)
@@ -37,7 +37,7 @@ static PyObject * Interface1D_pointsEnd( BPy_Interface1D *self, PyObject *args )
 
 /*----------------------Interface1D instance definitions ----------------------------*/
 static PyMethodDef BPy_Interface1D_methods[] = {
-       {"getExactTypeName", ( PyCFunction ) Interface1D_getExactTypeName, METH_NOARGS, "( )Returns the string of the name of the interface."},
+       {"getExactTypeName", ( PyCFunction ) Interface1D_getExactTypeName, METH_NOARGS, "() Returns the string of the name of the interface."},
        {"getVertices", ( PyCFunction ) Interface1D_getVertices, METH_NOARGS, "Returns the vertices"},
        {"getPoints", ( PyCFunction ) Interface1D_getPoints, METH_NOARGS, "Returns the points. The difference with getVertices() is that here we can iterate over points of the 1D element at any given sampling. At each call, a virtual point is created."},
        {"getLength2D", ( PyCFunction ) Interface1D_getLength2D, METH_NOARGS, "Returns the 2D length of the 1D element"},
@@ -56,141 +56,97 @@ static PyMethodDef BPy_Interface1D_methods[] = {
 /*-----------------------BPy_Interface1D type definition ------------------------------*/
 
 PyTypeObject Interface1D_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "Interface1D",                          /* tp_name */
-       sizeof( BPy_Interface1D ),      /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)Interface1D___dealloc__,    /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       (reprfunc)Interface1D___repr__,                                 /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_Interface1D_methods,        /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)Interface1D___init__,                         /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "Interface1D",                  /* tp_name */
+       sizeof(BPy_Interface1D),        /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)Interface1D___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)Interface1D___repr__, /* 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 | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "Interface1D objects",          /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_Interface1D_methods,        /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       (initproc)Interface1D___init__, /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC Interface1D_Init( PyObject *module )
+int Interface1D_Init( PyObject *module )
 {
-       PyObject *tmp;
-       
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &Interface1D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &Interface1D_Type );
        PyModule_AddObject(module, "Interface1D", (PyObject *)&Interface1D_Type);
        
        if( PyType_Ready( &FrsCurve_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &FrsCurve_Type );
        PyModule_AddObject(module, "FrsCurve", (PyObject *)&FrsCurve_Type);
 
        if( PyType_Ready( &Chain_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &Chain_Type );
        PyModule_AddObject(module, "Chain", (PyObject *)&Chain_Type);
        
        if( PyType_Ready( &FEdge_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &FEdge_Type );
        PyModule_AddObject(module, "FEdge", (PyObject *)&FEdge_Type);
 
        if( PyType_Ready( &FEdgeSharp_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &FEdgeSharp_Type );
        PyModule_AddObject(module, "FEdgeSharp", (PyObject *)&FEdgeSharp_Type);
        
        if( PyType_Ready( &FEdgeSmooth_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &FEdgeSmooth_Type );
        PyModule_AddObject(module, "FEdgeSmooth", (PyObject *)&FEdgeSmooth_Type);
 
        if( PyType_Ready( &Stroke_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &Stroke_Type );
        PyModule_AddObject(module, "Stroke", (PyObject *)&Stroke_Type);
 
-       tmp = BPy_MediumType_from_MediumType( Stroke::DRY_MEDIUM ); PyDict_SetItemString( Stroke_Type.tp_dict, "DRY_MEDIUM", tmp); Py_DECREF(tmp);
-       tmp = BPy_MediumType_from_MediumType( Stroke::HUMID_MEDIUM ); PyDict_SetItemString( Stroke_Type.tp_dict, "HUMID_MEDIUM", tmp); Py_DECREF(tmp);
-       tmp = BPy_MediumType_from_MediumType( Stroke::OPAQUE_MEDIUM ); PyDict_SetItemString( Stroke_Type.tp_dict, "OPAQUE_MEDIUM", tmp); Py_DECREF(tmp);
+       PyDict_SetItemString( Stroke_Type.tp_dict, "DRY_MEDIUM", BPy_MediumType_DRY_MEDIUM );
+       PyDict_SetItemString( Stroke_Type.tp_dict, "HUMID_MEDIUM", BPy_MediumType_HUMID_MEDIUM );
+       PyDict_SetItemString( Stroke_Type.tp_dict, "OPAQUE_MEDIUM", BPy_MediumType_OPAQUE_MEDIUM );
 
        if( PyType_Ready( &ViewEdge_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ViewEdge_Type );
        PyModule_AddObject(module, "ViewEdge", (PyObject *)&ViewEdge_Type);
 
-       
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
@@ -208,16 +164,16 @@ void Interface1D___dealloc__(BPy_Interface1D* self)
 {
        if( self->if1D && !self->borrowed )
                delete self->if1D;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 PyObject * Interface1D___repr__(BPy_Interface1D* self)
 {
-    return PyString_FromFormat("type: %s - address: %p", self->if1D->getExactTypeName().c_str(), self->if1D );
+    return PyUnicode_FromFormat("type: %s - address: %p", self->if1D->getExactTypeName().c_str(), self->if1D );
 }
 
 PyObject *Interface1D_getExactTypeName( BPy_Interface1D *self ) {
-       return PyString_FromString( self->if1D->getExactTypeName().c_str() );   
+       return PyUnicode_FromFormat( self->if1D->getExactTypeName().c_str() );  
 }
 
 PyObject *Interface1D_getVertices( BPy_Interface1D *self ) {
@@ -242,7 +198,7 @@ PyObject *Interface1D_getNature( BPy_Interface1D *self ) {
 }
 
 PyObject *Interface1D_getTimeStamp( BPy_Interface1D *self ) {
-       return PyInt_FromLong( self->if1D->getTimeStamp() );
+       return PyLong_FromLong( self->if1D->getTimeStamp() );
 }
 
 PyObject *Interface1D_setTimeStamp( BPy_Interface1D *self, PyObject *args) {
index 25ca84fdf425ff4c09a82ae38b53d75ef5d76992..f82b80e20eb589a1f1ad74a3d4473a02c9fd67bd 100644 (file)
@@ -24,7 +24,7 @@ typedef struct {
 
 /*---------------------------Python BPy_Interface1D visible prototypes-----------*/
 
-PyMODINIT_FUNC Interface1D_Init( PyObject *module );
+int Interface1D_Init( PyObject *module );
 
 
 ///////////////////////////////////////////////////////////////////////////////////////////
index 1ae58073a675a461b286c587e38974d6055d561b..0e06c869a877f8f581f85cfea31965f4972a96a0 100644 (file)
@@ -32,161 +32,119 @@ static PyObject * Iterator_isEnd(BPy_Iterator* self);
 
 /*----------------------Iterator instance definitions ----------------------------*/
 static PyMethodDef BPy_Iterator_methods[] = {
-       {"getExactTypeName", ( PyCFunction ) Iterator_getExactTypeName, METH_NOARGS, "( )Returns the string of the name of the iterator."},
-       {"increment", ( PyCFunction ) Iterator_increment, METH_NOARGS, "( )Increments iterator."},
-       {"decrement", ( PyCFunction ) Iterator_decrement, METH_NOARGS, "( )Decrements iterator."},
-       {"isBegin", ( PyCFunction ) Iterator_isBegin, METH_NOARGS, "( )Tests if iterator points to beginning."},
-       {"isEnd", ( PyCFunction ) Iterator_isEnd, METH_NOARGS, "( )Tests if iterator points to end."},
+       {"getExactTypeName", ( PyCFunction ) Iterator_getExactTypeName, METH_NOARGS, "() Returns the string of the name of the iterator."},
+       {"increment", ( PyCFunction ) Iterator_increment, METH_NOARGS, "() Increments iterator."},
+       {"decrement", ( PyCFunction ) Iterator_decrement, METH_NOARGS, "() Decrements iterator."},
+       {"isBegin", ( PyCFunction ) Iterator_isBegin, METH_NOARGS, "() Tests if iterator points to beginning."},
+       {"isEnd", ( PyCFunction ) Iterator_isEnd, METH_NOARGS, "() Tests if iterator points to end."},
        {NULL, NULL, 0, NULL}
 };
 
 /*-----------------------BPy_Iterator type definition ------------------------------*/
 
 PyTypeObject Iterator_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "Iterator",                             /* tp_name */
-       sizeof( BPy_Iterator ), /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)Iterator___dealloc__,       /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       (reprfunc)Iterator___repr__,                                    /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_Iterator_methods,   /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       NULL,                           /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "Iterator",                     /* tp_name */
+       sizeof(BPy_Iterator),           /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)Iterator___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)Iterator___repr__,    /* 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 | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "Iterator objects",             /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_Iterator_methods,           /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       0,                              /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC Iterator_Init( PyObject *module )
+int Iterator_Init( PyObject *module )
 {      
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &Iterator_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &Iterator_Type );
        PyModule_AddObject(module, "Iterator", (PyObject *)&Iterator_Type);
 
        if( PyType_Ready( &AdjacencyIterator_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &AdjacencyIterator_Type );
        PyModule_AddObject(module, "AdjacencyIterator", (PyObject *)&AdjacencyIterator_Type);
 
        if( PyType_Ready( &Interface0DIterator_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &Interface0DIterator_Type );
        PyModule_AddObject(module, "Interface0DIterator", (PyObject *)&Interface0DIterator_Type);
        
        if( PyType_Ready( &CurvePointIterator_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &CurvePointIterator_Type );
        PyModule_AddObject(module, "CurvePointIterator", (PyObject *)&CurvePointIterator_Type);
        
        if( PyType_Ready( &StrokeVertexIterator_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &StrokeVertexIterator_Type );
        PyModule_AddObject(module, "StrokeVertexIterator", (PyObject *)&StrokeVertexIterator_Type);
        
        if( PyType_Ready( &SVertexIterator_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &SVertexIterator_Type );
        PyModule_AddObject(module, "SVertexIterator", (PyObject *)&SVertexIterator_Type);
        
        if( PyType_Ready( &orientedViewEdgeIterator_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &orientedViewEdgeIterator_Type );
        PyModule_AddObject(module, "orientedViewEdgeIterator", (PyObject *)&orientedViewEdgeIterator_Type);
        
        if( PyType_Ready( &ViewEdgeIterator_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ViewEdgeIterator_Type );
        PyModule_AddObject(module, "ViewEdgeIterator", (PyObject *)&ViewEdgeIterator_Type);
        
        if( PyType_Ready( &ChainingIterator_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ChainingIterator_Type );
        PyModule_AddObject(module, "ChainingIterator", (PyObject *)&ChainingIterator_Type);
        
        if( PyType_Ready( &ChainPredicateIterator_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ChainPredicateIterator_Type );
        PyModule_AddObject(module, "ChainPredicateIterator", (PyObject *)&ChainPredicateIterator_Type);
        
        if( PyType_Ready( &ChainSilhouetteIterator_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ChainSilhouetteIterator_Type );
        PyModule_AddObject(module, "ChainSilhouetteIterator", (PyObject *)&ChainSilhouetteIterator_Type);
        
-       
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
@@ -195,16 +153,16 @@ void Iterator___dealloc__(BPy_Iterator* self)
 {
        if (self->it)
                delete self->it;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 PyObject * Iterator___repr__(BPy_Iterator* self)
 {
-    return PyString_FromFormat("type: %s - address: %p", self->it->getExactTypeName().c_str(), self->it );
+    return PyUnicode_FromFormat("type: %s - address: %p", self->it->getExactTypeName().c_str(), self->it );
 }
 
 PyObject * Iterator_getExactTypeName(BPy_Iterator* self) {
-       return PyString_FromString( self->it->getExactTypeName().c_str() );     
+       return PyUnicode_FromFormat( self->it->getExactTypeName().c_str() );    
 }
 
 
index bad3980616348d95c54fa0c872aababa544eef0c..162df60d91ee6993f08e967058e07071931bd33a 100644 (file)
@@ -23,7 +23,7 @@ typedef struct {
 
 /*---------------------------Python BPy_Iterator visible prototypes-----------*/
 
-PyMODINIT_FUNC Iterator_Init( PyObject *module );
+int Iterator_Init( PyObject *module );
 
 
 ///////////////////////////////////////////////////////////////////////////////////////////
index b889d2b5c2f7596a38af06da8e67ead128ae94dd..1d4838b14ada213415725927d3e0abad973385a9 100644 (file)
@@ -8,118 +8,76 @@ extern "C" {
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
-/*---------------  Python API function prototypes for MediumType instance  -----------*/
-static int MediumType___init__(BPy_MediumType *self, PyObject *args, PyObject *kwds);
-
-/*----------------------MediumType instance definitions ----------------------------*/
-static PyMethodDef BPy_MediumType_methods[] = {
-       {NULL, NULL, 0, NULL}
-};
-
 /*-----------------------BPy_MediumType type definition ------------------------------*/
 
 PyTypeObject MediumType_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "MediumType",                           /* tp_name */
-       sizeof( BPy_MediumType ),       /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       NULL,   /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       NULL,                                   /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
+       PyObject_HEAD_INIT(NULL)
+       "MediumType",                   /* tp_name */
+       sizeof(PyLongObject),           /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       0,                              /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       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 */
+       "MediumType objects",           /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       0,                              /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       &PyLong_Type,                   /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       0,                              /* tp_init */
+       0,                              /* tp_alloc */
+       0,                              /* tp_new */
+};
 
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
+/*-----------------------BPy_IntegrationType instance definitions -------------------------*/
 
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_MediumType_methods, /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       &PyInt_Type,                                                    /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)MediumType___init__,                          /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,                      /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+PyLongObject _BPy_MediumType_DRY_MEDIUM = {
+       PyVarObject_HEAD_INIT(&MediumType_Type, 1)
+       { Stroke::DRY_MEDIUM }
+};
+PyLongObject _BPy_MediumType_HUMID_MEDIUM = {
+       PyVarObject_HEAD_INIT(&MediumType_Type, 1)
+       { Stroke::HUMID_MEDIUM }
+};
+PyLongObject _BPy_MediumType_OPAQUE_MEDIUM = {
+       PyVarObject_HEAD_INIT(&MediumType_Type, 1)
+       { Stroke::OPAQUE_MEDIUM }
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
 
-PyMODINIT_FUNC MediumType_Init( PyObject *module )
+int MediumType_Init( PyObject *module )
 {      
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &MediumType_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &MediumType_Type );
        PyModule_AddObject(module, "MediumType", (PyObject *)&MediumType_Type);
 
-}
-
-int MediumType___init__(BPy_MediumType *self, PyObject *args, PyObject *kwds)
-{
-    if (PyInt_Type.tp_init((PyObject *)self, args, kwds) < 0)
-        return -1;
-       
        return 0;
 }
 
index 9b4ff5a2fd97c28e2a8e4e62e202335fe00f83b6..94bc7aa954cef528101defaa40e205a3ecab4d5f 100644 (file)
@@ -17,12 +17,21 @@ extern PyTypeObject MediumType_Type;
 
 /*---------------------------Python BPy_MediumType structure definition----------*/
 typedef struct {
-       PyIntObject i;
+       PyLongObject i;
 } BPy_MediumType;
 
 /*---------------------------Python BPy_MediumType visible prototypes-----------*/
 
-PyMODINIT_FUNC MediumType_Init( PyObject *module );
+int MediumType_Init( PyObject *module );
+
+// internal constants
+extern PyLongObject _BPy_MediumType_DRY_MEDIUM;
+extern PyLongObject _BPy_MediumType_HUMID_MEDIUM;
+extern PyLongObject _BPy_MediumType_OPAQUE_MEDIUM;
+// public constants
+#define BPy_MediumType_DRY_MEDIUM     ((PyObject *)&_BPy_MediumType_DRY_MEDIUM)
+#define BPy_MediumType_HUMID_MEDIUM   ((PyObject *)&_BPy_MediumType_HUMID_MEDIUM)
+#define BPy_MediumType_OPAQUE_MEDIUM  ((PyObject *)&_BPy_MediumType_OPAQUE_MEDIUM)
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
index 25d80816c8e72df37b4bfa8cde1ecd0c8342fc3b..0e6a80e0febdd3543bf78a65f5543aa3f8dbbf7c 100644 (file)
@@ -8,127 +8,235 @@ extern "C" {
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
-/*----------------------Nature instance definitions ----------------------------*/
-static PyMethodDef BPy_Nature_methods[] = {
-       {NULL, NULL, 0, NULL}
+static PyObject *BPy_Nature___and__(PyObject *a, PyObject *b);
+static PyObject *BPy_Nature___xor__(PyObject *a, PyObject *b);
+static PyObject *BPy_Nature___or__(PyObject *a, PyObject *b);
+
+/*-----------------------BPy_Nature number method definitions --------------------*/
+
+PyNumberMethods nature_as_number = {
+       0,                              /* binaryfunc nb_add */
+       0,                              /* binaryfunc nb_subtract */
+       0,                              /* binaryfunc nb_multiply */
+       0,                              /* binaryfunc nb_remainder */
+       0,                              /* binaryfunc nb_divmod */
+       0,                              /* ternaryfunc nb_power */
+       0,                              /* unaryfunc nb_negative */
+       0,                              /* unaryfunc nb_positive */
+       0,                              /* unaryfunc nb_absolute */
+       0,                              /* inquiry nb_bool */
+       0,                              /* unaryfunc nb_invert */
+       0,                              /* binaryfunc nb_lshift */
+       0,                              /* binaryfunc nb_rshift */
+       (binaryfunc)BPy_Nature___and__, /* binaryfunc nb_and */
+       (binaryfunc)BPy_Nature___xor__, /* binaryfunc nb_xor */
+       (binaryfunc)BPy_Nature___or__,  /* binaryfunc nb_or */
+       0,                              /* unaryfunc nb_int */
+       0,                              /* void *nb_reserved */
+       0,                              /* unaryfunc nb_float */
+       0,                              /* binaryfunc nb_inplace_add */
+       0,                              /* binaryfunc nb_inplace_subtract */
+       0,                              /* binaryfunc nb_inplace_multiply */
+       0,                              /* binaryfunc nb_inplace_remainder */
+       0,                              /* ternaryfunc nb_inplace_power */
+       0,                              /* binaryfunc nb_inplace_lshift */
+       0,                              /* binaryfunc nb_inplace_rshift */
+       0,                              /* binaryfunc nb_inplace_and */
+       0,                              /* binaryfunc nb_inplace_xor */
+       0,                              /* binaryfunc nb_inplace_or */
+       0,                              /* binaryfunc nb_floor_divide */
+       0,                              /* binaryfunc nb_true_divide */
+       0,                              /* binaryfunc nb_inplace_floor_divide */
+       0,                              /* binaryfunc nb_inplace_true_divide */
+       0,                              /* unaryfunc nb_index */
 };
 
 /*-----------------------BPy_Nature type definition ------------------------------*/
 
 PyTypeObject Nature_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "Nature",                               /* tp_name */
-       sizeof( BPy_Nature ),   /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       NULL,   /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       NULL,                                   /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_Nature_methods,     /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       NULL,                                                   /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       NULL,                                                   /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyObject_HEAD_INIT(NULL)
+       "Nature",                       /* tp_name */
+       sizeof(PyLongObject),           /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       0,                              /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       0,                              /* tp_repr */
+       &nature_as_number,              /* 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 */
+       "Nature objects",               /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       0,                              /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       &PyLong_Type,                   /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       0,                              /* tp_init */
+       0,                              /* tp_alloc */
+       0,                              /* tp_new */
+};
+
+/*-----------------------BPy_Nature instance definitions ----------------------------------*/
+
+static PyLongObject _Nature_POINT = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::POINT }
+};
+static PyLongObject _Nature_S_VERTEX = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::S_VERTEX }
+};
+static PyLongObject _Nature_VIEW_VERTEX = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::VIEW_VERTEX }
+};
+static PyLongObject _Nature_NON_T_VERTEX = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::NON_T_VERTEX }
+};
+static PyLongObject _Nature_T_VERTEX = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::T_VERTEX }
+};
+static PyLongObject _Nature_CUSP = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::CUSP }
+};
+static PyLongObject _Nature_NO_FEATURE = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::NO_FEATURE }
+};
+static PyLongObject _Nature_SILHOUETTE = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::SILHOUETTE }
+};
+static PyLongObject _Nature_BORDER = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::BORDER }
+};
+static PyLongObject _Nature_CREASE = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::CREASE }
+};
+static PyLongObject _Nature_RIDGE = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::RIDGE }
+};
+static PyLongObject _Nature_VALLEY = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::VALLEY }
+};
+static PyLongObject _Nature_SUGGESTIVE_CONTOUR = {
+       PyVarObject_HEAD_INIT(&Nature_Type, 1)
+       { Nature::SUGGESTIVE_CONTOUR }
 };
 
+#define BPy_Nature_POINT               ((PyObject *)&_Nature_POINT)
+#define BPy_Nature_S_VERTEX            ((PyObject *)&_Nature_S_VERTEX)
+#define BPy_Nature_VIEW_VERTEX         ((PyObject *)&_Nature_VIEW_VERTEX)
+#define BPy_Nature_NON_T_VERTEX        ((PyObject *)&_Nature_NON_T_VERTEX)
+#define BPy_Nature_T_VERTEX            ((PyObject *)&_Nature_T_VERTEX)
+#define BPy_Nature_CUSP                ((PyObject *)&_Nature_CUSP)
+#define BPy_Nature_NO_FEATURE          ((PyObject *)&_Nature_NO_FEATURE)
+#define BPy_Nature_SILHOUETTE          ((PyObject *)&_Nature_SILHOUETTE)
+#define BPy_Nature_BORDER              ((PyObject *)&_Nature_BORDER)
+#define BPy_Nature_CREASE              ((PyObject *)&_Nature_CREASE)
+#define BPy_Nature_RIDGE               ((PyObject *)&_Nature_RIDGE)
+#define BPy_Nature_VALLEY              ((PyObject *)&_Nature_VALLEY)
+#define BPy_Nature_SUGGESTIVE_CONTOUR  ((PyObject *)&_Nature_SUGGESTIVE_CONTOUR)
+
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC Nature_Init( PyObject *module )
+int Nature_Init( PyObject *module )
 {      
-       PyObject *tmp;
-       
        if( module == NULL )
-               return;
+               return -1;
 
-       Nature_Type.tp_base = &PyInt_Type;
        if( PyType_Ready( &Nature_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &Nature_Type );
        PyModule_AddObject(module, "Nature", (PyObject *)&Nature_Type);
 
        // VertexNature
-       tmp = PyInt_FromLong( Nature::POINT ); PyDict_SetItemString( Nature_Type.tp_dict, "POINT", tmp); Py_DECREF(tmp);
-       tmp = PyInt_FromLong( Nature::S_VERTEX ); PyDict_SetItemString( Nature_Type.tp_dict, "S_VERTEX", tmp); Py_DECREF(tmp);
-       tmp = PyInt_FromLong( Nature::VIEW_VERTEX ); PyDict_SetItemString( Nature_Type.tp_dict, "VIEW_VERTEX", tmp); Py_DECREF(tmp);
-       tmp = PyInt_FromLong( Nature::NON_T_VERTEX ); PyDict_SetItemString( Nature_Type.tp_dict, "NON_T_VERTEX", tmp); Py_DECREF(tmp);
-       tmp = PyInt_FromLong( Nature::T_VERTEX ); PyDict_SetItemString( Nature_Type.tp_dict, "T_VERTEX", tmp); Py_DECREF(tmp);
-       tmp = PyInt_FromLong( Nature::CUSP ); PyDict_SetItemString( Nature_Type.tp_dict, "CUSP", tmp); Py_DECREF(tmp);
+       PyDict_SetItemString( Nature_Type.tp_dict, "POINT", BPy_Nature_POINT);
+       PyDict_SetItemString( Nature_Type.tp_dict, "S_VERTEX", BPy_Nature_S_VERTEX);
+       PyDict_SetItemString( Nature_Type.tp_dict, "VIEW_VERTEX", BPy_Nature_VIEW_VERTEX );
+       PyDict_SetItemString( Nature_Type.tp_dict, "NON_T_VERTEX", BPy_Nature_NON_T_VERTEX );
+       PyDict_SetItemString( Nature_Type.tp_dict, "T_VERTEX", BPy_Nature_T_VERTEX );
+       PyDict_SetItemString( Nature_Type.tp_dict, "CUSP", BPy_Nature_CUSP );
        
        // EdgeNature
-       tmp = BPy_Nature_from_Nature( Nature::NO_FEATURE ); PyDict_SetItemString( Nature_Type.tp_dict, "NO_FEATURE", tmp); Py_DECREF(tmp);
-       tmp = BPy_Nature_from_Nature( Nature::SILHOUETTE ); PyDict_SetItemString( Nature_Type.tp_dict, "SILHOUETTE", tmp); Py_DECREF(tmp);
-       tmp = BPy_Nature_from_Nature( Nature::BORDER ); PyDict_SetItemString( Nature_Type.tp_dict, "BORDER", tmp); Py_DECREF(tmp);
-       tmp = BPy_Nature_from_Nature( Nature::CREASE ); PyDict_SetItemString( Nature_Type.tp_dict, "CREASE", tmp); Py_DECREF(tmp);
-       tmp = BPy_Nature_from_Nature( Nature::RIDGE ); PyDict_SetItemString( Nature_Type.tp_dict, "RIDGE", tmp); Py_DECREF(tmp);
-       tmp = BPy_Nature_from_Nature( Nature::VALLEY ); PyDict_SetItemString( Nature_Type.tp_dict, "VALLEY", tmp); Py_DECREF(tmp);
-       tmp = BPy_Nature_from_Nature( Nature::SUGGESTIVE_CONTOUR ); PyDict_SetItemString( Nature_Type.tp_dict, "SUGGESTIVE_CONTOUR", tmp); Py_DECREF(tmp);
-       
+       PyDict_SetItemString( Nature_Type.tp_dict, "NO_FEATURE", BPy_Nature_NO_FEATURE );
+       PyDict_SetItemString( Nature_Type.tp_dict, "SILHOUETTE", BPy_Nature_SILHOUETTE );
+       PyDict_SetItemString( Nature_Type.tp_dict, "BORDER", BPy_Nature_BORDER );
+       PyDict_SetItemString( Nature_Type.tp_dict, "CREASE", BPy_Nature_CREASE );
+       PyDict_SetItemString( Nature_Type.tp_dict, "RIDGE", BPy_Nature_RIDGE );
+       PyDict_SetItemString( Nature_Type.tp_dict, "VALLEY", BPy_Nature_VALLEY );
+       PyDict_SetItemString( Nature_Type.tp_dict, "SUGGESTIVE_CONTOUR", BPy_Nature_SUGGESTIVE_CONTOUR );
+
+       return 0;
+}
+
+static PyObject *
+BPy_Nature_bitwise(PyObject *a, int op, PyObject *b)
+{
+       BPy_Nature *result;
+
+       if (!BPy_Nature_Check(a) || !BPy_Nature_Check(b)) {
+               PyErr_SetString(PyExc_TypeError, "operands must be a Nature object");
+               return NULL;
+       }
+       result = PyObject_NewVar(BPy_Nature, &Nature_Type, 1);
+       if (!result)
+               return NULL;
+       assert(Py_SIZE(a) == 1 && Py_SIZE(b) == 1 && Py_SIZE(result) == 1);
+       switch (op) {
+       case '&':
+               result->i.ob_digit[0] = (((PyLongObject *)a)->ob_digit[0]) & (((PyLongObject *)b)->ob_digit)[0];
+               break;
+       case '^':
+               result->i.ob_digit[0] = (((PyLongObject *)a)->ob_digit[0]) ^ (((PyLongObject *)b)->ob_digit)[0];
+               break;
+       case '|':
+               result->i.ob_digit[0] = (((PyLongObject *)a)->ob_digit[0]) | (((PyLongObject *)b)->ob_digit)[0];
+               break;
+       }
+       return (PyObject *)result;
+}
+
+static PyObject *
+BPy_Nature___and__(PyObject *a, PyObject *b)
+{
+       return BPy_Nature_bitwise(a, '&', b);
+}
+
+static PyObject *
+BPy_Nature___xor__(PyObject *a, PyObject *b)
+{
+       return BPy_Nature_bitwise(a, '^', b);
+}
+
+static PyObject *
+BPy_Nature___or__(PyObject *a, PyObject *b)
+{
+       return BPy_Nature_bitwise(a, '|', b);
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
index 493a4f785999b9eafa79a240ad7422882ed92059..d5e1c9c63d4f2aee3635a01e77ac333f28156226 100644 (file)
@@ -17,12 +17,12 @@ extern PyTypeObject Nature_Type;
 
 /*---------------------------Python BPy_Nature structure definition----------*/
 typedef struct {
-       PyIntObject i;
+       PyLongObject i;
 } BPy_Nature;
 
 /*---------------------------Python BPy_Nature visible prototypes-----------*/
 
-PyMODINIT_FUNC Nature_Init( PyObject *module );
+int Nature_Init( PyObject *module );
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
index 49bddcbf7c7eb9597c9300b424b9a33dd900eb11..557143f22c2caacae5bbcf1e222dbc424c7d54ce 100644 (file)
@@ -54,106 +54,65 @@ static PyMethodDef BPy_Operators_methods[] = {
 /*-----------------------BPy_Operators type definition ------------------------------*/
 
 PyTypeObject Operators_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "Operators",                            /* tp_name */
-       sizeof( BPy_Operators ),        /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)Operators___dealloc__,      /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       NULL,                                   /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Operatorss */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_Operators_methods,  /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       NULL,                           /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "Operators",                    /* tp_name */
+       sizeof(BPy_Operators),          /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)Operators___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       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 */
+       "Operators objects",            /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_Operators_methods,          /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       0,                              /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC Operators_Init( PyObject *module )
+int Operators_Init( PyObject *module )
 {      
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &Operators_Type ) < 0 )
-               return;
+               return -1;
+
        Py_INCREF( &Operators_Type );
        PyModule_AddObject(module, "Operators", (PyObject *)&Operators_Type);   
-       
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
 
 void Operators___dealloc__(BPy_Operators* self)
 {
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 PyObject * Operators_select(BPy_Operators* self, PyObject *args)
@@ -414,15 +373,15 @@ PyObject * Operators_create(BPy_Operators* self, PyObject *args)
 }
 
 PyObject * Operators_getViewEdgesSize( BPy_Operators* self) {
-       return PyInt_FromLong( Operators::getViewEdgesSize() );
+       return PyLong_FromLong( Operators::getViewEdgesSize() );
 }
 
 PyObject * Operators_getChainsSize( BPy_Operators* self ) {
-       return PyInt_FromLong( Operators::getChainsSize() );
+       return PyLong_FromLong( Operators::getChainsSize() );
 }
 
 PyObject * Operators_getStrokesSize( BPy_Operators* self) {
-       return PyInt_FromLong( Operators::getStrokesSize() );
+       return PyLong_FromLong( Operators::getStrokesSize() );
 }
 
 
index 0af40551cf85373a4e47572549543ad4c73ac98f..c6b088415c426abdd39e90fa7b5dd1a2b0a6e85f 100644 (file)
@@ -22,7 +22,7 @@ typedef struct {
 
 /*---------------------------Python BPy_Operators visible prototypes-----------*/
 
-PyMODINIT_FUNC Operators_Init( PyObject *module );
+int Operators_Init( PyObject *module );
 
 
 ///////////////////////////////////////////////////////////////////////////////////////////
index 01971acbc754775a194a369a58816324974be355..6538818d025e84f9fef16637c0970a5d93929008 100644 (file)
@@ -29,15 +29,15 @@ static PyObject * SShape_setId( BPy_SShape *self , PyObject *args);
 
 /*----------------------SShape instance definitions ----------------------------*/
 static PyMethodDef BPy_SShape_methods[] = {
-       {"AddEdge", ( PyCFunction ) SShape_AddEdge, METH_VARARGS, "(FEdge fe )Adds a FEdge to the list of FEdges. "},
-       {"AddNewVertex", ( PyCFunction ) SShape_AddNewVertex, METH_VARARGS, "(SVertex sv )Adds a SVertex to the list of SVertex of this Shape. The SShape attribute of the SVertex is also set to 'this'."},
-       {"setBBox", ( PyCFunction ) SShape_setBBox, METH_VARARGS, "(BBox bb )Sets the Bounding Box of the Shape"},
-       {"ComputeBBox", ( PyCFunction ) SShape_ComputeBBox, METH_NOARGS, "( )Compute the bbox of the SShape"},
-       {"bbox", ( PyCFunction ) SShape_bbox, METH_NOARGS, "( )Returns the bounding box of the shape."},
-       {"getVertexList", ( PyCFunction ) SShape_getVertexList, METH_NOARGS, "( )Returns the list of SVertex of the Shape"},
-       {"getEdgeList", ( PyCFunction ) SShape_getEdgeList, METH_NOARGS, "( )Returns the list of FEdges of the Shape."},
-       {"getId", ( PyCFunction ) SShape_getId, METH_NOARGS, "( )Returns the Id of the Shape. "},
-       {"setId", ( PyCFunction ) SShape_setId, METH_VARARGS, "(Id id )Sets the Id of the shape. "},
+       {"AddEdge", ( PyCFunction ) SShape_AddEdge, METH_VARARGS, "(FEdge fe) Adds a FEdge to the list of FEdges. "},
+       {"AddNewVertex", ( PyCFunction ) SShape_AddNewVertex, METH_VARARGS, "(SVertex sv) Adds a SVertex to the list of SVertex of this Shape. The SShape attribute of the SVertex is also set to 'this'."},
+       {"setBBox", ( PyCFunction ) SShape_setBBox, METH_VARARGS, "(BBox bb) Sets the Bounding Box of the Shape"},
+       {"ComputeBBox", ( PyCFunction ) SShape_ComputeBBox, METH_NOARGS, "() Compute the bbox of the SShape"},
+       {"bbox", ( PyCFunction ) SShape_bbox, METH_NOARGS, "() Returns the bounding box of the shape."},
+       {"getVertexList", ( PyCFunction ) SShape_getVertexList, METH_NOARGS, "() Returns the list of SVertex of the Shape"},
+       {"getEdgeList", ( PyCFunction ) SShape_getEdgeList, METH_NOARGS, "() Returns the list of FEdges of the Shape."},
+       {"getId", ( PyCFunction ) SShape_getId, METH_NOARGS, "() Returns the Id of the Shape. "},
+       {"setId", ( PyCFunction ) SShape_setId, METH_VARARGS, "(Id id) Sets the Id of the shape. "},
        
        {NULL, NULL, 0, NULL}
 };
@@ -45,99 +45,58 @@ static PyMethodDef BPy_SShape_methods[] = {
 /*-----------------------BPy_SShape type definition ------------------------------*/
 
 PyTypeObject SShape_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "SShape",                                               /* tp_name */
-       sizeof( BPy_SShape ),                   /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)SShape___dealloc__, /* tp_dealloc */
-       NULL,                       /* printfunc tp_print; */
-       NULL,                       /* getattrfunc tp_getattr; */
-       NULL,                       /* setattrfunc tp_setattr; */
-       NULL,                                           /* tp_compare */
-       (reprfunc)SShape___repr__,                              /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                   /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_SShape_methods,     /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)SShape___init__,           /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,                                              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "SShape",                       /* tp_name */
+       sizeof(BPy_SShape),             /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)SShape___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)SShape___repr__,      /* 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 | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "SShape objects",               /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_SShape_methods,             /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       (initproc)SShape___init__,      /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC SShape_Init( PyObject *module )
+int SShape_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &SShape_Type ) < 0 )
-               return;
+               return -1;
 
        Py_INCREF( &SShape_Type );
        PyModule_AddObject(module, "SShape", (PyObject *)&SShape_Type);
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
@@ -164,12 +123,12 @@ void SShape___dealloc__(BPy_SShape *self)
 {
        if( self->ss && !self->borrowed )
                delete self->ss;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 PyObject * SShape___repr__(BPy_SShape *self)
 {
-    return PyString_FromFormat("SShape - address: %p", self->ss );
+    return PyUnicode_FromFormat("SShape - address: %p", self->ss );
 }
 
 PyObject * SShape_AddEdge( BPy_SShape *self , PyObject *args) {
index 61e2257b2a52991c7e2deaff25f26dc18e2498da..3bcb6a60603921c0f9c61012b884c8754ed01a93 100644 (file)
@@ -24,7 +24,7 @@ typedef struct {
 
 /*---------------------------Python BPy_SShape visible prototypes-----------*/
 
-PyMODINIT_FUNC SShape_Init( PyObject *module );
+int SShape_Init( PyObject *module );
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
index 2c9512792fac9e7e5ba289ec812c768c169039ac..30fb7a5c2e38bb97a9a0d3daede9118441b262fd 100644 (file)
@@ -69,99 +69,57 @@ static PyMethodDef BPy_StrokeAttribute_methods[] = {
 /*-----------------------BPy_StrokeAttribute type definition ------------------------------*/
 
 PyTypeObject StrokeAttribute_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "StrokeAttribute",                              /* tp_name */
-       sizeof( BPy_StrokeAttribute ),  /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)StrokeAttribute___dealloc__,        /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       (reprfunc)StrokeAttribute___repr__,                                     /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_StrokeAttribute_methods,    /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                                   /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)StrokeAttribute___init__,                             /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "StrokeAttribute",              /* tp_name */
+       sizeof(BPy_StrokeAttribute),    /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)StrokeAttribute___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)StrokeAttribute___repr__, /* 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 | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "StrokeAttribute objects",      /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_StrokeAttribute_methods,    /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       (initproc)StrokeAttribute___init__, /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC StrokeAttribute_Init( PyObject *module )
+int StrokeAttribute_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &StrokeAttribute_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &StrokeAttribute_Type );
        PyModule_AddObject(module, "StrokeAttribute", (PyObject *)&StrokeAttribute_Type);
-       
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
@@ -210,7 +168,7 @@ void StrokeAttribute___dealloc__(BPy_StrokeAttribute* self)
 {
        if( self->sa && !self->borrowed )
                delete self->sa;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 PyObject * StrokeAttribute___repr__(BPy_StrokeAttribute* self)
@@ -223,7 +181,7 @@ PyObject * StrokeAttribute___repr__(BPy_StrokeAttribute* self)
                 << " - R: " << self->sa->getThicknessR() 
                 << " L: " << self->sa->getThicknessL();
 
-       return PyString_FromFormat( repr.str().c_str() );
+       return PyUnicode_FromFormat( repr.str().c_str() );
 }
 
 
index ad4ae095b725bb27c290c815ad70af8c135beb3d..a2193c681aaa7260593f7a5d4b1cddd9599fdcb5 100644 (file)
@@ -24,7 +24,7 @@ typedef struct {
 
 /*---------------------------Python BPy_StrokeAttribute visible prototypes-----------*/
 
-PyMODINIT_FUNC StrokeAttribute_Init( PyObject *module );
+int StrokeAttribute_Init( PyObject *module );
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
index 1a99d7e395ce0afb7207828e79bc0715972a61b7..637d917fb6d8aa2ed54b50a64e4bbac2d63798db 100644 (file)
@@ -42,217 +42,176 @@ static PyObject * StrokeShader_shade( BPy_StrokeShader *self , PyObject *args);
 
 /*----------------------StrokeShader instance definitions ----------------------------*/
 static PyMethodDef BPy_StrokeShader_methods[] = {
-       {"getName", ( PyCFunction ) StrokeShader_getName, METH_NOARGS, "( )Returns the string of the name of the binary predicate."},
-       {"shade", ( PyCFunction ) StrokeShader_shade, METH_VARARGS, "(Stroke s )The shading method. This method must be overloaded by inherited classes. The shading method is designed to modify any Stroke's attribute such as Thickness, Color, Geometry, Texture, Blending mode... The basic way to achieve this operation consists in iterating over the StrokeVertices of the Stroke and to modify each one's StrokeAttribute."},
+       {"getName", ( PyCFunction ) StrokeShader_getName, METH_NOARGS, "() Returns the string of the name of the binary predicate."},
+       {"shade", ( PyCFunction ) StrokeShader_shade, METH_VARARGS, "(Stroke s) The shading method. This method must be overloaded by inherited classes. The shading method is designed to modify any Stroke's attribute such as Thickness, Color, Geometry, Texture, Blending mode... The basic way to achieve this operation consists in iterating over the StrokeVertices of the Stroke and to modify each one's StrokeAttribute."},
        {NULL, NULL, 0, NULL}
 };
 
 /*-----------------------BPy_StrokeShader type definition ------------------------------*/
 
 PyTypeObject StrokeShader_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "StrokeShader",                         /* tp_name */
-       sizeof( BPy_StrokeShader ),     /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)StrokeShader___dealloc__,   /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       (reprfunc)StrokeShader___repr__,                                        /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_StrokeShader_methods,       /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)StrokeShader___init__, /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "StrokeShader",                 /* tp_name */
+       sizeof(BPy_StrokeShader),       /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)StrokeShader___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)StrokeShader___repr__, /* 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 | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "StrokeShader objects",         /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_StrokeShader_methods,       /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       (initproc)StrokeShader___init__, /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC StrokeShader_Init( PyObject *module )
+int StrokeShader_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &StrokeShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &StrokeShader_Type );
        PyModule_AddObject(module, "StrokeShader", (PyObject *)&StrokeShader_Type);
 
        if( PyType_Ready( &BackboneStretcherShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &BackboneStretcherShader_Type );
        PyModule_AddObject(module, "BackboneStretcherShader", (PyObject *)&BackboneStretcherShader_Type);
 
        if( PyType_Ready( &BezierCurveShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &BezierCurveShader_Type );
        PyModule_AddObject(module, "BezierCurveShader", (PyObject *)&BezierCurveShader_Type);
 
        if( PyType_Ready( &CalligraphicShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &CalligraphicShader_Type );
        PyModule_AddObject(module, "CalligraphicShader", (PyObject *)&CalligraphicShader_Type);
 
        if( PyType_Ready( &ColorNoiseShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ColorNoiseShader_Type );
        PyModule_AddObject(module, "ColorNoiseShader", (PyObject *)&ColorNoiseShader_Type);
 
        if( PyType_Ready( &ColorVariationPatternShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ColorVariationPatternShader_Type );
        PyModule_AddObject(module, "ColorVariationPatternShader", (PyObject *)&ColorVariationPatternShader_Type);
 
        if( PyType_Ready( &ConstantColorShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ConstantColorShader_Type );
        PyModule_AddObject(module, "ConstantColorShader", (PyObject *)&ConstantColorShader_Type);
 
        if( PyType_Ready( &ConstantThicknessShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ConstantThicknessShader_Type );
        PyModule_AddObject(module, "ConstantThicknessShader", (PyObject *)&ConstantThicknessShader_Type);
 
        if( PyType_Ready( &ConstrainedIncreasingThicknessShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ConstrainedIncreasingThicknessShader_Type );
        PyModule_AddObject(module, "ConstrainedIncreasingThicknessShader", (PyObject *)&ConstrainedIncreasingThicknessShader_Type);
 
        if( PyType_Ready( &fstreamShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &fstreamShader_Type );
        PyModule_AddObject(module, "fstreamShader", (PyObject *)&fstreamShader_Type);
 
        if( PyType_Ready( &GuidingLinesShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &GuidingLinesShader_Type );
        PyModule_AddObject(module, "GuidingLinesShader", (PyObject *)&GuidingLinesShader_Type);
 
        if( PyType_Ready( &IncreasingColorShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &IncreasingColorShader_Type );
        PyModule_AddObject(module, "IncreasingColorShader", (PyObject *)&IncreasingColorShader_Type);
 
        if( PyType_Ready( &IncreasingThicknessShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &IncreasingThicknessShader_Type );
        PyModule_AddObject(module, "IncreasingThicknessShader", (PyObject *)&IncreasingThicknessShader_Type);
 
        if( PyType_Ready( &PolygonalizationShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &PolygonalizationShader_Type );
        PyModule_AddObject(module, "PolygonalizationShader", (PyObject *)&PolygonalizationShader_Type);
 
        if( PyType_Ready( &SamplingShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &SamplingShader_Type );
        PyModule_AddObject(module, "SamplingShader", (PyObject *)&SamplingShader_Type);
 
        if( PyType_Ready( &SmoothingShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &SmoothingShader_Type );
        PyModule_AddObject(module, "SmoothingShader", (PyObject *)&SmoothingShader_Type);
 
        if( PyType_Ready( &SpatialNoiseShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &SpatialNoiseShader_Type );
        PyModule_AddObject(module, "SpatialNoiseShader", (PyObject *)&SpatialNoiseShader_Type);
 
        if( PyType_Ready( &streamShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &streamShader_Type );
        PyModule_AddObject(module, "streamShader", (PyObject *)&streamShader_Type);
 
        if( PyType_Ready( &StrokeTextureShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &StrokeTextureShader_Type );
        PyModule_AddObject(module, "StrokeTextureShader", (PyObject *)&StrokeTextureShader_Type);
 
        if( PyType_Ready( &TextureAssignerShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &TextureAssignerShader_Type );
        PyModule_AddObject(module, "TextureAssignerShader", (PyObject *)&TextureAssignerShader_Type);
 
        if( PyType_Ready( &ThicknessNoiseShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ThicknessNoiseShader_Type );
        PyModule_AddObject(module, "ThicknessNoiseShader", (PyObject *)&ThicknessNoiseShader_Type);
 
        if( PyType_Ready( &ThicknessVariationPatternShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &ThicknessVariationPatternShader_Type );
        PyModule_AddObject(module, "ThicknessVariationPatternShader", (PyObject *)&ThicknessVariationPatternShader_Type);
 
        if( PyType_Ready( &TipRemoverShader_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &TipRemoverShader_Type );
        PyModule_AddObject(module, "TipRemoverShader", (PyObject *)&TipRemoverShader_Type);
-       
+
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
@@ -270,19 +229,19 @@ void StrokeShader___dealloc__(BPy_StrokeShader* self)
 {
        if (self->ss)
                delete self->ss;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 
 PyObject * StrokeShader___repr__(BPy_StrokeShader* self)
 {
-    return PyString_FromFormat("type: %s - address: %p", self->ss->getName().c_str(), self->ss );
+    return PyUnicode_FromFormat("type: %s - address: %p", self->ss->getName().c_str(), self->ss );
 }
 
 
 PyObject * StrokeShader_getName( BPy_StrokeShader *self, PyObject *args)
 {
-       return PyString_FromString( self->ss->getName().c_str() );
+       return PyUnicode_FromFormat( self->ss->getName().c_str() );
 }
 
 PyObject *StrokeShader_shade( BPy_StrokeShader *self , PyObject *args) {
index 5ee89a3587536ffceef1bea4816d14cfe7841644..e1d72cef5469c5ce9fe2d1aa6ff131e696ed4cd8 100644 (file)
@@ -28,7 +28,7 @@ typedef struct {
 
 /*---------------------------Python BPy_StrokeShader visible prototypes-----------*/
 
-PyMODINIT_FUNC StrokeShader_Init( PyObject *module );
+int StrokeShader_Init( PyObject *module );
 
 
 ///////////////////////////////////////////////////////////////////////////////////////////
index 122c6cc678c912153f01b0e9589700e201c38f6d..8558daf069394338aba7ef38b4ed1c02b2883531 100644 (file)
@@ -19,107 +19,61 @@ extern "C" {
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 /*---------------  Python API function prototypes for UnaryFunction0D instance  -----------*/
+
 static void UnaryFunction0D___dealloc__(BPy_UnaryFunction0D *self);
 static PyObject * UnaryFunction0D___repr__(BPy_UnaryFunction0D *self);
 
-/*----------------------UnaryFunction0D instance definitions ----------------------------*/
-static PyMethodDef BPy_UnaryFunction0D_methods[] = {
-       {NULL, NULL, 0, NULL}
-};
-
 /*-----------------------BPy_UnaryFunction0D type definition ------------------------------*/
 
 PyTypeObject UnaryFunction0D_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "UnaryFunction0D",                              /* tp_name */
-       sizeof( BPy_UnaryFunction0D ),  /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)UnaryFunction0D___dealloc__,        /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       (reprfunc)UnaryFunction0D___repr__,                                     /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_UnaryFunction0D_methods,    /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       NULL, /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "UnaryFunction0D",              /* tp_name */
+       sizeof(BPy_UnaryFunction0D),    /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)UnaryFunction0D___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)UnaryFunction0D___repr__, /* 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 | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "UnaryFunction0D objects",      /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       0,                              /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       0,                              /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC UnaryFunction0D_Init( PyObject *module )
+int UnaryFunction0D_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &UnaryFunction0D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &UnaryFunction0D_Type );
        PyModule_AddObject(module, "UnaryFunction0D", (PyObject *)&UnaryFunction0D_Type);
 
@@ -133,19 +87,21 @@ PyMODINIT_FUNC UnaryFunction0D_Init( PyObject *module )
        UnaryFunction0DVec3f_Init( module );
        UnaryFunction0DVectorViewShape_Init( module );
        UnaryFunction0DViewShape_Init( module );
+       
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
 
 void UnaryFunction0D___dealloc__(BPy_UnaryFunction0D* self)
 {
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 
 PyObject * UnaryFunction0D___repr__(BPy_UnaryFunction0D* self)
 {
-    return PyString_FromString("UnaryFunction0D");
+    return PyUnicode_FromFormat("UnaryFunction0D");
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
index d95230ecccd4384ddac9d9afae264474cb8445e7..d9215e3275f0f0e96e2a8333a98b45e947c060d1 100644 (file)
@@ -23,7 +23,7 @@ typedef struct {
 
 /*---------------------------Python BPy_UnaryFunction0D visible prototypes-----------*/
 
-PyMODINIT_FUNC UnaryFunction0D_Init( PyObject *module );
+int UnaryFunction0D_Init( PyObject *module );
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
index 10db0d931404dd17fc516a5c40d81dfe9e03fc7e..c05ba35422f5965ff8bfbe4ea67a956b2193bd20 100644 (file)
@@ -16,107 +16,61 @@ extern "C" {
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 /*---------------  Python API function prototypes for UnaryFunction1D instance  -----------*/
+
 static void UnaryFunction1D___dealloc__(BPy_UnaryFunction1D *self);
 static PyObject * UnaryFunction1D___repr__(BPy_UnaryFunction1D *self);
 
-/*----------------------UnaryFunction1D instance definitions ----------------------------*/
-static PyMethodDef BPy_UnaryFunction1D_methods[] = {
-       {NULL, NULL, 0, NULL}
-};
-
 /*-----------------------BPy_UnaryFunction1D type definition ------------------------------*/
 
 PyTypeObject UnaryFunction1D_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "UnaryFunction1D",                              /* tp_name */
-       sizeof( BPy_UnaryFunction1D ),  /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)UnaryFunction1D___dealloc__,        /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       (reprfunc)UnaryFunction1D___repr__,                                     /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       NULL,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_UnaryFunction1D_methods,    /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       NULL, /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "UnaryFunction1D",              /* tp_name */
+       sizeof(BPy_UnaryFunction1D),    /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)UnaryFunction1D___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)UnaryFunction1D___repr__, /* 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 | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "UnaryFunction1D objects",      /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       0,                              /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       0,                              /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC UnaryFunction1D_Init( PyObject *module )
+int UnaryFunction1D_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &UnaryFunction1D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &UnaryFunction1D_Type );
        PyModule_AddObject(module, "UnaryFunction1D", (PyObject *)&UnaryFunction1D_Type);
 
@@ -128,19 +82,20 @@ PyMODINIT_FUNC UnaryFunction1D_Init( PyObject *module )
        UnaryFunction1DVec3f_Init( module );
        UnaryFunction1DVectorViewShape_Init( module );
        UnaryFunction1DVoid_Init( module );
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
 
 void UnaryFunction1D___dealloc__(BPy_UnaryFunction1D* self)
 {
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 
 PyObject * UnaryFunction1D___repr__(BPy_UnaryFunction1D* self)
 {
-    return PyString_FromString("UnaryFunction1D");
+    return PyUnicode_FromFormat("UnaryFunction1D");
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
index 571ef8a5d2579630c8796282120aa369ebe50206..b8d92ba649da3dc1c257d2410065c55b91c3bf6b 100644 (file)
@@ -23,7 +23,7 @@ typedef struct {
 
 /*---------------------------Python BPy_UnaryFunction1D visible prototypes-----------*/
 
-PyMODINIT_FUNC UnaryFunction1D_Init( PyObject *module );
+int UnaryFunction1D_Init( PyObject *module );
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
index c146760a415000f931988d426338b48ff559fedf..0a2a943b346b432acd87891f026ca01f08dad8c3 100644 (file)
@@ -15,9 +15,9 @@ extern "C" {
 static int UnaryPredicate0D___init__(BPy_UnaryPredicate0D *self, PyObject *args, PyObject *kwds);
 static void UnaryPredicate0D___dealloc__(BPy_UnaryPredicate0D *self);
 static PyObject * UnaryPredicate0D___repr__(BPy_UnaryPredicate0D *self);
+static PyObject * UnaryPredicate0D___call__( BPy_UnaryPredicate0D *self, PyObject *args, PyObject *kwds);
 
 static PyObject * UnaryPredicate0D_getName( BPy_UnaryPredicate0D *self );
-static PyObject * UnaryPredicate0D___call__( BPy_UnaryPredicate0D *self, PyObject *args, PyObject *kwds);
 
 /*----------------------UnaryPredicate0D instance definitions ----------------------------*/
 static PyMethodDef BPy_UnaryPredicate0D_methods[] = {
@@ -28,109 +28,68 @@ static PyMethodDef BPy_UnaryPredicate0D_methods[] = {
 /*-----------------------BPy_UnaryPredicate0D type definition ------------------------------*/
 
 PyTypeObject UnaryPredicate0D_Type = {
-       PyObject_HEAD_INIT( NULL ) 
-       0,                                                      /* ob_size */
-       "UnaryPredicate0D",                             /* tp_name */
-       sizeof( BPy_UnaryPredicate0D ), /* tp_basicsize */
-       0,                                                      /* tp_itemsize */
-       
-       /* methods */
-       (destructor)UnaryPredicate0D___dealloc__,       /* tp_dealloc */
-       NULL,                                                   /* printfunc tp_print; */
-       NULL,                                                   /* getattrfunc tp_getattr; */
-       NULL,                                                   /* setattrfunc tp_setattr; */
-       NULL,                                                                           /* tp_compare */
-       (reprfunc)UnaryPredicate0D___repr__,                                    /* tp_repr */
-
-       /* Method suites for standard classes */
-
-       NULL,                       /* PyNumberMethods *tp_as_number; */
-       NULL,                       /* PySequenceMethods *tp_as_sequence; */
-       NULL,                       /* PyMappingMethods *tp_as_mapping; */
-
-       /* More standard operations (here for binary compatibility) */
-
-       NULL,                                           /* hashfunc tp_hash; */
-       (ternaryfunc)UnaryPredicate0D___call__,                       /* ternaryfunc tp_call; */
-       NULL,                       /* reprfunc tp_str; */
-       NULL,                       /* getattrofunc tp_getattro; */
-       NULL,                       /* setattrofunc tp_setattro; */
-
-       /* Functions to access object as input/output buffer */
-       NULL,                       /* PyBufferProcs *tp_as_buffer; */
-
-  /*** Flags to define presence of optional/expanded features ***/
-       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* long tp_flags; */
-
-       NULL,                       /*  char *tp_doc;  Documentation string */
-  /*** Assigned meaning in release 2.0 ***/
-       /* call function for all accessible objects */
-       NULL,                       /* traverseproc tp_traverse; */
-
-       /* delete references to contained objects */
-       NULL,                       /* inquiry tp_clear; */
-
-  /***  Assigned meaning in release 2.1 ***/
-  /*** rich comparisons ***/
-       NULL,                       /* richcmpfunc tp_richcompare; */
-
-  /***  weak reference enabler ***/
-       0,                          /* long tp_weaklistoffset; */
-
-  /*** Added in release 2.2 ***/
-       /*   Iterators */
-       NULL,                       /* getiterfunc tp_iter; */
-       NULL,                       /* iternextfunc tp_iternext; */
-
-  /*** Attribute descriptor and subclassing stuff ***/
-       BPy_UnaryPredicate0D_methods,   /* struct PyMethodDef *tp_methods; */
-       NULL,                           /* struct PyMemberDef *tp_members; */
-       NULL,                                           /* struct PyGetSetDef *tp_getset; */
-       NULL,                                                   /* struct _typeobject *tp_base; */
-       NULL,                                                   /* PyObject *tp_dict; */
-       NULL,                                                   /* descrgetfunc tp_descr_get; */
-       NULL,                                                   /* descrsetfunc tp_descr_set; */
-       0,                              /* long tp_dictoffset; */
-       (initproc)UnaryPredicate0D___init__, /* initproc tp_init; */
-       NULL,                                                   /* allocfunc tp_alloc; */
-       PyType_GenericNew,              /* newfunc tp_new; */
-       
-       /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
-       
-       /* For PyObject_IS_GC */
-       NULL,                       /* inquiry tp_is_gc;  */
-       NULL,                       /* PyObject *tp_bases; */
-       
-       /* method resolution order */
-       NULL,                       /* PyObject *tp_mro;  */
-       NULL,                       /* PyObject *tp_cache; */
-       NULL,                       /* PyObject *tp_subclasses; */
-       NULL,                       /* PyObject *tp_weaklist; */
-       NULL
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "UnaryPredicate0D",             /* tp_name */
+       sizeof(BPy_UnaryPredicate0D),   /* tp_basicsize */
+       0,                              /* tp_itemsize */
+       (destructor)UnaryPredicate0D___dealloc__, /* tp_dealloc */
+       0,                              /* tp_print */
+       0,                              /* tp_getattr */
+       0,                              /* tp_setattr */
+       0,                              /* tp_reserved */
+       (reprfunc)UnaryPredicate0D___repr__, /* tp_repr */
+       0,                              /* tp_as_number */
+       0,                              /* tp_as_sequence */
+       0,                              /* tp_as_mapping */
+       0,                              /* tp_hash  */
+       (ternaryfunc)UnaryPredicate0D___call__, /* tp_call */
+       0,                              /* tp_str */
+       0,                              /* tp_getattro */
+       0,                              /* tp_setattro */
+       0,                              /* tp_as_buffer */
+       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+       "UnaryPredicate0D objects",      /* tp_doc */
+       0,                              /* tp_traverse */
+       0,                              /* tp_clear */
+       0,                              /* tp_richcompare */
+       0,                              /* tp_weaklistoffset */
+       0,                              /* tp_iter */
+       0,                              /* tp_iternext */
+       BPy_UnaryPredicate0D_methods,   /* tp_methods */
+       0,                              /* tp_members */
+       0,                              /* tp_getset */
+       0,                              /* tp_base */
+       0,                              /* tp_dict */
+       0,                              /* tp_descr_get */
+       0,                              /* tp_descr_set */
+       0,                              /* tp_dictoffset */
+       (initproc)UnaryPredicate0D___init__, /* tp_init */
+       0,                              /* tp_alloc */
+       PyType_GenericNew,              /* tp_new */
 };
 
 //-------------------MODULE INITIALIZATION--------------------------------
-PyMODINIT_FUNC UnaryPredicate0D_Init( PyObject *module )
+int UnaryPredicate0D_Init( PyObject *module )
 {
        if( module == NULL )
-               return;
+               return -1;
 
        if( PyType_Ready( &UnaryPredicate0D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &UnaryPredicate0D_Type );
        PyModule_AddObject(module, "UnaryPredicate0D", (PyObject *)&UnaryPredicate0D_Type);
        
        if( PyType_Ready( &FalseUP0D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &FalseUP0D_Type );
        PyModule_AddObject(module, "FalseUP0D", (PyObject *)&FalseUP0D_Type);
        
        if( PyType_Ready( &TrueUP0D_Type ) < 0 )
-               return;
+               return -1;
        Py_INCREF( &TrueUP0D_Type );
        PyModule_AddObject(module, "TrueUP0D", (PyObject *)&TrueUP0D_Type);
        
+       return 0;
 }
 
 //------------------------INSTANCE METHODS ----------------------------------
@@ -148,19 +107,19 @@ void UnaryPredicate0D___dealloc__(BPy_UnaryPredicate0D* self)
 {
        if (self->up0D)
                delete self->up0D;
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
 
 PyObject * UnaryPredicate0D___repr__(BPy_UnaryPredicate0D* self)
 {
-    return PyString_FromFormat("type: %s - address: %p", self->up0D->getName().c_str(), self->up0D );
+    return PyUnicode_FromFormat("type: %s - address: %p", self->up0D->getName().c_str(), self->up0D );
 }
 
 
 PyObject * UnaryPredicate0D_getName( BPy_UnaryPredicate0D *self )
 {
-       return PyString_FromString( self->up0D->getName().c_str() );
+       return PyUnicode_FromFormat( self->up0D->getName().c_str() );
 }
 
 PyObject * UnaryPredicate0D___call__( BPy_UnaryPredicate0D *self, PyObject *args, PyObject *kwds)
diff --git