diff options
-rw-r--r-- | source/blender/python/api2_2x/Blender.c | 10 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Bone.c | 25 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Camera.c | 7 | ||||
-rw-r--r-- | source/blender/python/api2_2x/CurNurb.c | 14 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Curve.c | 11 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Image.c | 38 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Lamp.c | 7 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Material.c | 94 | ||||
-rw-r--r-- | source/blender/python/api2_2x/NMesh.c | 115 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Object.c | 48 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Texture.c | 7 | ||||
-rw-r--r-- | source/blender/python/api2_2x/World.c | 7 | ||||
-rw-r--r-- | source/blender/python/api2_2x/gen_utils.c | 14 | ||||
-rw-r--r-- | source/blender/python/api2_2x/gen_utils.h | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/logic.c | 9 |
15 files changed, 296 insertions, 112 deletions
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index 4501d918470..ec0ba64e103 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -511,18 +511,16 @@ void M_Blender_Init( void ) g_blenderdict = NULL; - /* TODO: create a docstring for the Blender module */ - module = Py_InitModule3( "Blender", Blender_methods, NULL ); + module = Py_InitModule3( "Blender", Blender_methods, + "The main Blender module" ); types_InitAll( ); /* set all our pytypes to &PyType_Type */ dict = PyModule_GetDict( module ); g_blenderdict = dict; - Py_INCREF( Py_False ); - PyDict_SetItemString( dict, "bylink", Py_False ); - Py_INCREF( Py_None ); - PyDict_SetItemString( dict, "link", Py_None ); + PyDict_SetItemString( dict, "bylink", EXPP_incr_ret_False() ); + PyDict_SetItemString( dict, "link", EXPP_incr_ret ( Py_None ) ); PyDict_SetItemString( dict, "event", PyString_FromString( "" ) ); PyDict_SetItemString( dict, "Types", Types_Init( ) ); diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c index e8c0613d220..5a3a2d014e1 100644 --- a/source/blender/python/api2_2x/Bone.c +++ b/source/blender/python/api2_2x/Bone.c @@ -195,6 +195,7 @@ PyTypeObject Bone_Type = { 0, 0, 0, 0, 0, 0, BPy_Bone_methods, /* tp_methods */ 0, /* tp_members */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; //--------------- Bone Module Init----------------------------- @@ -901,20 +902,16 @@ static PyObject *Bone_hasParent( BPy_Bone * self ) if( !self->bone ) { //test to see if linked to armature //use python vars if( BLI_streq( self->parent, parent_str ) ) { - Py_INCREF( Py_False ); - return Py_False; + return EXPP_incr_ret_False(); } else { - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } } else { //use bone datastruct if( self->bone->parent ) { - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } else { - Py_INCREF( Py_False ); - return Py_False; + return EXPP_incr_ret_False(); } } } @@ -1653,20 +1650,16 @@ static PyObject *Bone_hasIK( BPy_Bone * self ) if( !self->bone ) { //test to see if linked to armature //use python vars if( self->flag & BONE_IK_TOPARENT ) { - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } else { - Py_INCREF( Py_False ); - return Py_False; + return EXPP_incr_ret_False(); } } else { //use bone datastruct if( self->bone->flag & BONE_IK_TOPARENT ) { - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } else { - Py_INCREF( Py_False ); - return Py_False; + return EXPP_incr_ret_False(); } } return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c index 3c37d1c22be..ae9b07e9b45 100644 --- a/source/blender/python/api2_2x/Camera.c +++ b/source/blender/python/api2_2x/Camera.c @@ -213,6 +213,7 @@ PyTypeObject Camera_Type = { 0, 0, 0, 0, 0, 0, BPy_Camera_methods, /* tp_methods */ 0, /* tp_members */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; static PyObject *M_Camera_New( PyObject * self, PyObject * args, @@ -555,12 +556,10 @@ static PyObject *Camera_clearIpo( BPy_Camera * self ) id->us--; cam->ipo = NULL; - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } - Py_INCREF( Py_False ); /* no ipo found */ - return Py_False; + return EXPP_incr_ret_False(); /* no ipo found */ } static PyObject *Camera_setName( BPy_Camera * self, PyObject * args ) diff --git a/source/blender/python/api2_2x/CurNurb.c b/source/blender/python/api2_2x/CurNurb.c index 6128519c5b4..e5285ef278c 100644 --- a/source/blender/python/api2_2x/CurNurb.c +++ b/source/blender/python/api2_2x/CurNurb.c @@ -194,7 +194,7 @@ static PyObject *CurNurb_repr( BPy_CurNurb * self ) return PyString_FromFormat( "[CurNurb \"%d\"]", self->nurb->type ); } - +/* XXX Can't this be simply removed? */ static PyObject *M_CurNurb_New( PyObject * self, PyObject * args ) { return ( PyObject * ) 0; @@ -419,11 +419,9 @@ static PyObject *CurNurb_isNurb( BPy_CurNurb * self ) */ if( self->nurb->bp ) { - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } else { - Py_INCREF( Py_False ); - return ( Py_False ); + return EXPP_incr_ret_False(); } } @@ -437,11 +435,9 @@ static PyObject *CurNurb_isCyclic( BPy_CurNurb * self ) /* supposing that the flagu is always set */ if( self->nurb->flagu & CU_CYCLIC ) { - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } else { - Py_INCREF( Py_False ); - return ( Py_False ); + return EXPP_incr_ret_False(); } } diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c index f8f7eb8f726..fcfb5b171c8 100644 --- a/source/blender/python/api2_2x/Curve.c +++ b/source/blender/python/api2_2x/Curve.c @@ -1067,9 +1067,10 @@ static PyObject *Curve_isNurb( BPy_Curve * self, PyObject * args ) static PyObject *Curve_isCyclic( BPy_Curve * self, PyObject * args ) { int curve_num = 0; /* default value */ - int is_cyclic; + /* unused:*/ + /* int is_cyclic; + * PyObject *ret_val;*/ Nurb *ptrnurb; - PyObject *ret_val; int i; /* parse and check input args */ @@ -1096,11 +1097,9 @@ static PyObject *Curve_isCyclic( BPy_Curve * self, PyObject * args ) } if( ptrnurb->flagu & CU_CYCLIC ){ - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } else { - Py_INCREF( Py_False ); - return Py_False; + return EXPP_incr_ret_False(); } } diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c index b651745256f..d2fbc3324a2 100644 --- a/source/blender/python/api2_2x/Image.c +++ b/source/blender/python/api2_2x/Image.c @@ -41,6 +41,7 @@ #include <BKE_image.h> #include <BIF_drawimage.h> #include <BLI_blenlib.h> +#include <DNA_space_types.h> /* FILE_MAXDIR = 160 */ #include <IMB_imbuf_types.h> /* for the IB_rect define */ #include <BIF_gl.h> #include "gen_utils.h" @@ -62,8 +63,8 @@ /*****************************************************************************/ /* Python API function prototypes for the Image module. */ /*****************************************************************************/ -static PyObject *M_Image_New( PyObject * self, PyObject * args, - PyObject * keywords ); +/*static PyObject *M_Image_New( PyObject * self, PyObject * args, + PyObject * keywords );*/ static PyObject *M_Image_Get( PyObject * self, PyObject * args ); static PyObject *M_Image_Load( PyObject * self, PyObject * args ); @@ -74,8 +75,8 @@ static PyObject *M_Image_Load( PyObject * self, PyObject * args ); /*****************************************************************************/ static char M_Image_doc[] = "The Blender Image module\n\n"; -static char M_Image_New_doc[] = - "() - return a new Image object -- unimplemented"; +/*static char M_Image_New_doc[] = + "() - return a new Image object -- unimplemented";*/ static char M_Image_Get_doc[] = "(name) - return the image with the name 'name', \ @@ -90,8 +91,8 @@ returns None if not found.\n"; /* Python method structure definition for Blender.Image module: */ /*****************************************************************************/ struct PyMethodDef M_Image_methods[] = { - {"New", ( PyCFunction ) M_Image_New, METH_VARARGS | METH_KEYWORDS, - M_Image_New_doc}, + /*{"New", ( PyCFunction ) M_Image_New, METH_VARARGS | METH_KEYWORDS, + M_Image_New_doc},*/ {"Get", M_Image_Get, METH_VARARGS, M_Image_Get_doc}, {"get", M_Image_Get, METH_VARARGS, M_Image_Get_doc}, {"Load", M_Image_Load, METH_VARARGS, M_Image_Load_doc}, @@ -99,18 +100,16 @@ struct PyMethodDef M_Image_methods[] = { }; /*****************************************************************************/ -/* Function: M_Image_New */ +/* Function: M_Image_New (unimplemented) */ /* Python equivalent: Blender.Image.New */ /*****************************************************************************/ -static PyObject *M_Image_New( PyObject * self, PyObject * args, - PyObject * keywords ) +/*static PyObject *M_Image_New( PyObject * self, PyObject * args, + PyObject * keywords ) { - printf( "In Image_New() - unimplemented in 2.25\n" ); - Py_INCREF( Py_None ); return Py_None; } - +*/ /*****************************************************************************/ /* Function: M_Image_Get */ /* Python equivalent: Blender.Image.Get */ @@ -326,6 +325,7 @@ PyTypeObject Image_Type = { 0, 0, 0, 0, 0, 0, BPy_Image_methods, /* tp_methods */ 0, /* tp_members */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* up to tp_del, to avoid a warning */ }; /*****************************************************************************/ @@ -552,15 +552,19 @@ static PyObject *Image_setName( BPy_Image * self, PyObject * args ) static PyObject *Image_setFilename( BPy_Image * self, PyObject * args ) { char *name; - char buf[160]; + int namelen = 0; - if( !PyArg_ParseTuple( args, "s", &name ) ) + /* max len is FILE_MAXDIR = 160 chars like done in DNA_image_types.h */ + + if( !PyArg_ParseTuple( args, "s#", &name, &namelen ) ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, - "expected string argument" ) ); + "expected a string argument" ) ); - PyOS_snprintf( buf, sizeof( buf ), "%s", name ); + if( namelen >= 160) + return ( EXPP_ReturnPyObjError( PyExc_TypeError, + "string argument is limited to 160 chars at most" ) ); - strcpy(self->image->name, buf); + PyOS_snprintf( self->image->name, FILE_MAXDIR * sizeof( char ), "%s", name ); Py_INCREF( Py_None ); return Py_None; diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c index 0e9935d0c78..aaf5ec33d5f 100644 --- a/source/blender/python/api2_2x/Lamp.c +++ b/source/blender/python/api2_2x/Lamp.c @@ -341,6 +341,7 @@ PyTypeObject Lamp_Type = { 0, 0, 0, 0, 0, 0, BPy_Lamp_methods, /* tp_methods */ 0, /* tp_members */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; /*****************************************************************************/ @@ -1527,10 +1528,8 @@ static PyObject *Lamp_clearIpo( BPy_Lamp * self ) id->us--; lamp->ipo = NULL; - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } - Py_INCREF( Py_False ); /* no ipo found */ - return Py_False; + return EXPP_incr_ret_False(); /* no ipo found */ } diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c index 9ab493eddcb..90a78a5f60a 100644 --- a/source/blender/python/api2_2x/Material.c +++ b/source/blender/python/api2_2x/Material.c @@ -26,7 +26,7 @@ * This is a new part of Blender. * * Contributor(s): Willian P. Germano, Michel Selten, Alex Mole, - * Alexander Szakaly + * Alexander Szakaly, Campbell Barton * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ @@ -47,6 +47,10 @@ #include "Material.h" #include "Ipo.h" +/* only used for .oopsLoc at the moment */ +#include "DNA_oops_types.h" +#include "DNA_space_types.h" + /*****************************************************************************/ /* Python BPy_Material defaults: */ /*****************************************************************************/ @@ -670,6 +674,7 @@ PyTypeObject Material_Type = { 0, 0, 0, 0, 0, 0, BPy_Material_methods, /* tp_methods */ 0, /* tp_members */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* up to tp_del to avoid a warning */ }; /*****************************************************************************/ @@ -1217,12 +1222,10 @@ static PyObject *Material_clearIpo( BPy_Material * self ) id->us--; mat->ipo = NULL; - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } - Py_INCREF( Py_False ); /* no ipo found */ - return Py_False; + return EXPP_incr_ret_False(); /* no ipo found */ } static PyObject *Material_setName( BPy_Material * self, PyObject * args ) @@ -1998,10 +2001,44 @@ static PyObject *Material_getAttr( BPy_Material * self, char *name ) else if( strcmp( name, "users" ) == 0 ) attr = PyInt_FromLong( ( double ) self->material-> id.us ); + else if (strcmp(name, "oopsLoc") == 0) { + if (G.soops) { + Oops *oops= G.soops->oops.first; + while(oops) { + if(oops->type==ID_MA) { + if ((Material *)oops->id == self->material) { + return (Py_BuildValue ("ff", oops->x, oops->y)); + } + } + oops= oops->next; + } + } + Py_INCREF (Py_None); + return (Py_None); + } + /* Select in the oops view only since its a mesh */ + else if (strcmp(name, "oopsSel") == 0) { + if (G.soops) { + Oops *oops= G.soops->oops.first; + while(oops) { + if(oops->type==ID_MA) { + if ((Material *)oops->id == self->material) { + if (oops->flag & SELECT) + return EXPP_incr_ret_True(); + else + return EXPP_incr_ret_False(); + } + } + oops= oops->next; + } + } + Py_INCREF (Py_None); + return (Py_None); + } else if( strcmp( name, "__members__" ) == 0 ) { - attr = /* 28 items */ + attr = /* 30 items */ Py_BuildValue - ( "[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]", + ( "[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]", "name", "mode", "rgbCol", "specCol", "mirCol", "R", "G", "B", "alpha", "amb", "emit", "ref", "spec", "specTransp", "add", "zOffset", "haloSize", @@ -2009,7 +2046,7 @@ static PyObject *Material_getAttr( BPy_Material * self, char *name ) "subSize", "hard", "nFlares", "nStars", "nLines", "nRings", "rayMirr", "rayMirrDepth", "fresnelDepth", "fresnelDepthFac", "IOR", "transDepth", - "fresnelTrans", "fresnelTransFac", "users" ); + "fresnelTrans", "fresnelTransFac", "users", "oopsLoc", "oopsSel" ); } if( !attr ) @@ -2129,7 +2166,46 @@ static int Material_setAttr( BPy_Material * self, char *name, error = Material_setFresnelTrans( self, valtuple ); else if( strcmp( name, "fresnelTransFac" ) == 0 ) error = Material_setFresnelTransFac( self, valtuple ); - + else if (strcmp (name, "oopsLoc") == 0) { + if (G.soops) { + Oops *oops= G.soops->oops.first; + while(oops) { + if(oops->type==ID_MA) { + if ((Material *)oops->id == self->material) { + if (!PyArg_ParseTuple (value, "ff", &(oops->x),&(oops->y))) + PyErr_SetString(PyExc_AttributeError, + "expected two floats as arguments"); + break; + } + } + oops= oops->next; + } + if (!oops) + PyErr_SetString(PyExc_RuntimeError, + "couldn't find oopsLoc data for this material!"); + else error = EXPP_incr_ret (Py_None); + } + } + /* Select in the oops view only since its a mesh */ + else if (strcmp (name, "oopsSel") == 0) { + int sel; + if (!PyArg_Parse (value, "i", &sel)) + PyErr_SetString (PyExc_TypeError, "expected an integer, 0 or 1"); + else if (G.soops) { + Oops *oops= G.soops->oops.first; + while(oops) { + if(oops->type==ID_MA) { + if ((Material *)oops->id == self->material) { + if(sel == 0) oops->flag &= ~SELECT; + else oops->flag |= SELECT; + break; + } + } + oops= oops->next; + } + error = EXPP_incr_ret (Py_None); + } + } else { /* Error */ Py_DECREF( valtuple ); return ( EXPP_ReturnIntError( PyExc_AttributeError, name ) ); diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index 50a477f7629..0bf2aa4b933 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -26,7 +26,7 @@ * This is a new part of Blender. * * Contributor(s): Willian P. Germano, Jordi Rovira i Bonet, Joseph Gilbert, - * Bala Gi, Alexander Szakaly, Stephane Soppera + * Bala Gi, Alexander Szakaly, Stephane Soppera, Campbell Barton * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ @@ -66,6 +66,9 @@ #include "constant.h" #include "gen_utils.h" +/* only used for ob.oopsloc at the moment */ +#include "DNA_oops_types.h" +#include "DNA_space_types.h" /* EXPP Mesh defines */ @@ -402,6 +405,8 @@ PyTypeObject NMCol_Type = { 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* up to tp_del to avoid a warning */ }; /*****************************/ @@ -691,6 +696,7 @@ static PySequenceMethods NMFace_SeqMethods = { ( intintargfunc ) NMFace_slice, /* sq_slice */ ( intobjargproc ) 0, /* sq_ass_item */ ( intintobjargproc ) 0, /* sq_ass_slice */ + 0,0,0, }; PyTypeObject NMFace_Type = { @@ -709,6 +715,8 @@ PyTypeObject NMFace_Type = { &NMFace_SeqMethods, /*tp_as_sequence */ 0, /*tp_as_mapping */ 0, /*tp_hash */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* up to tp_del to avoid a warning */ }; static BPy_NMVert *newvert( float *co ) @@ -883,6 +891,7 @@ static PySequenceMethods NMVert_SeqMethods = { ( intintargfunc ) NMVert_slice, /* sq_slice */ ( intobjargproc ) NMVert_ass_item, /* sq_ass_item */ ( intintobjargproc ) NMVert_ass_slice, /* sq_ass_slice */ + 0,0,0, }; PyTypeObject NMVert_Type = { @@ -900,6 +909,8 @@ PyTypeObject NMVert_Type = { ( reprfunc ) 0, /*tp_repr */ 0, /*tp_as_number */ &NMVert_SeqMethods, /*tp_as_sequence */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_del */ }; @@ -998,13 +1009,11 @@ PyTypeObject NMEdge_Type = { ( printfunc ) 0, /*tp_print */ ( getattrfunc ) NMEdge_getattr, /*tp_getattr */ ( setattrfunc ) NMEdge_setattr, /*tp_setattr */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0, }; - - - - - static void NMesh_dealloc( PyObject * self ) { BPy_NMesh *me = ( BPy_NMesh * ) self; @@ -1104,12 +1113,12 @@ static PyObject *NMesh_removeAllKeys( PyObject * self, PyObject * args ) "this function expects no arguments" ); if( !me || !me->key ) - return EXPP_incr_ret( Py_False ); + return EXPP_incr_ret_False(); me->key->id.us--; me->key = 0; - return EXPP_incr_ret( Py_True ); + return EXPP_incr_ret_True(); } static PyObject *NMesh_insertKey( PyObject * self, PyObject * args ) @@ -1215,9 +1224,9 @@ static PyObject *NMesh_hasVertexUV( PyObject * self, PyObject * args ) } if( me->flags & NMESH_HASVERTUV ) - return EXPP_incr_ret( Py_True ); + return EXPP_incr_ret_True(); else - return EXPP_incr_ret( Py_False ); + return EXPP_incr_ret_False(); } static PyObject *NMesh_hasFaceUV( PyObject * self, PyObject * args ) @@ -1241,9 +1250,9 @@ static PyObject *NMesh_hasFaceUV( PyObject * self, PyObject * args ) } if( me->flags & NMESH_HASFACEUV ) - return EXPP_incr_ret( Py_True ); + return EXPP_incr_ret_True(); else - return EXPP_incr_ret( Py_False ); + return EXPP_incr_ret_False(); } static PyObject *NMesh_hasVertexColours( PyObject * self, PyObject * args ) @@ -1267,9 +1276,9 @@ static PyObject *NMesh_hasVertexColours( PyObject * self, PyObject * args ) } if( me->flags & NMESH_HASMCOL ) - return EXPP_incr_ret( Py_True ); + return EXPP_incr_ret_True(); else - return EXPP_incr_ret( Py_False ); + return EXPP_incr_ret_False(); } static PyObject *NMesh_update( PyObject *self, PyObject *a, PyObject *kwd ) @@ -1626,11 +1635,45 @@ static PyObject *NMesh_getattr( PyObject * self, char *name ) else return EXPP_incr_ret( Py_None ); } + else if (strcmp(name, "oopsLoc") == 0) { + if (G.soops) { + Oops *oops = G.soops->oops.first; + while(oops) { + if(oops->type==ID_ME) { + if ((Mesh *)oops->id == me->mesh) { + return (Py_BuildValue ("ff", oops->x, oops->y)); + } + } + oops = oops->next; + } + } + Py_INCREF (Py_None); + return (Py_None); + } + /* Select in the oops view only since it's a mesh */ + else if (strcmp(name, "oopsSel") == 0) { + if (G.soops) { + Oops *oops = G.soops->oops.first; + while(oops) { + if(oops->type==ID_ME) { + if ((Mesh *)oops->id == me->mesh) { + if (oops->flag & SELECT) { + return EXPP_incr_ret_True(); + } else { + return EXPP_incr_ret_False(); + } + } + } + oops = oops->next; + } + } + return EXPP_incr_ret(Py_None); + } else if( strcmp( name, "__members__" ) == 0 ) - return Py_BuildValue( "[s,s,s,s,s,s,s,s]", + return Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s]", "name", "materials", "verts", "users", "faces", "maxSmoothAngle", - "subdivLevels", "edges" ); + "subdivLevels", "edges", "oopsLoc", "oopsSel" ); return Py_FindMethod( NMesh_methods, ( PyObject * ) self, name ); } @@ -1744,6 +1787,41 @@ static int NMesh_setattr( PyObject * self, char *name, PyObject * v ) return EXPP_ReturnIntError( PyExc_RuntimeError, "mesh has no edge information" ); } + else if (!strcmp(name, "oopsLoc")) { + if (G.soops) { + Oops *oops = G.soops->oops.first; + while(oops) { + if(oops->type==ID_ME) { + if ((Mesh *)oops->id == me->mesh) { + return (!PyArg_ParseTuple (v, "ff", &(oops->x),&(oops->y))); + } + } + oops = oops->next; + } + } + return 0; + } + /* Select in the oops view only since its a mesh */ + else if (!strcmp(name, "oopsSel")) { + int sel; + if (!PyArg_Parse (v, "i", &sel)) + return EXPP_ReturnIntError + (PyExc_TypeError, "expected an integer, 0 or 1"); + if (G.soops) { + Oops *oops = G.soops->oops.first; + while(oops) { + if(oops->type==ID_ME) { + if ((Mesh *)oops->id == me->mesh) { + if(sel == 0) oops->flag &= ~SELECT; + else oops->flag |= SELECT; + return 0; + } + } + oops = oops->next; + } + } + return 0; + } else return EXPP_ReturnIntError( PyExc_AttributeError, name ); @@ -1760,11 +1838,12 @@ PyTypeObject NMesh_Type = { ( printfunc ) 0, /*tp_print */ ( getattrfunc ) NMesh_getattr, /*tp_getattr */ ( setattrfunc ) NMesh_setattr, /*tp_setattr */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; static BPy_NMFace *nmface_from_data( BPy_NMesh * mesh, int vidxs[4], - char mat_nr, char flag, TFace * tface, - MCol * col ) + char mat_nr, char flag, TFace * tface, MCol * col ) { BPy_NMFace *newf = PyObject_NEW( BPy_NMFace, &NMFace_Type ); int i, len; diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 97476eb1fe0..b400a059781 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -51,6 +51,9 @@ #include "Lattice.h" #include "modules.h" +/* only used for oops location get/set at the moment */ +#include "DNA_oops_types.h" +#include "DNA_space_types.h" /*****************************************************************************/ /* Python API function prototypes for the Blender module. */ @@ -340,6 +343,7 @@ PyTypeObject Object_Type = { 0, 0, 0, 0, 0, 0, BPy_Object_methods, /* tp_methods */ 0, /* tp_members */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; /*****************************************************************************/ @@ -608,12 +612,10 @@ static PyObject *Object_clearIpo( BPy_Object * self ) id->us--; ob->ipo = NULL; - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } - Py_INCREF( Py_False ); /* no ipo found */ - return Py_False; + return EXPP_incr_ret_False(); /* no ipo found */ } static PyObject *Object_clrParent( BPy_Object * self, PyObject * args ) @@ -856,11 +858,9 @@ static PyObject *Object_isSelected( BPy_Object * self ) while( base ) { if( base->object == self->object ) { if( base->flag & SELECT ) { - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } else { - Py_INCREF( Py_False ); - return Py_False; + return EXPP_incr_ret_False(); } } base = base->next; @@ -2221,6 +2221,20 @@ static PyObject *Object_getAttr( BPy_Object * obj, char *name ) return ( Py_BuildValue( "s", object->id.name + 2 ) ); if( StringEqual( name, "sel" ) ) return ( Object_isSelected( obj ) ); + if (StringEqual (name, "oopsLoc")) { + if (G.soops) { + Oops *oops= G.soops->oops.first; + while(oops) { + if(oops->type==ID_OB) { + if ((Object *)oops->id == object) { + return (Py_BuildValue ("ff", oops->x, oops->y)); + } + } + oops= oops->next; + } + } + return EXPP_incr_ret( Py_None ); + } /* not an attribute, search the methods table */ return Py_FindMethod( BPy_Object_methods, ( PyObject * ) obj, name ); @@ -2422,16 +2436,28 @@ static int Object_setAttr( BPy_Object * obj, char *name, PyObject * value ) else return ( 0 ); } - if( StringEqual( name, "sel" ) ) { if( Object_Select( obj, valtuple ) != Py_None ) return ( -1 ); else return ( 0 ); } + if (StringEqual (name, "oopsLoc")) { + if (G.soops) { + Oops *oops= G.soops->oops.first; + while(oops) { + if(oops->type==ID_OB) { + if ((Object *)oops->id == object) { + return (!PyArg_ParseTuple (value, "ff", &(oops->x),&(oops->y))); + } + } + oops= oops->next; + } + } + return 0; + } - printf( "Unknown variable.\n" ); - return ( 0 ); + return EXPP_ReturnIntError( PyExc_KeyError, "attribute not found" ); } /*****************************************************************************/ diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c index 562f53f8f16..12c4ab362f2 100644 --- a/source/blender/python/api2_2x/Texture.c +++ b/source/blender/python/api2_2x/Texture.c @@ -500,6 +500,7 @@ PyTypeObject Texture_Type = { 0, 0, 0, 0, 0, 0, BPy_Texture_methods, /* tp_methods */ 0, /* tp_members */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; static PyObject *M_Texture_New( PyObject * self, PyObject * args, @@ -2015,10 +2016,8 @@ static PyObject *Texture_clearIpo( BPy_Texture * self ) id->us--; tex->ipo = NULL; - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } - Py_INCREF( Py_False ); /* no ipo found */ - return Py_False; + return EXPP_incr_ret_False(); /* no ipo found */ } diff --git a/source/blender/python/api2_2x/World.c b/source/blender/python/api2_2x/World.c index c6e4dae4efa..72d573ce347 100644 --- a/source/blender/python/api2_2x/World.c +++ b/source/blender/python/api2_2x/World.c @@ -241,6 +241,7 @@ PyTypeObject World_Type = { 0, 0, 0, 0, 0, 0, BPy_World_methods, /* tp_methods */ 0, /* tp_members */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; /** @@ -480,12 +481,10 @@ static PyObject *World_clearIpo( BPy_World * self ) id->us--; world->ipo = NULL; - Py_INCREF( Py_True ); - return Py_True; + return EXPP_incr_ret_True(); } - Py_INCREF( Py_False ); /* no ipo found */ - return Py_False; + return EXPP_incr_ret_False(); /* no ipo found */ } /** diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c index 0b289a77ecb..9e659654059 100644 --- a/source/blender/python/api2_2x/gen_utils.c +++ b/source/blender/python/api2_2x/gen_utils.c @@ -126,6 +126,20 @@ PyObject *EXPP_incr_ret( PyObject * object ) return ( object ); } +/* return Py_False - to avoid warnings, we use the fact that + * 0 == False in Python: */ +PyObject *EXPP_incr_ret_False() +{ + return Py_BuildValue("i", 0); +} + +/* return Py_True - to avoid warnings, we use the fact that + * 1 == True in Python: */ +PyObject *EXPP_incr_ret_True() +{ + return Py_BuildValue("i", 1); +} + /*****************************************************************************/ /* Description: This function maps the event identifier to a string. */ /*****************************************************************************/ diff --git a/source/blender/python/api2_2x/gen_utils.h b/source/blender/python/api2_2x/gen_utils.h index 514542ada71..6baf76c9ee5 100644 --- a/source/blender/python/api2_2x/gen_utils.h +++ b/source/blender/python/api2_2x/gen_utils.h @@ -64,6 +64,8 @@ float EXPP_ClampFloat( float value, float min, float max ); int EXPP_ClampInt( int value, int min, int max ); PyObject *EXPP_incr_ret( PyObject * object ); +PyObject *EXPP_incr_ret_True(void); +PyObject *EXPP_incr_ret_False(void); PyObject *EXPP_ReturnPyObjError( PyObject * type, char *error_msg ); int EXPP_ReturnIntError( PyObject * type, char *error_msg ); diff --git a/source/blender/python/api2_2x/logic.c b/source/blender/python/api2_2x/logic.c index 2dc74a8b479..c48039aab4b 100644 --- a/source/blender/python/api2_2x/logic.c +++ b/source/blender/python/api2_2x/logic.c @@ -85,6 +85,7 @@ PyTypeObject property_Type = { 0, 0, 0, 0, 0, 0, BPy_Property_methods, /* tp_methods */ 0, /* tp_members */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; //--------------- Property module internal callbacks------------------- @@ -98,9 +99,9 @@ int updatePyProperty( BPy_Property * self ) self->type = self->property->type; if( self->property->type == PROP_BOOL ) { if( *( ( int * ) &self->property->poin ) ) { - self->data = EXPP_incr_ret( Py_True ); + self->data = EXPP_incr_ret_True(); } else { - self->data = EXPP_incr_ret( Py_False ); + self->data = EXPP_incr_ret_False(); } } else if( self->property->type == PROP_INT ) { self->data = PyInt_FromLong( self->property->data ); @@ -430,9 +431,9 @@ static PyObject *Property_getData( BPy_Property * self ) } else { if( self->property->type == PROP_BOOL ) { if( self->property->data ) - attr = EXPP_incr_ret( Py_True ); + attr = EXPP_incr_ret_True(); else - attr = EXPP_incr_ret( Py_False ); + attr = EXPP_incr_ret_False(); } else if( self->property->type == PROP_INT ) { attr = PyInt_FromLong( self->property->data ); } else if( self->property->type == PROP_FLOAT || |