[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15578] branches/soc-2008-mxcurioni: soc-2008-mxcurioni: Reimplemented the Freestyle Python API' s files to be correctly used as classes and not submodules.
Maxime Curioni
maxime.curioni at gmail.com
Tue Jul 15 03:07:33 CEST 2008
Revision: 15578
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15578
Author: mxcurioni
Date: 2008-07-15 03:07:19 +0200 (Tue, 15 Jul 2008)
Log Message:
-----------
soc-2008-mxcurioni: Reimplemented the Freestyle Python API's files to be correctly used as classes and not submodules. Added and integrated object lifecycle functions (__new__, __alloc__, __repr__) for the previous classes: BinaryPredicate0D, BinaryPredicate1D, Id, Interface0D, Interface1D. All of these classes were tested within Blender's Python interpreter with simple test cases and their getter/setters were corrected.
Interface0DIterator was modified to allow BPy_Interface1D to be instantiated: verticesBegin(), verticesEnd(), pointsBegin(float) and pointsEnd(float) are not pure virtual functions anymore. If they are called directly from BPy_Interface1D (instead of its subclasses), an error message is displayed.
Modified Paths:
--------------
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate0D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate0D.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate1D.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Convert.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Freestyle.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Id.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Id.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface0D.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/Interface1D.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/Interface1D.h
Property Changed:
----------------
branches/soc-2008-mxcurioni/extern/ffmpeg/
branches/soc-2008-mxcurioni/source/blender/freestyle/style_modules/
Property changes on: branches/soc-2008-mxcurioni/extern/ffmpeg
___________________________________________________________________
Name: svn:ignore
+ *.pc
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate0D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate0D.cpp 2008-07-14 23:49:17 UTC (rev 15577)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate0D.cpp 2008-07-15 01:07:19 UTC (rev 15578)
@@ -9,18 +9,22 @@
///////////////////////////////////////////////////////////////////////////////////////////
+/*--------------- Python API function prototypes for BinaryPredicate0D instance -----------*/
+static PyObject * BinaryPredicate0D___new__(PyTypeObject *type, PyObject *args, PyObject *kwds);
+static void BinaryPredicate0D___dealloc__(BPy_BinaryPredicate0D *self);
+static PyObject * BinaryPredicate0D___repr__(BPy_BinaryPredicate0D *self);
-/*-----------------------Python API function prototypes for the BinaryPredicate0D module--*/
-//static PyObject *Freestyle_testOutput( BPy_Freestyle * self );
-/*-----------------------BinaryPredicate0D module doc strings-----------------------------*/
-static char M_BinaryPredicate0D_doc[] = "The Blender.Freestyle.BinaryPredicate0D submodule";
-/*----------------------BinaryPredicate0D module method def----------------------------*/
-struct PyMethodDef M_BinaryPredicate0D_methods[] = {
-// {"testOutput", ( PyCFunction ) Freestyle_testOutput, METH_NOARGS, "() - Return Curve Data name"},
+static PyObject * BinaryPredicate0D_getName( BPy_BinaryPredicate0D *self, PyObject *args);
+static PyObject * BinaryPredicate0D___call__( BPy_BinaryPredicate0D *self, PyObject *args);
+
+/*----------------------BinaryPredicate0D instance definitions ----------------------------*/
+static PyMethodDef BPy_BinaryPredicate0D_methods[] = {
+ {"getName", ( PyCFunction ) BinaryPredicate0D_getName, METH_NOARGS, "( )Returns the string of the name of the binary predicate."},
+ {"__call__", ( PyCFunction ) BinaryPredicate0D___call__, METH_VARARGS, "BinaryPredicate0D(Interface0D, Interface0D ). Must be overloaded by inherited classes. It evaluates a relation between two Interface0D." },
{NULL, NULL, 0, NULL}
};
-/*-----------------------BPy_Freestyle method def------------------------------*/
+/*-----------------------BPy_BinaryPredicate0D type definition ------------------------------*/
PyTypeObject BinaryPredicate0D_Type = {
PyObject_HEAD_INIT( NULL )
@@ -30,12 +34,12 @@
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 */
+ (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 */
@@ -78,17 +82,17 @@
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; */
+ 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; */
+ NULL, /* initproc tp_init; */
+ NULL, /* allocfunc tp_alloc; */
+ (newfunc)BinaryPredicate0D___new__, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
@@ -106,35 +110,60 @@
};
//-------------------MODULE INITIALIZATION--------------------------------
-PyObject *BinaryPredicate0D_Init( void )
+PyMODINIT_FUNC BinaryPredicate0D_Init( PyObject *module )
{
- PyObject *submodule;
-
+ if( module == NULL )
+ return;
+
if( PyType_Ready( &BinaryPredicate0D_Type ) < 0 )
- return NULL;
-
- submodule = Py_InitModule3( "Blender.Freestyle.BinaryPredicate0D", M_BinaryPredicate0D_methods, M_BinaryPredicate0D_doc );
-
- return submodule;
+ return;
+
+ Py_INCREF( &BinaryPredicate0D_Type );
+ PyModule_AddObject(module, "BinaryPredicate0D", (PyObject *)&BinaryPredicate0D_Type);
}
//------------------------INSTANCE METHODS ----------------------------------
-PyObject *BinaryPredicate0D_getName( BPy_BinaryPredicate0D *self, PyObject *args)
+PyObject * BinaryPredicate0D___new__(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
+ BPy_BinaryPredicate0D *self;
+
+ self = (BPy_BinaryPredicate0D *)type->tp_alloc(type, 0);
+ if (self != NULL) {
+ self->bp0D = new BinaryPredicate0D();
+ }
+
+ return (PyObject *)self;
+}
+
+void BinaryPredicate0D___dealloc__(BPy_BinaryPredicate0D* self)
+{
+ delete self->bp0D;
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+PyObject * BinaryPredicate0D___repr__(BPy_BinaryPredicate0D* self)
+{
+ return PyString_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() );
}
-PyObject *BinaryPredicate0D___call__( BPy_BinaryPredicate0D *self, PyObject *args)
+PyObject * BinaryPredicate0D___call__( BPy_BinaryPredicate0D *self, PyObject *args)
{
- BPy_BinaryPredicate0D *obj1;
- BPy_Interface0D *obj2, *obj3;
+ BPy_Interface0D *obj1, *obj2;
bool b;
- if (!PyArg_ParseTuple(args,(char *)"OOO:BinaryPredicate0D___call__", &obj1, obj2, &obj3))
+ if( !PyArg_ParseTuple(args,(char *)"OO:BinaryPredicate0D___call__", &obj1, obj2) ) {
cout << "ERROR: BinaryPredicate0D___call__ " << endl;
+ return NULL;
+ }
- b = self->bp0D->operator()( *(obj2->if0D) , *(obj3->if0D) );
+ b = self->bp0D->operator()( *(obj1->if0D) , *(obj2->if0D) );
return PyBool_from_bool( b );
}
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate0D.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate0D.h 2008-07-14 23:49:17 UTC (rev 15577)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate0D.h 2008-07-15 01:07:19 UTC (rev 15578)
@@ -24,7 +24,7 @@
/*---------------------------Python BPy_BinaryPredicate0D visible prototypes-----------*/
-PyObject *BinaryPredicate0D_Init( void );
+PyMODINIT_FUNC BinaryPredicate0D_Init( PyObject *module );
///////////////////////////////////////////////////////////////////////////////////////////
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate1D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate1D.cpp 2008-07-14 23:49:17 UTC (rev 15577)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate1D.cpp 2008-07-15 01:07:19 UTC (rev 15578)
@@ -9,33 +9,36 @@
///////////////////////////////////////////////////////////////////////////////////////////
+/*--------------- Python API function prototypes for BinaryPredicate1D instance -----------*/
+static PyObject * BinaryPredicate1D___new__(PyTypeObject *type, PyObject *args, PyObject *kwds);
+static void BinaryPredicate1D___dealloc__(BPy_BinaryPredicate1D *self);
+static PyObject * BinaryPredicate1D___repr__(BPy_BinaryPredicate1D *self);
-/*-----------------------Python API function prototypes for the BinaryPredicate1D module--*/
-//static PyObject *Freestyle_testOutput( BPy_Freestyle * self );
-/*-----------------------BinaryPredicate1D module doc strings-----------------------------*/
-static char M_BinaryPredicate1D_doc[] = "The Blender.Freestyle.BinaryPredicate1D submodule";
-/*----------------------BinaryPredicate1D module method def----------------------------*/
-struct PyMethodDef M_BinaryPredicate1D_methods[] = {
-// {"testOutput", ( PyCFunction ) Freestyle_testOutput, METH_NOARGS, "() - Return Curve Data name"},
+static PyObject * BinaryPredicate1D_getName( BPy_BinaryPredicate1D *self, PyObject *args);
+static PyObject * BinaryPredicate1D___call__( BPy_BinaryPredicate1D *self, PyObject *args);
+
+/*----------------------BinaryPredicate1D instance definitions ----------------------------*/
+static PyMethodDef BPy_BinaryPredicate1D_methods[] = {
+ {"getName", ( PyCFunction ) BinaryPredicate1D_getName, METH_NOARGS, "( )Returns the string of the name of the binary predicate."},
+ {"__call__", ( PyCFunction ) BinaryPredicate1D___call__, METH_VARARGS, "BinaryPredicate1D(Interface1D, Interface1D ). Must be overloaded by inherited classes. It evaluates a relation between two Interface1D." },
{NULL, NULL, 0, NULL}
};
-/*-----------------------BPy_Freestyle method def------------------------------*/
-
+/*-----------------------BPy_BinaryPredicate1D type definition ------------------------------*/
PyTypeObject BinaryPredicate1D_Type = {
PyObject_HEAD_INIT( NULL )
- 0, /* ob_size */
+ 0, /* ob_size */
"BinaryPredicate1D", /* tp_name */
sizeof( BPy_BinaryPredicate1D ), /* tp_basicsize */
- 0, /* tp_itemsize */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list