From 39a526a963e9e0a0f206556a8b740fab56ba2654 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jun 2007 12:24:41 +0000 Subject: Python PyMethodDef supports single argument methods (METH_O) but was using METH_VARARGS everywhere and getting the single args from the tuple. Use METH_O where applicable. --- source/blender/python/api2_2x/Blender.c | 41 ++++++++-------- source/blender/python/api2_2x/Camera.c | 68 ++++++++++++------------- source/blender/python/api2_2x/Constraint.c | 23 ++++----- source/blender/python/api2_2x/CurNurb.c | 37 ++++++-------- source/blender/python/api2_2x/Draw.c | 4 +- source/blender/python/api2_2x/Font.c | 23 ++++----- source/blender/python/api2_2x/Geometry.c | 18 +++---- source/blender/python/api2_2x/Group.c | 30 +++++------- source/blender/python/api2_2x/IDProp.c | 17 +++---- source/blender/python/api2_2x/Image.c | 52 ++++++++------------ source/blender/python/api2_2x/Ipo.c | 26 +++++----- source/blender/python/api2_2x/Ipocurve.c | 55 +++++++++------------ source/blender/python/api2_2x/Ipocurve.h | 2 + source/blender/python/api2_2x/Lamp.c | 26 +++++----- source/blender/python/api2_2x/Library.c | 44 ++++++++--------- source/blender/python/api2_2x/Material.c | 22 ++++----- source/blender/python/api2_2x/Mathutils.c | 11 ++--- source/blender/python/api2_2x/Mathutils.h | 2 +- source/blender/python/api2_2x/Mesh.c | 79 +++++++++++++++--------------- source/blender/python/api2_2x/Metaball.c | 7 ++- source/blender/python/api2_2x/Object.c | 8 +-- source/blender/python/api2_2x/Scene.c | 8 +-- source/blender/python/api2_2x/Text3d.c | 8 +-- source/blender/python/api2_2x/World.c | 8 +-- source/blender/python/api2_2x/bpy_data.c | 36 +++++--------- source/blender/python/api2_2x/gen_utils.c | 6 +-- source/blender/python/api2_2x/gen_utils.h | 2 +- source/blender/python/api2_2x/logic.c | 30 ++++++------ 28 files changed, 315 insertions(+), 378 deletions(-) (limited to 'source/blender/python') diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index 9a5163022ff..6f652a92894 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -99,16 +99,16 @@ struct ID; /*keep me up here */ /* Python API function prototypes for the Blender module. */ /**********************************************************/ static PyObject *Blender_Set( PyObject * self, PyObject * args ); -static PyObject *Blender_Get( PyObject * self, PyObject * args ); +static PyObject *Blender_Get( PyObject * self, PyObject * value ); static PyObject *Blender_Redraw( PyObject * self, PyObject * args ); static PyObject *Blender_Quit( PyObject * self ); static PyObject *Blender_Load( PyObject * self, PyObject * args ); static PyObject *Blender_Save( PyObject * self, PyObject * args ); -static PyObject *Blender_Run( PyObject * self, PyObject * args ); -static PyObject *Blender_ShowHelp( PyObject * self, PyObject * args ); +static PyObject *Blender_Run( PyObject * self, PyObject * value ); +static PyObject *Blender_ShowHelp( PyObject * self, PyObject * script ); static PyObject *Blender_UpdateMenus( PyObject * self); static PyObject *Blender_PackAll( PyObject * self); -static PyObject *Blender_UnpackAll( PyObject * self, PyObject * args); +static PyObject *Blender_UnpackAll( PyObject * self, PyObject * value); static PyObject *Blender_CountPackedFiles( PyObject * self ); extern PyObject *Text3d_Init( void ); /* missing in some include */ @@ -199,16 +199,16 @@ static char Blender_CountPackedFiles_doc[] = /*****************************************************************************/ static struct PyMethodDef Blender_methods[] = { {"Set", Blender_Set, METH_VARARGS, Blender_Set_doc}, - {"Get", Blender_Get, METH_VARARGS, Blender_Get_doc}, + {"Get", Blender_Get, METH_O, Blender_Get_doc}, {"Redraw", Blender_Redraw, METH_VARARGS, Blender_Redraw_doc}, {"Quit", ( PyCFunction ) Blender_Quit, METH_NOARGS, Blender_Quit_doc}, {"Load", Blender_Load, METH_VARARGS, Blender_Load_doc}, {"Save", Blender_Save, METH_VARARGS, Blender_Save_doc}, - {"Run", Blender_Run, METH_VARARGS, Blender_Run_doc}, - {"ShowHelp", Blender_ShowHelp, METH_VARARGS, Blender_ShowHelp_doc}, + {"Run", Blender_Run, METH_O, Blender_Run_doc}, + {"ShowHelp", Blender_ShowHelp, METH_O, Blender_ShowHelp_doc}, {"CountPackedFiles", ( PyCFunction ) Blender_CountPackedFiles, METH_NOARGS, Blender_CountPackedFiles_doc}, {"PackAll", ( PyCFunction ) Blender_PackAll, METH_NOARGS, Blender_PackAll_doc}, - {"UnpackAll", Blender_UnpackAll, METH_VARARGS, Blender_UnpackAll_doc}, + {"UnpackAll", Blender_UnpackAll, METH_O, Blender_UnpackAll_doc}, {"UpdateMenus", ( PyCFunction ) Blender_UpdateMenus, METH_NOARGS, Blender_UpdateMenus_doc}, {NULL, NULL, 0, NULL} @@ -288,12 +288,12 @@ static PyObject *Blender_Set( PyObject * self, PyObject * args ) /* Function: Blender_Get */ /* Python equivalent: Blender.Get */ /*****************************************************************************/ -static PyObject *Blender_Get( PyObject * self, PyObject * args ) +static PyObject *Blender_Get( PyObject * self, PyObject * value ) { PyObject *ret = NULL; - char *str = NULL; + char *str = PyString_AsString(value); - if( !PyArg_ParseTuple( args, "s", &str ) ) + if( !str ) return EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument"); @@ -712,14 +712,13 @@ static PyObject *Blender_Save( PyObject * self, PyObject * args ) Py_RETURN_NONE; } -static PyObject *Blender_ShowHelp(PyObject *self, PyObject *args) +static PyObject *Blender_ShowHelp(PyObject *self, PyObject *script) { - PyObject *script = NULL; char hspath[FILE_MAXDIR + FILE_MAXFILE]; /* path to help_browser.py */ char *sdir = bpy_gethome(1); PyObject *rkeyd = NULL, *arglist = NULL; - if (!PyArg_ParseTuple(args, "O!", &PyString_Type, &script)) + if (!PyString_Check(script)) return EXPP_ReturnPyObjError(PyExc_TypeError, "expected a script filename as argument"); @@ -759,14 +758,14 @@ static PyObject *Blender_ShowHelp(PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyObject *Blender_Run(PyObject *self, PyObject *args) +static PyObject *Blender_Run(PyObject *self, PyObject *value) { - char *fname = NULL; + char *fname = PyString_AsString(value); Text *text = NULL; int is_blender_text = 0; Script *script = NULL; - if (!PyArg_ParseTuple(args, "s", &fname)) + if (!fname) return EXPP_ReturnPyObjError(PyExc_TypeError, "expected a filename or a Blender Text name as argument"); @@ -848,10 +847,12 @@ static PyObject *Blender_PackAll( PyObject * self) /* Function: Blender_UnpackAll */ /* Python equivalent: Blender.UnpackAll */ /*****************************************************************************/ -static PyObject *Blender_UnpackAll( PyObject * self, PyObject *args) +static PyObject *Blender_UnpackAll( PyObject * self, PyObject *value) { - int mode; - PyArg_ParseTuple( args, "i", &mode ); + int mode = PyInt_AsLong(value); + + if (mode==-1) + return EXPP_ReturnPyObjError( PyExc_ValueError, "expected an int Blender.UnpackModes"); unpackAll(mode); Py_RETURN_NONE; } diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c index 3ed11288980..a7ebd786158 100644 --- a/source/blender/python/api2_2x/Camera.c +++ b/source/blender/python/api2_2x/Camera.c @@ -129,7 +129,7 @@ static PyObject *Camera_oldsetClipStart( BPy_Camera * self, PyObject * args ); static PyObject *Camera_oldsetClipEnd( BPy_Camera * self, PyObject * args ); static PyObject *Camera_oldsetDrawSize( BPy_Camera * self, PyObject * args ); static PyObject *Camera_oldsetScale( BPy_Camera * self, PyObject * args ); -static PyObject *Camera_oldgetScriptLinks( BPy_Camera * self, PyObject * args ); +static PyObject *Camera_oldgetScriptLinks( BPy_Camera * self, PyObject * value ); static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args ); static PyObject *Camera_oldclearIpo( BPy_Camera * self ); static PyObject *Camera_clearScriptLinks( BPy_Camera * self, PyObject * args ); @@ -169,21 +169,21 @@ static PyMethodDef BPy_Camera_methods[] = { "( Camera IPO type ) - Inserts a key into IPO"}, {"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS, "(s) - Set Camera Data name"}, - {"setType", ( PyCFunction ) Camera_oldsetType, METH_VARARGS, + {"setType", ( PyCFunction ) Camera_oldsetType, METH_O, "(s) - Set Camera type, which can be 'persp' or 'ortho'"}, {"setMode", ( PyCFunction ) Camera_oldsetMode, METH_VARARGS, "(>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"}, - {"setLens", ( PyCFunction ) Camera_oldsetLens, METH_VARARGS, + {"setLens", ( PyCFunction ) Camera_oldsetLens, METH_O, "(f) - Set *perpective* Camera lens value"}, - {"setScale", ( PyCFunction ) Camera_oldsetScale, METH_VARARGS, + {"setScale", ( PyCFunction ) Camera_oldsetScale, METH_O, "(f) - Set *ortho* Camera scale value"}, - {"setClipStart", ( PyCFunction ) Camera_oldsetClipStart, METH_VARARGS, + {"setClipStart", ( PyCFunction ) Camera_oldsetClipStart, METH_O, "(f) - Set Camera clip start value"}, - {"setClipEnd", ( PyCFunction ) Camera_oldsetClipEnd, METH_VARARGS, + {"setClipEnd", ( PyCFunction ) Camera_oldsetClipEnd, METH_O, "(f) - Set Camera clip end value"}, - {"setDrawSize", ( PyCFunction ) Camera_oldsetDrawSize, METH_VARARGS, + {"setDrawSize", ( PyCFunction ) Camera_oldsetDrawSize, METH_O, "(f) - Set Camera draw size value"}, - {"getScriptLinks", ( PyCFunction ) Camera_oldgetScriptLinks, METH_VARARGS, + {"getScriptLinks", ( PyCFunction ) Camera_oldgetScriptLinks, METH_O, "(eventname) - Get a list of this camera's scriptlinks (Text names) " "of the given type\n" "(eventname) - string: FrameChanged, Redraw or Render."}, @@ -462,11 +462,11 @@ static PyObject *Camera_oldclearIpo( BPy_Camera * self ) return EXPP_incr_ret_False(); /* no ipo found */ } -static PyObject *Camera_oldsetType( BPy_Camera * self, PyObject * args ) +static PyObject *Camera_oldsetType( BPy_Camera * self, PyObject * value ) { - char *type; + char *type = PyString_AsString(value); - if( !PyArg_ParseTuple( args, "s", &type ) ) + if(!value) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); @@ -516,75 +516,75 @@ static PyObject *Camera_oldsetMode( BPy_Camera * self, PyObject * args ) Py_RETURN_NONE; } -static PyObject *Camera_oldsetLens( BPy_Camera * self, PyObject * args ) +static PyObject *Camera_oldsetLens( BPy_Camera * self, PyObject * value ) { - float value; + float param = PyFloat_AsDouble(value); - if( !PyArg_ParseTuple( args, "f", &value ) ) + if( !PyFloat_Check(value) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected float argument" ); - self->camera->lens = EXPP_ClampFloat( value, + self->camera->lens = EXPP_ClampFloat( param, EXPP_CAM_LENS_MIN, EXPP_CAM_LENS_MAX ); Py_RETURN_NONE; } -static PyObject *Camera_oldsetScale( BPy_Camera * self, PyObject * args ) +static PyObject *Camera_oldsetScale( BPy_Camera * self, PyObject * value ) { - float value; + float param = PyFloat_AsDouble(value); - if( !PyArg_ParseTuple( args, "f", &value ) ) + if( !PyFloat_Check(value) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected float argument" ); - self->camera->ortho_scale = EXPP_ClampFloat( value, + self->camera->ortho_scale = EXPP_ClampFloat( param, EXPP_CAM_SCALE_MIN, EXPP_CAM_SCALE_MAX ); Py_RETURN_NONE; } -static PyObject *Camera_oldsetClipStart( BPy_Camera * self, PyObject * args ) +static PyObject *Camera_oldsetClipStart( BPy_Camera * self, PyObject * value ) { - float value; + float param = PyFloat_AsDouble(value); - if( !PyArg_ParseTuple( args, "f", &value ) ) + if( !PyFloat_Check(value) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected float argument" ); - self->camera->clipsta = EXPP_ClampFloat( value, + self->camera->clipsta = EXPP_ClampFloat( param, EXPP_CAM_CLIPSTART_MIN, EXPP_CAM_CLIPSTART_MAX ); Py_RETURN_NONE; } -static PyObject *Camera_oldsetClipEnd( BPy_Camera * self, PyObject * args ) +static PyObject *Camera_oldsetClipEnd( BPy_Camera * self, PyObject * value ) { - float value; + float param = PyFloat_AsDouble(value); - if( !PyArg_ParseTuple( args, "f", &value ) ) + if( !PyFloat_Check(value) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected float argument" ); - self->camera->clipend = EXPP_ClampFloat( value, + self->camera->clipend = EXPP_ClampFloat( param, EXPP_CAM_CLIPEND_MIN, EXPP_CAM_CLIPEND_MAX ); Py_RETURN_NONE; } -static PyObject *Camera_oldsetDrawSize( BPy_Camera * self, PyObject * args ) +static PyObject *Camera_oldsetDrawSize( BPy_Camera * self, PyObject * value ) { - float value; + float param = PyFloat_AsDouble(value); - if( !PyArg_ParseTuple( args, "f", &value ) ) + if( !PyFloat_Check(value) ) return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected a float number as argument" ); + "expected float argument" ); - self->camera->drawsize = EXPP_ClampFloat( value, + self->camera->drawsize = EXPP_ClampFloat( param, EXPP_CAM_DRAWSIZE_MIN, EXPP_CAM_DRAWSIZE_MAX ); @@ -614,7 +614,7 @@ static PyObject *Camera_clearScriptLinks( BPy_Camera * self, PyObject * args ) } /* cam.getScriptLinks */ -static PyObject *Camera_oldgetScriptLinks( BPy_Camera * self, PyObject * args ) +static PyObject *Camera_oldgetScriptLinks( BPy_Camera * self, PyObject * value ) { Camera *cam = self->camera; ScriptLink *slink = NULL; @@ -622,7 +622,7 @@ static PyObject *Camera_oldgetScriptLinks( BPy_Camera * self, PyObject * args ) slink = &( cam )->scriptlink; - ret = EXPP_getScriptLinks( slink, args, 0 ); + ret = EXPP_getScriptLinks( slink, value, 0 ); if( ret ) return ret; diff --git a/source/blender/python/api2_2x/Constraint.c b/source/blender/python/api2_2x/Constraint.c index 37c24dbbda6..6ab0f861509 100644 --- a/source/blender/python/api2_2x/Constraint.c +++ b/source/blender/python/api2_2x/Constraint.c @@ -174,7 +174,7 @@ static int Constraint_setData( BPy_Constraint * self, PyObject * key, /*****************************************************************************/ static PyMethodDef BPy_Constraint_methods[] = { /* name, method, flags, doc */ - {"insertKey", ( PyCFunction ) Constraint_insertKey, METH_VARARGS, + {"insertKey", ( PyCFunction ) Constraint_insertKey, METH_O, "Insert influence keyframe for constraint"}, {NULL, NULL, 0, NULL} }; @@ -374,11 +374,10 @@ static PyObject *Constraint_getType( BPy_Constraint * self ) * add keyframe for influence base on code in add_influence_key_to_constraint_func() */ - -static PyObject *Constraint_insertKey( BPy_Constraint * self, PyObject * arg ) +static PyObject *Constraint_insertKey( BPy_Constraint * self, PyObject * value ) { IpoCurve *icu; - float cfra; + float cfra = (float)PyFloat_AsDouble(value); char actname[32] = ""; Object *ob = self->obj; bConstraint *con = self->con; @@ -388,7 +387,7 @@ static PyObject *Constraint_insertKey( BPy_Constraint * self, PyObject * arg ) "This constraint has been removed!" ); /* get frame for inserting key */ - if( !PyArg_ParseTuple( arg, "f", &cfra ) ) + if( PyFloat_Check(value) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a float argument" ); @@ -1647,18 +1646,16 @@ static bConstraint *locate_constr( BPy_ConstraintSeq *self, PyObject * args ) /* create a new constraint at the end of the list */ -static PyObject *ConstraintSeq_append( BPy_ConstraintSeq *self, PyObject *args ) +static PyObject *ConstraintSeq_append( BPy_ConstraintSeq *self, PyObject *value ) { - int type; + int type = (int)PyInt_AsLong(value); bConstraint *con; - if( !PyArg_ParseTuple( args, "i", &type ) ) - EXPP_ReturnPyObjError( PyExc_TypeError, "expected int argument" ); - - /* type 0 is CONSTRAINT_TYPE_NULL, should we be able to add one of these? */ + /* type 0 is CONSTRAINT_TYPE_NULL, should we be able to add one of these? + * if the value is not an int it will be -1 */ if( type < CONSTRAINT_TYPE_NULL || type > CONSTRAINT_TYPE_RIGIDBODYJOINT ) return EXPP_ReturnPyObjError( PyExc_ValueError, - "int argument out of range" ); + "arg not in int or out of range" ); con = add_new_constraint( type ); if( self->pchan ) { @@ -1739,7 +1736,7 @@ static void ConstraintSeq_dealloc( BPy_Constraint * self ) /*****************************************************************************/ static PyMethodDef BPy_ConstraintSeq_methods[] = { /* name, method, flags, doc */ - {"append", ( PyCFunction ) ConstraintSeq_append, METH_VARARGS, + {"append", ( PyCFunction ) ConstraintSeq_append, METH_O, "(type) - add a new constraint, where type is the constraint type"}, {"remove", ( PyCFunction ) ConstraintSeq_remove, METH_VARARGS, "(con) - remove an existing constraint, where con is a constraint from this object."}, diff --git a/source/blender/python/api2_2x/CurNurb.c b/source/blender/python/api2_2x/CurNurb.c index 9d930fee1ca..f919167372c 100644 --- a/source/blender/python/api2_2x/CurNurb.c +++ b/source/blender/python/api2_2x/CurNurb.c @@ -62,7 +62,7 @@ static int CurNurb_setPoint( BPy_CurNurb * self, int index, PyObject * ob ); static int CurNurb_length( PyInstanceObject * inst ); static PyObject *CurNurb_getIter( BPy_CurNurb * self ); static PyObject *CurNurb_iterNext( BPy_CurNurb * self ); -PyObject *CurNurb_append( BPy_CurNurb * self, PyObject * args ); +PyObject *CurNurb_append( BPy_CurNurb * self, PyObject * value ); static PyObject *CurNurb_isNurb( BPy_CurNurb * self ); static PyObject *CurNurb_isCyclic( BPy_CurNurb * self ); @@ -124,7 +124,7 @@ static PyMethodDef BPy_CurNurb_methods[] = { "( type ) - change the type of the curve (Poly: 0, Bezier: 1, NURBS: 4)"}, {"getType", ( PyCFunction ) CurNurb_getType, METH_NOARGS, "( ) - get the type of the curve (Poly: 0, Bezier: 1, NURBS: 4)"}, - {"append", ( PyCFunction ) CurNurb_append, METH_VARARGS, + {"append", ( PyCFunction ) CurNurb_append, METH_O, "( point ) - add a new point. arg is BezTriple or list of x,y,z,w floats"}, {"isNurb", ( PyCFunction ) CurNurb_isNurb, METH_NOARGS, "( ) - boolean function tests if this spline is type nurb or bezier"}, @@ -435,11 +435,9 @@ static PyObject *CurNurb_getPoints( BPy_CurNurb * self ) * arg is BezTriple or list of xyzw floats */ -PyObject *CurNurb_append( BPy_CurNurb * self, PyObject * args ) +PyObject *CurNurb_append( BPy_CurNurb * self, PyObject * value ) { - Nurb *nurb = self->nurb; - - return CurNurb_appendPointToNurb( nurb, args ); + return CurNurb_appendPointToNurb( self->nurb, value ); } @@ -449,29 +447,22 @@ PyObject *CurNurb_append( BPy_CurNurb * self, PyObject * args ) * notice the first arg is Nurb*. */ -PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * args ) +PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * value ) { int i; int size; - PyObject *pyOb; int npoints = nurb->pntsu; /* do we have a list of four floats or a BezTriple? */ - if( !PyArg_ParseTuple( args, "O", &pyOb )) - return EXPP_ReturnPyObjError - ( PyExc_RuntimeError, - "Internal error parsing arguments" ); - - - + /* if curve is empty, adjust type depending on input type */ if (nurb->bezt==NULL && nurb->bp==NULL) { - if (BPy_BezTriple_Check( pyOb )) + if (BPy_BezTriple_Check( value )) nurb->type |= CU_BEZIER; - else if (PySequence_Check( pyOb )) + else if (PySequence_Check( value )) nurb->type |= CU_NURBS; else return( EXPP_ReturnPyObjError( PyExc_TypeError, @@ -483,7 +474,7 @@ PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * args ) if ((nurb->type & 7)==CU_BEZIER) { BezTriple *tmp; - if( !BPy_BezTriple_Check( pyOb ) ) + if( !BPy_BezTriple_Check( value ) ) return( EXPP_ReturnPyObjError( PyExc_TypeError, "Expected a BezTriple\n" ) ); @@ -507,11 +498,11 @@ PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * args ) nurb->pntsu++; /* add new point to end of list */ memcpy( nurb->bezt + npoints, - BezTriple_FromPyObject( pyOb ), sizeof( BezTriple ) ); + BezTriple_FromPyObject( value ), sizeof( BezTriple ) ); } - else if( PySequence_Check( pyOb ) ) { - size = PySequence_Size( pyOb ); + else if( PySequence_Check( value ) ) { + size = PySequence_Size( value ); /* printf("\ndbg: got a sequence of size %d\n", size ); */ if( size == 4 || size == 5 ) { BPoint *tmp; @@ -537,7 +528,7 @@ PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * args ) sizeof( BPoint ) ); for( i = 0; i < 4; ++i ) { - PyObject *item = PySequence_GetItem( pyOb, i ); + PyObject *item = PySequence_GetItem( value, i ); if (item == NULL) return NULL; @@ -548,7 +539,7 @@ PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * args ) } if (size == 5) { - PyObject *item = PySequence_GetItem( pyOb, i ); + PyObject *item = PySequence_GetItem( value, i ); if (item == NULL) return NULL; diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c index d0d2810bfae..114713fcfad 100644 --- a/source/blender/python/api2_2x/Draw.c +++ b/source/blender/python/api2_2x/Draw.c @@ -832,7 +832,7 @@ static PyObject *Method_Exit( PyObject * self, PyObject * args ) else Py_RETURN_NONE; - if( !PyArg_ParseTuple( args, "" ) ) + if( PyTuple_Size(args) ) return EXPP_ReturnPyObjError( PyExc_AttributeError, "expected empty argument list" ); @@ -958,7 +958,7 @@ static PyObject *Method_Draw( PyObject * self, PyObject * args ) Py_RETURN_NONE; } - if( !PyArg_ParseTuple( args, "" ) ) + if( PyTuple_Size(args) ) return EXPP_ReturnPyObjError( PyExc_AttributeError, "expected empty argument list" ); diff --git a/source/blender/python/api2_2x/Font.c b/source/blender/python/api2_2x/Font.c index 08af60fd9e0..e27f5fa3dcd 100644 --- a/source/blender/python/api2_2x/Font.c +++ b/source/blender/python/api2_2x/Font.c @@ -44,7 +44,7 @@ extern PyObject *M_Text3d_LoadFont( PyObject * self, PyObject * args ); /*--------------------Python API function prototypes for the Font module----*/ -static PyObject *M_Font_Load( PyObject * self, PyObject * args ); +static PyObject *M_Font_Load( PyObject * self, PyObject * value ); static PyObject *M_Font_Get( PyObject * self, PyObject * args ); /*------------------------Python API Doc strings for the Font module--------*/ @@ -62,7 +62,7 @@ returns None if not found.\n"; /*----- Python method structure definition for Blender.Text3d.Font module---*/ struct PyMethodDef M_Font_methods[] = { {"Get", ( PyCFunction ) M_Font_Get, METH_VARARGS, M_Font_Get_doc}, - {"Load", ( PyCFunction ) M_Font_Load, METH_VARARGS, M_Font_Load_doc}, + {"Load", ( PyCFunction ) M_Font_Load, METH_O, M_Font_Load_doc}, {NULL, NULL, 0, NULL} }; @@ -74,7 +74,7 @@ static PyObject *Font_unpack( BPy_Font * self, PyObject * args ); static PyMethodDef BPy_Font_methods[] = { {"pack", ( PyCFunction ) Font_pack, METH_NOARGS, "() - pack this Font"}, - {"unpack", ( PyCFunction ) Font_unpack, METH_VARARGS, + {"unpack", ( PyCFunction ) Font_unpack, METH_O, "(mode) - unpack this packed font"}, {NULL, NULL, 0, NULL} }; @@ -154,21 +154,18 @@ static PyObject *M_Font_Get( PyObject * self, PyObject * args ) /*--------------- Blender.Text3d.Font.New()-----------------------*/ -PyObject *M_Font_Load( PyObject * self, PyObject * args ) +PyObject *M_Font_Load( PyObject * self, PyObject * value ) { - char *filename_str; + char *filename_str = PyString_AsString(value); BPy_Font *py_font = NULL; /* for Font Data object wrapper in Python */ - PyObject *tmp; - if( !PyArg_ParseTuple( args, "s", &filename_str ) ) + if( !value ) return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "expected string or empty argument" ) ); /*create python font*/ if( !S_ISDIR(BLI_exist(filename_str)) ) { - tmp= Py_BuildValue("(s)", filename_str); - py_font= (BPy_Font *) M_Text3d_LoadFont (self, tmp); - Py_DECREF (tmp); + py_font= (BPy_Font *) M_Text3d_LoadFont (self, value); } else Py_RETURN_NONE; @@ -218,12 +215,12 @@ static PyObject *Font_pack( BPy_Font * self ) } /*--------------- BPy_Font.unpack()---------------------------------*/ -static PyObject *Font_unpack( BPy_Font * self, PyObject * args ) +static PyObject *Font_unpack( BPy_Font * self, PyObject * value ) { - int mode= 0; + int mode= PyInt_AsLong(value); VFont *font= self->font; - if( !PyArg_ParseTuple( args, "i", &mode ) ) + if( mode==-1 ) return ( EXPP_ReturnPyObjError ( PyExc_AttributeError, "expected int argument from Blender.UnpackModes" ) ); diff --git a/source/blender/python/api2_2x/Geometry.c b/source/blender/python/api2_2x/Geometry.c index 816fa03ac30..fcfe1eeae04 100644 --- a/source/blender/python/api2_2x/Geometry.c +++ b/source/blender/python/api2_2x/Geometry.c @@ -52,7 +52,7 @@ #define eul 0.000001 /*-- forward declarations -- */ -static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * args ); +static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * polyLineSeq ); static PyObject *M_Geometry_LineIntersect2D( PyObject * self, PyObject * args ); static PyObject *M_Geometry_PointInTriangle2D( PyObject * self, PyObject * args ); static PyObject *M_Geometry_BoxPack2D( PyObject * self, PyObject * args ); @@ -65,10 +65,10 @@ static char M_Geometry_PointInTriangle2D_doc[] = "(pt, tri_p1, tri_p2, tri_p3) - static char M_Geometry_BoxPack2D_doc[] = ""; /*-----------------------METHOD DEFINITIONS ----------------------*/ struct PyMethodDef M_Geometry_methods[] = { - {"PolyFill", ( PyCFunction ) M_Geometry_PolyFill, METH_VARARGS, M_Geometry_PolyFill_doc}, + {"PolyFill", ( PyCFunction ) M_Geometry_PolyFill, METH_O, M_Geometry_PolyFill_doc}, {"LineIntersect2D", ( PyCFunction ) M_Geometry_LineIntersect2D, METH_VARARGS, M_Geometry_LineIntersect2D_doc}, {"PointInTriangle2D", ( PyCFunction ) M_Geometry_PointInTriangle2D, METH_VARARGS, M_Geometry_PointInTriangle2D_doc}, - {"BoxPack2D", ( PyCFunction ) M_Geometry_BoxPack2D, METH_VARARGS, M_Geometry_BoxPack2D_doc}, + {"BoxPack2D", ( PyCFunction ) M_Geometry_BoxPack2D, METH_O, M_Geometry_BoxPack2D_doc}, {NULL, NULL, 0, NULL} }; /*----------------------------MODULE INIT-------------------------*/ @@ -83,10 +83,10 @@ PyObject *Geometry_Init(void) /*----------------------------------Geometry.PolyFill() -------------------*/ /* PolyFill function, uses Blenders scanfill to fill multiple poly lines */ -static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * args ) +static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * polyLineSeq ) { PyObject *tri_list; /*return this list of tri's */ - PyObject *polyLineSeq, *polyLine, *polyVec; + PyObject *polyLine, *polyVec; int i, len_polylines, len_polypoints; /* display listbase */ @@ -99,7 +99,7 @@ static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * args ) dispbase.first= dispbase.last= NULL; - if(!PyArg_ParseTuple ( args, "O", &polyLineSeq) || !PySequence_Check(polyLineSeq)) { + if(!PySequence_Check(polyLineSeq)) { return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a sequence of poly lines" ); } @@ -361,18 +361,16 @@ void boxPack_ToPyObject(PyObject * value, boxPack **boxarray) } -static PyObject *M_Geometry_BoxPack2D( PyObject * self, PyObject * args ) +static PyObject *M_Geometry_BoxPack2D( PyObject * self, PyObject * boxlist ) { - PyObject *boxlist; /*return this list of tri's */ boxPack *boxarray; float tot_width, tot_height; int len; int error; - if(!PyArg_ParseTuple ( args, "O", &boxlist) || !PyList_Check(boxlist)) { + if(!PyList_Check(boxlist)) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a sequence of boxes [[x,y,w,h], ... ]" ); - } len = PyList_Size( boxlist ); diff --git a/source/blender/python/api2_2x/Group.c b/source/blender/python/api2_2x/Group.c index 7a6a1562d8b..012e0cb540c 100755 --- a/source/blender/python/api2_2x/Group.c +++ b/source/blender/python/api2_2x/Group.c @@ -58,7 +58,7 @@ /*****************************************************************************/ static PyObject *M_Group_New( PyObject * self, PyObject * args ); PyObject *M_Group_Get( PyObject * self, PyObject * args ); -PyObject *M_Group_Unlink( PyObject * self, PyObject * args ); +PyObject *M_Group_Unlink( PyObject * self, BPy_Group * pygrp ); /* internal */ static PyObject *GroupObSeq_CreatePyObject( BPy_Group *self, GroupObject *iter ); @@ -72,7 +72,7 @@ struct PyMethodDef M_Group_methods[] = { {"Get", ( PyCFunction ) M_Group_Get, METH_VARARGS, "(name) - return the group with the name 'name',\ returns None if notfound.\nIf 'name' is not specified, it returns a list of all groups."}, - {"Unlink", ( PyCFunction ) M_Group_Unlink, METH_VARARGS, + {"Unlink", ( PyCFunction ) M_Group_Unlink, METH_O, "(group) - Unlink (delete) this group from Blender."}, {NULL, NULL, 0, NULL} }; @@ -447,17 +447,13 @@ PyObject *M_Group_Get( PyObject * self, PyObject * args ) /* Function: M_Group_Unlink */ /* Python equivalent: Blender.Group.Unlink */ /*****************************************************************************/ -PyObject *M_Group_Unlink( PyObject * self, PyObject * args ) +PyObject *M_Group_Unlink( PyObject * self, BPy_Group * pygrp ) { - PyObject *pyob=NULL; - BPy_Group *pygrp=NULL; Group *group; - if( !PyArg_ParseTuple( args, "O!", &Group_Type, &pyob) ) + if( !BPy_Group_Check(pygrp) ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, "expected a group" ) ); - pygrp= (BPy_Group *)pyob; - GROUP_DEL_CHECK_PY(pygrp); group= pygrp->group; @@ -661,14 +657,13 @@ static PyObject *GroupObSeq_nextIter( BPy_GroupObSeq * self ) } -static PyObject *GroupObSeq_link( BPy_GroupObSeq * self, PyObject *args ) +static PyObject *GroupObSeq_link( BPy_GroupObSeq * self, BPy_Object *value ) { - PyObject *pyobj; Object *blen_ob; GROUP_DEL_CHECK_PY(self->bpygroup); - if( !PyArg_ParseTuple( args, "O!", &Object_Type, &pyobj ) ) + if( !BPy_Object_Check(value) ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, "expected a python object as an argument" ) ); @@ -678,26 +673,25 @@ static PyObject *GroupObSeq_link( BPy_GroupObSeq * self, PyObject *args ) "Cannot modify group objects while iterating" ); */ - blen_ob = ( ( BPy_Object * ) pyobj )->object; + blen_ob = value->object; add_to_group_wraper(self->bpygroup->group, blen_ob); /* this checks so as not to add the object into the group twice*/ Py_RETURN_NONE; } -static PyObject *GroupObSeq_unlink( BPy_GroupObSeq * self, PyObject *args ) +static PyObject *GroupObSeq_unlink( BPy_GroupObSeq * self, BPy_Object *value ) { - PyObject *pyobj; Object *blen_ob; Base *base= NULL; GROUP_DEL_CHECK_PY(self->bpygroup); - if( !PyArg_ParseTuple( args, "O!", &Object_Type, &pyobj ) ) + if( !BPy_Object_Check(value) ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, "expected a python object as an argument" ) ); - blen_ob = ( ( BPy_Object * ) pyobj )->object; + blen_ob = value->object; @@ -714,9 +708,9 @@ static PyObject *GroupObSeq_unlink( BPy_GroupObSeq * self, PyObject *args ) } static struct PyMethodDef BPy_GroupObSeq_methods[] = { - {"link", (PyCFunction)GroupObSeq_link, METH_VARARGS, + {"link", (PyCFunction)GroupObSeq_link, METH_O, "make the object a part of this group"}, - {"unlink", (PyCFunction)GroupObSeq_unlink, METH_VARARGS, + {"unlink", (PyCFunction)GroupObSeq_unlink, METH_O, "unlink an object from this group"}, {NULL, NULL, 0, NULL} }; diff --git a/source/blender/python/api2_2x/IDProp.c b/source/blender/python/api2_2x/IDProp.c index 5372e569d41..4f2fa82b21e 100644 --- a/source/blender/python/api2_2x/IDProp.c +++ b/source/blender/python/api2_2x/IDProp.c @@ -384,14 +384,13 @@ PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop) "eek!! a property exists with a bad type code!!!" ); } -PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *vars) +PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value) { IDProperty *loop; PyObject *pyform; - char *name; - int ok = PyArg_ParseTuple(vars, "s", &name); + char *name = PyString_AsString(value); - if (!ok) { + if (!name) { return EXPP_ReturnPyObjError( PyExc_TypeError, "pop expected at least 1 arguments, got 0" ); } @@ -463,12 +462,12 @@ PyObject *BPy_IDGroup_GetValues(BPy_IDProperty *self) return seq; } -PyObject *BPy_IDGroup_HasKey(BPy_IDProperty *self, PyObject *vars) +PyObject *BPy_IDGroup_HasKey(BPy_IDProperty *self, PyObject *value) { IDProperty *loop; - char *name; + char *name = PyString_AsString(value); - if (!PyArg_ParseTuple(vars, "s", &name)) + if (!name) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a string"); @@ -507,7 +506,7 @@ PyObject *BPy_IDGroup_ConvertToPy(BPy_IDProperty *self) } static struct PyMethodDef BPy_IDGroup_methods[] = { - {"pop", (PyCFunction)BPy_IDGroup_Pop, METH_VARARGS, + {"pop", (PyCFunction)BPy_IDGroup_Pop, METH_O, "pop an item from the group; raises KeyError if the item doesn't exist."}, {"iteritems", (PyCFunction)BPy_IDGroup_IterItems, METH_NOARGS, "iterate through the items in the dict; behaves like dictionary method iteritems."}, @@ -515,7 +514,7 @@ static struct PyMethodDef BPy_IDGroup_methods[] = { "get the keys associated with this group as a list of strings."}, {"values", (PyCFunction)BPy_IDGroup_GetValues, METH_NOARGS, "get the values associated with this group."}, - {"has_key", (PyCFunction)BPy_IDGroup_HasKey, METH_VARARGS, + {"has_key", (PyCFunction)BPy_IDGroup_HasKey, METH_O, "returns true if the group contains a key, false if not."}, {"update", (PyCFunction)BPy_IDGroup_Update, METH_VARARGS, "updates the values in the group with the values of another or a dict."}, diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c index 4a7ba22a084..ab2f573519a 100644 --- a/source/blender/python/api2_2x/Image.c +++ b/source/blender/python/api2_2x/Image.c @@ -83,7 +83,7 @@ enum img_consts { static PyObject *M_Image_New( PyObject * self, PyObject * args ); static PyObject *M_Image_Get( PyObject * self, PyObject * args ); static PyObject *M_Image_GetCurrent( PyObject * self ); -static PyObject *M_Image_Load( PyObject * self, PyObject * args ); +static PyObject *M_Image_Load( PyObject * self, PyObject * value ); /*****************************************************************************/ @@ -100,8 +100,8 @@ static PyObject *Image_getEnd( BPy_Image * self ); static PyObject *Image_getSpeed( BPy_Image * self ); static int Image_setFilename( BPy_Image * self, PyObject * args ); static PyObject *Image_oldsetFilename( BPy_Image * self, PyObject * args ); -static PyObject *Image_setXRep( BPy_Image * self, PyObject * args ); -static PyObject *Image_setYRep( BPy_Image * self, PyObject * args ); +static PyObject *Image_setXRep( BPy_Image * self, PyObject * value ); +static PyObject *Image_setYRep( BPy_Image * self, PyObject * value ); static PyObject *Image_setStart( BPy_Image * self, PyObject * args ); static PyObject *Image_setEnd( BPy_Image * self, PyObject * args ); static PyObject *Image_setSpeed( BPy_Image * self, PyObject * args ); @@ -115,7 +115,7 @@ static PyObject *Image_setPixelI( BPy_Image * self, PyObject * args ); static PyObject *Image_getMaxXY( BPy_Image * self ); static PyObject *Image_getMinXY( BPy_Image * self ); static PyObject *Image_save( BPy_Image * self ); -static PyObject *Image_unpack( BPy_Image * self, PyObject * args ); +static PyObject *Image_unpack( BPy_Image * self, PyObject * value ); static PyObject *Image_pack( BPy_Image * self ); static PyObject *Image_makeCurrent( BPy_Image * self ); @@ -169,9 +169,9 @@ static PyMethodDef BPy_Image_methods[] = { "(str) - Change Image object name"}, {"setFilename", ( PyCFunction ) Image_oldsetFilename, METH_VARARGS, "(str) - Change Image file name"}, - {"setXRep", ( PyCFunction ) Image_setXRep, METH_VARARGS, + {"setXRep", ( PyCFunction ) Image_setXRep, METH_O, "(int) - Change Image object x repetition value"}, - {"setYRep", ( PyCFunction ) Image_setYRep, METH_VARARGS, + {"setYRep", ( PyCFunction ) Image_setYRep, METH_O, "(int) - Change Image object y repetition value"}, {"setStart", ( PyCFunction ) Image_setStart, METH_VARARGS, "(int) - Change Image object animation start value"}, @@ -222,7 +222,7 @@ struct PyMethodDef M_Image_methods[] = { {"Get", M_Image_Get, METH_VARARGS, M_Image_Get_doc}, {"GetCurrent", ( PyCFunction ) M_Image_GetCurrent, METH_NOARGS, M_Image_GetCurrent_doc}, {"get", M_Image_Get, METH_VARARGS, M_Image_Get_doc}, - {"Load", M_Image_Load, METH_VARARGS, M_Image_Load_doc}, + {"Load", M_Image_Load, METH_O, M_Image_Load_doc}, {NULL, NULL, 0, NULL} }; @@ -349,13 +349,13 @@ static PyObject *M_Image_GetCurrent( PyObject * self ) /* Description: Receives a string and returns the image object */ /* whose filename matches the string. */ /*****************************************************************************/ -static PyObject *M_Image_Load( PyObject * self, PyObject * args ) +static PyObject *M_Image_Load( PyObject * self, PyObject * value ) { - char *fname; + char *fname = PyString_AsString(value); Image *img_ptr; BPy_Image *image; - if( !PyArg_ParseTuple( args, "s", &fname ) ) + if( !value ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ) ); @@ -650,13 +650,13 @@ static PyObject *Image_getMinXY( BPy_Image * self ) /* unpack image */ -static PyObject *Image_unpack( BPy_Image * self, PyObject * args ) +static PyObject *Image_unpack( BPy_Image * self, PyObject * value ) { Image *image = self->image; - int mode; + int mode = (int)PyInt_AsLong(value); /*get the absolute path */ - if( !PyArg_ParseTuple( args, "i", &mode ) ) + if( mode==-1 ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected 1 integer from Blender.UnpackModes" ); @@ -1000,37 +1000,27 @@ static PyObject *Image_oldsetFilename( BPy_Image * self, PyObject * args ) return EXPP_setterWrapper( (void *)self, args, (setter)Image_setFilename ); } -static PyObject *Image_setXRep( BPy_Image * self, PyObject * args ) +static PyObject *Image_setXRep( BPy_Image * self, PyObject * value ) { - short value; + short param = (short)PyInt_AsLong(value); - if( !PyArg_ParseTuple( args, "h", &value ) ) + if( param !=-1 && param >= EXPP_IMAGE_REP_MIN && param <= EXPP_IMAGE_REP_MAX) return ( EXPP_ReturnPyObjError( PyExc_TypeError, "expected int argument in [1,16]" ) ); - if( value >= EXPP_IMAGE_REP_MIN && value <= EXPP_IMAGE_REP_MAX ) - self->image->xrep = value; - else - return ( EXPP_ReturnPyObjError( PyExc_ValueError, - "expected int argument in [1,16]" ) ); - + self->image->xrep = param; Py_RETURN_NONE; } -static PyObject *Image_setYRep( BPy_Image * self, PyObject * args ) +static PyObject *Image_setYRep( BPy_Image * self, PyObject * value ) { - short value; + short param = (short)PyInt_AsLong(value); - if( !PyArg_ParseTuple( args, "h", &value ) ) + if( param !=-1 && param >= EXPP_IMAGE_REP_MIN && param <= EXPP_IMAGE_REP_MAX) return ( EXPP_ReturnPyObjError( PyExc_TypeError, "expected int argument in [1,16]" ) ); - if( value >= EXPP_IMAGE_REP_MIN && value <= EXPP_IMAGE_REP_MAX ) - self->image->yrep = value; - else - return ( EXPP_ReturnPyObjError( PyExc_ValueError, - "expected int argument in [1,16]" ) ); - + self->image->yrep = param; Py_RETURN_NONE; } diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c index 466337ff914..45b6f8a2c79 100644 --- a/source/blender/python/api2_2x/Ipo.c +++ b/source/blender/python/api2_2x/Ipo.c @@ -86,7 +86,7 @@ struct PyMethodDef M_Ipo_methods[] = { M_Ipo_New_doc}, {"Get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc}, {"get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc}, - {"Recalc", M_Ipo_Recalc, METH_VARARGS, M_Ipo_Get_doc}, + {"Recalc", M_Ipo_Recalc, METH_O, M_Ipo_Get_doc}, {NULL, NULL, 0, NULL} }; @@ -103,7 +103,7 @@ static int Ipo_setRctf( BPy_Ipo * self, PyObject * args ); static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args ); static PyObject *Ipo_getCurves( BPy_Ipo * self ); static PyObject *Ipo_getCurveNames( BPy_Ipo * self ); -static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args ); +static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * value ); static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * args ); static PyObject *Ipo_getNcurves( BPy_Ipo * self ); static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args ); @@ -142,7 +142,7 @@ static PyMethodDef BPy_Ipo_methods[] = { "() - Return Ipo rctf"}, {"setRctf", ( PyCFunction ) Ipo_oldsetRctf, METH_VARARGS, "(flt,flt,flt,flt) - Change Ipo rctf"}, - {"addCurve", ( PyCFunction ) Ipo_addCurve, METH_VARARGS, + {"addCurve", ( PyCFunction ) Ipo_addCurve, METH_O, "() - Add a curve to Ipo"}, {"delCurve", ( PyCFunction ) Ipo_delCurve, METH_VARARGS, "(str) - Delete curve from Ipo"}, @@ -790,15 +790,13 @@ static PyObject *M_Ipo_Get( PyObject * self_unused, PyObject * args ) /* Description: Receives (presumably) an IpoCurve object and */ /* updates the curve after changes to control points. */ /*****************************************************************************/ -static PyObject *M_Ipo_Recalc( PyObject * self_unused, PyObject * args ) +static PyObject *M_Ipo_Recalc( PyObject * self_unused, PyObject * value ) { - PyObject *pyobj; - - if( !PyArg_ParseTuple( args, "O!", &IpoCurve_Type, &pyobj ) ) + if( !BPy_IpoCurve_Check(value) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected Ipo curve argument" ); - testhandles_ipocurve( IpoCurve_FromPyObject( pyobj ) ); + testhandles_ipocurve( IpoCurve_FromPyObject( value ) ); Py_RETURN_NONE; } @@ -882,15 +880,15 @@ static PyObject *Ipo_getNcurves( BPy_Ipo * self ) cu = ipo.addCurve('LocX') */ -static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args ) +static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * value ) { short param; /* numeric curve name constant */ - char *cur_name = 0; /* input arg: curve name */ + char *cur_name = PyString_AsString(value); /* input arg: curve name */ Ipo *ipo = 0; IpoCurve *icu = 0; Link *link; - if( !PyArg_ParseTuple( args, "s", &cur_name ) ) + if( !cur_name ) return ( EXPP_ReturnPyObjError ( PyExc_TypeError, "expected string argument" ) ); @@ -959,12 +957,12 @@ static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args ) cu = ipo.delCurve('LocX') */ -static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * args ) +static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * value ) { IpoCurve *icu; - char *strname; + char *strname = PyString_AsString(value); - if( !PyArg_ParseTuple( args, "s", &strname ) ) + if( !strname ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c index 7b071ab1f76..bbc8e8ffc4e 100644 --- a/source/blender/python/api2_2x/Ipocurve.c +++ b/source/blender/python/api2_2x/Ipocurve.c @@ -67,16 +67,16 @@ struct PyMethodDef M_IpoCurve_methods[] = { /*****************************************************************************/ static PyObject *IpoCurve_getName( C_IpoCurve * self ); static PyObject *IpoCurve_Recalc( C_IpoCurve * self ); -static PyObject *IpoCurve_append( C_IpoCurve * self, PyObject * args ); -static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject * args ); +static PyObject *IpoCurve_append( C_IpoCurve * self, PyObject * value ); +static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject * value ); static PyObject *IpoCurve_delBezier( C_IpoCurve * self, PyObject * args ); static PyObject *IpoCurve_setInterpolation( C_IpoCurve * self, - PyObject * args ); + PyObject * value ); static PyObject *IpoCurve_getInterpolation( C_IpoCurve * self ); static PyObject *IpoCurve_newgetInterp( C_IpoCurve * self ); static int IpoCurve_newsetInterp( C_IpoCurve * self, PyObject * args ); static PyObject *IpoCurve_setExtrapolation( C_IpoCurve * self, - PyObject * args ); + PyObject * value ); static PyObject *IpoCurve_getExtrapolation( C_IpoCurve * self ); static PyObject *IpoCurve_newgetExtend( C_IpoCurve * self ); static int IpoCurve_newsetExtend( C_IpoCurve * self, PyObject * args ); @@ -110,18 +110,18 @@ static PyMethodDef C_IpoCurve_methods[] = { "() - Recomputes the curve after changes"}, {"update", ( PyCFunction ) IpoCurve_Recalc, METH_NOARGS, "() - deprecated method: use recalc method instead."}, - {"append", ( PyCFunction ) IpoCurve_append, METH_VARARGS, + {"append", ( PyCFunction ) IpoCurve_append, METH_O, "(coordlist) - Adds a Bezier point to a curve"}, - {"addBezier", ( PyCFunction ) IpoCurve_addBezier, METH_VARARGS, + {"addBezier", ( PyCFunction ) IpoCurve_addBezier, METH_O, "() - deprecated method. use append() instead"}, {"delBezier", ( PyCFunction ) IpoCurve_delBezier, METH_VARARGS, "() - deprecated method. use \"del icu[index]\" instead"}, {"setInterpolation", ( PyCFunction ) IpoCurve_setInterpolation, - METH_VARARGS, "(str) - Sets the interpolation type of the curve"}, + METH_O, "(str) - Sets the interpolation type of the curve"}, {"getInterpolation", ( PyCFunction ) IpoCurve_getInterpolation, METH_NOARGS, "() - Gets the interpolation type of the curve"}, {"setExtrapolation", ( PyCFunction ) IpoCurve_setExtrapolation, - METH_VARARGS, "(str) - Sets the extend mode of the curve"}, + METH_O, "(str) - Sets the extend mode of the curve"}, {"getExtrapolation", ( PyCFunction ) IpoCurve_getExtrapolation, METH_NOARGS, "() - Gets the extend mode of the curve"}, {"getPoints", ( PyCFunction ) IpoCurve_getPoints, METH_NOARGS, @@ -394,12 +394,12 @@ static void del_beztriple( IpoCurve *icu, int index ) /*****************************************************************************/ static PyObject *IpoCurve_setInterpolation( C_IpoCurve * self, - PyObject * args ) + PyObject * value ) { - char *interpolationtype = 0; + char *interpolationtype = PyString_AsString(value); short id; - if( !PyArg_ParseTuple( args, "s", &interpolationtype ) ) + if( !interpolationtype ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); @@ -441,12 +441,12 @@ static PyObject *IpoCurve_getInterpolation( C_IpoCurve * self ) } static PyObject * IpoCurve_setExtrapolation( C_IpoCurve * self, - PyObject * args ) + PyObject * value ) { - char *extrapolationtype = 0; + char *extrapolationtype = PyString_AsString(value); short id; - if( !PyArg_ParseTuple( args, "s", &extrapolationtype ) ) + if( !extrapolationtype ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); @@ -496,19 +496,14 @@ static PyObject *IpoCurve_getExtrapolation( C_IpoCurve * self ) * append a new BezTriple to curve */ -static PyObject *IpoCurve_append( C_IpoCurve * self, PyObject * args ) +static PyObject *IpoCurve_append( C_IpoCurve * self, PyObject * value ) { float x, y; IpoCurve *icu = self->ipocurve; - PyObject *obj = NULL; - - if( !PyArg_ParseTuple( args, "O", &obj ) ) - return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected tuple or BezTriple argument" ); /* if args is a already a beztriple, tack onto end of list */ - if( BPy_BezTriple_Check ( obj ) ) { - BPy_BezTriple *bobj = (BPy_BezTriple *)obj; + if( BPy_BezTriple_Check ( value ) ) { + BPy_BezTriple *bobj = (BPy_BezTriple *)value; BezTriple *newb = MEM_callocN( (icu->totvert+1)*sizeof(BezTriple), "BPyBeztriple" ); @@ -525,8 +520,8 @@ static PyObject *IpoCurve_append( C_IpoCurve * self, PyObject * args ) /* otherwise try to get two floats and add to list */ } else { PyObject *xobj, *yobj; - xobj = PyNumber_Float( PyTuple_GetItem( obj, 0 ) ); - yobj = PyNumber_Float( PyTuple_GetItem( obj, 1 ) ); + xobj = PyNumber_Float( PyTuple_GetItem( value, 0 ) ); + yobj = PyNumber_Float( PyTuple_GetItem( value, 1 ) ); if( !xobj || !yobj ) return EXPP_ReturnPyObjError( PyExc_TypeError, @@ -1058,20 +1053,17 @@ static int IpoCurve_setFlag( C_IpoCurve * self, PyObject *value, void *type ) /* #####DEPRECATED###### */ -static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject * args ) +static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject * value ) { float x, y; int npoints; IpoCurve *icu; BezTriple *bzt, *tmp; static char name[10] = "mlml"; - PyObject *popo = 0; - if( !PyArg_ParseTuple( args, "O", &popo ) ) + if( !PyArg_ParseTuple( value, "ff", &x, &y ) ) return ( EXPP_ReturnPyObjError - ( PyExc_TypeError, "expected tuple argument" ) ); + ( PyExc_TypeError, "expected a tuple of 2 floats" ) ); - x = (float)PyFloat_AsDouble( PyTuple_GetItem( popo, 0 ) ); - y = (float)PyFloat_AsDouble( PyTuple_GetItem( popo, 1 ) ); icu = self->ipocurve; npoints = icu->totvert; tmp = icu->bezt; @@ -1093,6 +1085,5 @@ static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject * args ) bzt->h1 = HD_AUTO; bzt->h2 = HD_AUTO; - Py_INCREF( Py_None ); - return Py_None; + Py_RETURN_NONE; } diff --git a/source/blender/python/api2_2x/Ipocurve.h b/source/blender/python/api2_2x/Ipocurve.h index c79dc5d35f1..0844e11b04b 100644 --- a/source/blender/python/api2_2x/Ipocurve.h +++ b/source/blender/python/api2_2x/Ipocurve.h @@ -47,6 +47,8 @@ typedef struct { extern PyTypeObject IpoCurve_Type; +#define BPy_IpoCurve_Check(v) ((v)->ob_type == &IpoCurve_Type) /* for type checking */ + PyObject *IpoCurve_Init( void ); PyObject *IpoCurve_CreatePyObject( IpoCurve * ipo ); IpoCurve *IpoCurve_FromPyObject( PyObject * pyobj ); diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c index 84e755b64a0..ee4a8257b6f 100644 --- a/source/blender/python/api2_2x/Lamp.c +++ b/source/blender/python/api2_2x/Lamp.c @@ -207,7 +207,7 @@ static PyObject *Lamp_getComponent( BPy_Lamp * self, void * closure ); static PyObject *Lamp_clearIpo( BPy_Lamp * self ); static PyObject *Lamp_insertIpoKey( BPy_Lamp * self, PyObject * args ); static PyObject *Lamp_oldsetIpo( BPy_Lamp * self, PyObject * args ); -static PyObject *Lamp_oldsetType( BPy_Lamp * self, PyObject * args ); +static PyObject *Lamp_oldsetType( BPy_Lamp * self, PyObject * value ); static PyObject *Lamp_oldsetMode( BPy_Lamp * self, PyObject * args ); static PyObject *Lamp_oldsetSamples( BPy_Lamp * self, PyObject * args ); static PyObject *Lamp_oldsetRaySamplesX( BPy_Lamp * self, PyObject * args ); @@ -251,7 +251,7 @@ static int Lamp_setHaloInt( BPy_Lamp * self, PyObject * args ); static int Lamp_setQuad1( BPy_Lamp * self, PyObject * args ); static int Lamp_setQuad2( BPy_Lamp * self, PyObject * args ); static int Lamp_setCol( BPy_Lamp * self, PyObject * args ); -static PyObject *Lamp_getScriptLinks( BPy_Lamp * self, PyObject * args ); +static PyObject *Lamp_getScriptLinks( BPy_Lamp * self, PyObject * value ); static PyObject *Lamp_addScriptLink( BPy_Lamp * self, PyObject * args ); static PyObject *Lamp_clearScriptLinks( BPy_Lamp * self, PyObject * args ); static int Lamp_setComponent( BPy_Lamp * self, PyObject * value, void * closure ); @@ -306,7 +306,7 @@ static PyMethodDef BPy_Lamp_methods[] = { "() - return light rgb color triplet"}, {"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS, "(str) - rename Lamp"}, - {"setType", ( PyCFunction ) Lamp_oldsetType, METH_VARARGS, + {"setType", ( PyCFunction ) Lamp_oldsetType, METH_O, "(str) - change Lamp type, which can be 'Lamp', 'Sun', 'Spot', 'Hemi', 'Area', 'Photon'"}, {"setMode", ( PyCFunction ) Lamp_oldsetMode, METH_VARARGS, "([up to eight str's]) - Set Lamp mode flag(s)"}, @@ -348,7 +348,7 @@ static PyMethodDef BPy_Lamp_methods[] = { "(float) - change light intensity value #2 for a Quad Lamp"}, {"setCol", ( PyCFunction ) Lamp_oldsetCol, METH_VARARGS, "(f,f,f) or ([f,f,f]) - change light's rgb color triplet"}, - {"getScriptLinks", ( PyCFunction ) Lamp_getScriptLinks, METH_VARARGS, + {"getScriptLinks", ( PyCFunction ) Lamp_getScriptLinks, METH_O, "(eventname) - Get a list of this lamp's scriptlinks (Text names) " "of the given type\n" "(eventname) - string: FrameChanged, Redraw or Render."}, @@ -1330,7 +1330,7 @@ static PyObject *Lamp_clearScriptLinks( BPy_Lamp * self, PyObject * args ) } /* mat.getScriptLinks */ -static PyObject *Lamp_getScriptLinks( BPy_Lamp * self, PyObject * args ) +static PyObject *Lamp_getScriptLinks( BPy_Lamp * self, PyObject * value ) { Lamp *lamp = self->lamp; ScriptLink *slink = NULL; @@ -1338,7 +1338,7 @@ static PyObject *Lamp_getScriptLinks( BPy_Lamp * self, PyObject * args ) slink = &( lamp )->scriptlink; - ret = EXPP_getScriptLinks( slink, args, 0 ); + ret = EXPP_getScriptLinks( slink, value, 0 ); if( ret ) return ret; @@ -1613,14 +1613,14 @@ static PyObject *Lamp_clearIpo( BPy_Lamp * self ) * setType() accepts a string while mode setter takes an integer */ -static PyObject *Lamp_oldsetType( BPy_Lamp * self, PyObject * args ) +static PyObject *Lamp_oldsetType( BPy_Lamp * self, PyObject * value ) { - char *type; - PyObject *value, *error; + char *type = PyString_AsString(value); + PyObject *arg, *error; /* parse string argument */ - if( !PyArg_ParseTuple( args, "s", &type ) ) + if( !value ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ) ); @@ -1644,9 +1644,9 @@ static PyObject *Lamp_oldsetType( BPy_Lamp * self, PyObject * args ) /* build tuple, call wrapper */ - value = PyInt_FromLong( (long)type ); - error = EXPP_setterWrapper ( (void *)self, value, (setter)Lamp_setType ); - Py_DECREF ( value ); + arg = PyInt_FromLong( (long)type ); + error = EXPP_setterWrapper ( (void *)self, arg, (setter)Lamp_setType ); + Py_DECREF ( arg ); return error; } diff --git a/source/blender/python/api2_2x/Library.c b/source/blender/python/api2_2x/Library.c index 495f6eabf44..1aacaf56786 100644 --- a/source/blender/python/api2_2x/Library.c +++ b/source/blender/python/api2_2x/Library.c @@ -67,7 +67,7 @@ static PyObject *M_Library_Open( PyObject * self, PyObject * args ); static PyObject *M_Library_Close( PyObject * self ); static PyObject *M_Library_GetName( PyObject * self ); static PyObject *M_Library_Update( PyObject * self ); -static PyObject *M_Library_Datablocks( PyObject * self, PyObject * args ); +static PyObject *M_Library_Datablocks( PyObject * self, PyObject * value ); static PyObject *oldM_Library_Load( PyObject * self, PyObject * args ); static PyObject *M_Library_LinkableGroups( PyObject * self ); static PyObject *M_Library_LinkedLibs( PyObject * self ); @@ -123,14 +123,14 @@ static char Library_LinkedLibs_doc[] = * Python method structure definition for Blender.Library submodule. */ struct PyMethodDef oldM_Library_methods[] = { - {"Open", M_Library_Open, METH_VARARGS, Library_Open_doc}, + {"Open", M_Library_Open, METH_O, Library_Open_doc}, {"Close", ( PyCFunction ) M_Library_Close, METH_NOARGS, Library_Close_doc}, {"GetName", ( PyCFunction ) M_Library_GetName, METH_NOARGS, Library_GetName_doc}, {"Update", ( PyCFunction ) M_Library_Update, METH_NOARGS, Library_Update_doc}, - {"Datablocks", M_Library_Datablocks, METH_VARARGS, + {"Datablocks", M_Library_Datablocks, METH_O, Library_Datablocks_doc}, {"Load", oldM_Library_Load, METH_VARARGS, Library_Load_doc}, {"LinkableGroups", ( PyCFunction ) M_Library_LinkableGroups, @@ -147,9 +147,9 @@ struct PyMethodDef oldM_Library_methods[] = { * Only one can be open at a time, so this function also closes * the previously opened file, if any. */ -static PyObject *M_Library_Open( PyObject * self, PyObject * args ) +static PyObject *M_Library_Open( PyObject * self, PyObject * value ) { - char *fname = NULL; + char *fname = PyString_AsString(value); char filename[FILE_MAXDIR+FILE_MAXFILE]; char fname1[FILE_MAXDIR+FILE_MAXFILE]; @@ -157,7 +157,7 @@ static PyObject *M_Library_Open( PyObject * self, PyObject * args ) bpy_relative= 0; /* assume non relative each time we load */ - if( !PyArg_ParseTuple( args, "s", &fname ) ) { + if( !fname ) { return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a .blend filename" ); } @@ -244,9 +244,9 @@ static PyObject *M_Library_GetName( PyObject * self ) * Return a list with all items of a given datablock type * (like 'Object', 'Mesh', etc.) in the open library file. */ -static PyObject *M_Library_Datablocks( PyObject * self, PyObject * args ) +static PyObject *M_Library_Datablocks( PyObject * self, PyObject * value ) { - char *name = NULL; + char *name = PyString_AsString(value); int blocktype = 0; LinkNode *l = NULL, *names = NULL; PyObject *list = NULL; @@ -256,7 +256,7 @@ static PyObject *M_Library_Datablocks( PyObject * self, PyObject * args ) "no library file: open one first with Blender.Lib_Open(filename)" ); } - if( !PyArg_ParseTuple( args, "s", &name ) ) { + if( !name ) { return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a string (datablock type) as argument." ); } @@ -526,13 +526,13 @@ static PyObject *CreatePyObject_LibData( int idtype, int kind, * which can be linked/appended to a scene. */ -static PyObject *lib_link_or_append( BPy_LibraryData *self, PyObject * args, +static PyObject *lib_link_or_append( BPy_LibraryData *self, PyObject * value, int mode ) { - char *name; + char *name = PyString_AsString(value); /* get the name of the data used wants to append */ - if( !PyArg_ParseTuple( args, "s", &name ) ) + if( !name ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a string" ); @@ -672,16 +672,16 @@ PyObject *LibraryData_importLibData( BPy_LibraryData *self, char *name, /* .append(): make a local copy of the library's data (except for objects) */ -static PyObject *LibraryData_getAppend( BPy_LibraryData *self, PyObject * args) +static PyObject *LibraryData_getAppend( BPy_LibraryData *self, PyObject * value) { - return lib_link_or_append( self, args, OBJECT_IS_APPEND ); + return lib_link_or_append( self, value, OBJECT_IS_APPEND ); } /* .link(): make a link to the library's data (except for objects) */ -static PyObject *LibraryData_getLink( BPy_LibraryData *self, PyObject * args) +static PyObject *LibraryData_getLink( BPy_LibraryData *self, PyObject * value) { - return lib_link_or_append( self, args, OBJECT_IS_LINK ); + return lib_link_or_append( self, value, OBJECT_IS_LINK ); } /************************************************************************ @@ -745,9 +745,9 @@ static PyObject *LibraryData_nextIter( BPy_LibraryData * self ) ************************************************************************/ static struct PyMethodDef BPy_LibraryData_methods[] = { - {"append", (PyCFunction)LibraryData_getAppend, METH_VARARGS, + {"append", (PyCFunction)LibraryData_getAppend, METH_O, "(str) - create new data from library"}, - {"link", (PyCFunction)LibraryData_getLink, METH_VARARGS, + {"link", (PyCFunction)LibraryData_getLink, METH_O, "(str) - link data from library"}, {NULL, NULL, 0, NULL} }; @@ -1060,12 +1060,12 @@ static PyGetSetDef Library_getseters[] = { * actually accessed later. */ -static PyObject *M_Library_Load(PyObject *self, PyObject * args) +static PyObject *M_Library_Load(PyObject *self, PyObject * value) { - char *filename; + char *filename = PyString_AsString(value); BPy_Library *lib; - if( !PyArg_ParseTuple( args, "s", &filename ) ) + if( !filename ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a string" ); @@ -1081,7 +1081,7 @@ static PyObject *M_Library_Load(PyObject *self, PyObject * args) } static struct PyMethodDef M_Library_methods[] = { - {"load", (PyCFunction)M_Library_Load, METH_VARARGS, + {"load", (PyCFunction)M_Library_Load, METH_O, "(string) - declare a .blend file for use as a library"}, {NULL, NULL, 0, NULL} }; diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c index 019c3d750b9..21200882a7f 100644 --- a/source/blender/python/api2_2x/Material.c +++ b/source/blender/python/api2_2x/Material.c @@ -621,9 +621,9 @@ static PyObject *Material_getTextures( BPy_Material * self ); static PyObject *Material_clearIpo( BPy_Material * self ); static PyObject *Material_setTexture( BPy_Material * self, PyObject * args ); -static PyObject *Material_clearTexture( BPy_Material * self, PyObject * args ); +static PyObject *Material_clearTexture( BPy_Material * self, PyObject * value ); -static PyObject *Material_getScriptLinks(BPy_Material *self, PyObject * args ); +static PyObject *Material_getScriptLinks(BPy_Material *self, PyObject * value ); static PyObject *Material_addScriptLink(BPy_Material * self, PyObject * args ); static PyObject *Material_clearScriptLinks(BPy_Material *self, PyObject *args); @@ -840,10 +840,9 @@ static PyMethodDef BPy_Material_methods[] = { "(f) - Set fresnel power for refractions factor- [0.0, 5.0]"}, {"setTexture", ( PyCFunction ) Material_setTexture, METH_VARARGS, "(n,tex,texco=0,mapto=0) - Set numbered texture to tex"}, - {"clearTexture", ( PyCFunction ) Material_clearTexture, METH_VARARGS, + {"clearTexture", ( PyCFunction ) Material_clearTexture, METH_O, "(n) - Remove texture from numbered slot"}, - {"getScriptLinks", ( PyCFunction ) Material_getScriptLinks, - METH_VARARGS, + {"getScriptLinks", ( PyCFunction ) Material_getScriptLinks, METH_O, "(eventname) - Get a list of this material's scriptlinks (Text names) " "of the given type\n" "(eventname) - string: FrameChanged, Redraw or Render."}, @@ -2548,14 +2547,11 @@ static PyObject *Material_setTexture( BPy_Material * self, PyObject * args ) Py_RETURN_NONE; } -static PyObject *Material_clearTexture( BPy_Material * self, PyObject * args ) +static PyObject *Material_clearTexture( BPy_Material * self, PyObject * value ) { - int texnum; + int texnum = (int)PyInt_AsLong(value); struct MTex *mtex; - - if( !PyArg_ParseTuple( args, "i", &texnum ) ) - return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected int in [0,9]" ); + /* non ints will be -1 */ if( ( texnum < 0 ) || ( texnum >= MAX_MTEX ) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected int in [0,9]" ); @@ -2595,7 +2591,7 @@ static PyObject *Material_clearScriptLinks(BPy_Material *self, PyObject *args ) /* mat.getScriptLinks */ static PyObject *Material_getScriptLinks( BPy_Material * self, - PyObject * args ) + PyObject * value ) { Material *mat = self->material; ScriptLink *slink = NULL; @@ -2606,7 +2602,7 @@ static PyObject *Material_getScriptLinks( BPy_Material * self, /* can't this just return? EXP_getScriptLinks() returns a PyObject* * or NULL anyway */ - ret = EXPP_getScriptLinks( slink, args, 0 ); + ret = EXPP_getScriptLinks( slink, value, 0 ); if( ret ) return ret; diff --git a/source/blender/python/api2_2x/Mathutils.c b/source/blender/python/api2_2x/Mathutils.c index 35db6bfcadf..bac9d6038ca 100644 --- a/source/blender/python/api2_2x/Mathutils.c +++ b/source/blender/python/api2_2x/Mathutils.c @@ -59,7 +59,7 @@ static char M_Mathutils_ScaleMatrix_doc[] = "() - construct a scaling matrix fro static char M_Mathutils_OrthoProjectionMatrix_doc[] = "() - construct a orthographic projection matrix from a selected plane"; static char M_Mathutils_ShearMatrix_doc[] = "() - construct a shearing matrix from a plane of shear and a shear factor"; static char M_Mathutils_CopyMat_doc[] = "() - create a copy of a matrix"; -static char M_Mathutils_TranslationMatrix_doc[] = "() - create a translation matrix from a vector"; +static char M_Mathutils_TranslationMatrix_doc[] = "(vec) - create a translation matrix from a vector"; static char M_Mathutils_CopyQuat_doc[] = "() - copy quatB to quatA"; static char M_Mathutils_CopyEuler_doc[] = "() - copy eulB to eultA"; static char M_Mathutils_CrossQuats_doc[] = "() - return the mutliplication of two quaternions"; @@ -88,7 +88,7 @@ struct PyMethodDef M_Mathutils_methods[] = { {"RotationMatrix", (PyCFunction) M_Mathutils_RotationMatrix, METH_VARARGS, M_Mathutils_RotationMatrix_doc}, {"ScaleMatrix", (PyCFunction) M_Mathutils_ScaleMatrix, METH_VARARGS, M_Mathutils_ScaleMatrix_doc}, {"ShearMatrix", (PyCFunction) M_Mathutils_ShearMatrix, METH_VARARGS, M_Mathutils_ShearMatrix_doc}, - {"TranslationMatrix", (PyCFunction) M_Mathutils_TranslationMatrix, METH_VARARGS, M_Mathutils_TranslationMatrix_doc}, + {"TranslationMatrix", (PyCFunction) M_Mathutils_TranslationMatrix, METH_O, M_Mathutils_TranslationMatrix_doc}, {"CopyMat", (PyCFunction) M_Mathutils_CopyMat, METH_VARARGS, M_Mathutils_CopyMat_doc}, {"OrthoProjectionMatrix", (PyCFunction) M_Mathutils_OrthoProjectionMatrix, METH_VARARGS, M_Mathutils_OrthoProjectionMatrix_doc}, {"MatMultVec", (PyCFunction) M_Mathutils_MatMultVec, METH_VARARGS, M_Mathutils_MatMultVec_doc}, @@ -773,13 +773,12 @@ PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args) } //----------------------------------Mathutils.TranslationMatrix() ------- //creates a translation matrix -PyObject *M_Mathutils_TranslationMatrix(PyObject * self, PyObject * args) +PyObject *M_Mathutils_TranslationMatrix(PyObject * self, VectorObject * vec) { - VectorObject *vec = NULL; float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; - - if(!PyArg_ParseTuple(args, "O!", &vector_Type, &vec)) { + + if(!VectorObject_Check(vec)) { return EXPP_ReturnPyObjError(PyExc_TypeError, "Mathutils.TranslationMatrix(): expected vector\n"); } diff --git a/source/blender/python/api2_2x/Mathutils.h b/source/blender/python/api2_2x/Mathutils.h index 84890267ed2..901cb2139d7 100644 --- a/source/blender/python/api2_2x/Mathutils.h +++ b/source/blender/python/api2_2x/Mathutils.h @@ -57,7 +57,7 @@ PyObject *M_Mathutils_MidpointVecs(PyObject * self, PyObject * args); PyObject *M_Mathutils_ProjectVecs(PyObject * self, PyObject * args); PyObject *M_Mathutils_Matrix(PyObject * self, PyObject * args); PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args); -PyObject *M_Mathutils_TranslationMatrix(PyObject * self, PyObject * args); +PyObject *M_Mathutils_TranslationMatrix(PyObject * self, VectorObject * value); PyObject *M_Mathutils_ScaleMatrix(PyObject * self, PyObject * args); PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject * self, PyObject * args); PyObject *M_Mathutils_ShearMatrix(PyObject * self, PyObject * args); diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index bd79c2878d9..b76a8cf236f 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -1247,13 +1247,13 @@ static PyObject *Mesh_addPropLayer_internal(Mesh *mesh, CustomData *data, int to Py_RETURN_NONE; } -static PyObject *Mesh_removePropLayer_internal(Mesh *mesh, CustomData *data, int tot,PyObject *args) +static PyObject *Mesh_removePropLayer_internal(Mesh *mesh, CustomData *data, int tot,PyObject *value) { CustomDataLayer *layer; - char *name=NULL; + char *name=PyString_AsString(value); int i; - if( !PyArg_ParseTuple( args, "s", &name ) ) + if( !name ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); @@ -1318,16 +1318,16 @@ static PyObject *Mesh_propList_internal(CustomData *data) return list; } -static PyObject *Mesh_getProperty_internal(CustomData *data, int eindex, PyObject *args) +static PyObject *Mesh_getProperty_internal(CustomData *data, int eindex, PyObject *value) { CustomDataLayer *layer; - char *name=NULL; + char *name=PyString_AsString(value); int i; MFloatProperty *pf; MIntProperty *pi; MStringProperty *ps; - if(!PyArg_ParseTuple(args, "s", &name)) + if(!name) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected an string argument" ); @@ -2193,10 +2193,10 @@ static PyObject *MVertSeq_add_layertype(BPy_MVertSeq *self, PyObject *args) Mesh *me = (Mesh*)self->mesh; return Mesh_addPropLayer_internal(me, &(me->vdata), me->totvert, args); } -static PyObject *MVertSeq_del_layertype(BPy_MVertSeq *self, PyObject *args) +static PyObject *MVertSeq_del_layertype(BPy_MVertSeq *self, PyObject *value) { Mesh *me = (Mesh*)self->mesh; - return Mesh_removePropLayer_internal(me, &(me->vdata), me->totvert, args); + return Mesh_removePropLayer_internal(me, &(me->vdata), me->totvert, value); } static PyObject *MVertSeq_rename_layertype(BPy_MVertSeq *self, PyObject *args) { @@ -2229,7 +2229,7 @@ static struct PyMethodDef BPy_MVertSeq_methods[] = { "returns a list containing indices of selected vertices"}, {"addPropertyLayer",(PyCFunction)MVertSeq_add_layertype, METH_VARARGS, "add a new property layer"}, - {"removePropertyLayer",(PyCFunction)MVertSeq_del_layertype, METH_VARARGS, + {"removePropertyLayer",(PyCFunction)MVertSeq_del_layertype, METH_O, "removes a property layer"}, {"renamePropertyLayer",(PyCFunction)MVertSeq_rename_layertype, METH_VARARGS, "renames an existing property layer"}, @@ -3614,10 +3614,10 @@ static PyObject *MEdgeSeq_add_layertype(BPy_MEdgeSeq *self, PyObject *args) Mesh *me = (Mesh*)self->mesh; return Mesh_addPropLayer_internal(me, &(me->edata), me->totedge, args); } -static PyObject *MEdgeSeq_del_layertype(BPy_MEdgeSeq *self, PyObject *args) +static PyObject *MEdgeSeq_del_layertype(BPy_MEdgeSeq *self, PyObject *value) { Mesh *me = (Mesh*)self->mesh; - return Mesh_removePropLayer_internal(me, &(me->edata), me->totedge, args); + return Mesh_removePropLayer_internal(me, &(me->edata), me->totedge, value); } static PyObject *MEdgeSeq_rename_layertype(BPy_MEdgeSeq *self, PyObject *args) { @@ -3642,7 +3642,7 @@ static struct PyMethodDef BPy_MEdgeSeq_methods[] = { "collapse one or more edges to a vertex"}, {"addPropertyLayer",(PyCFunction)MEdgeSeq_add_layertype, METH_VARARGS, "add a new property layer"}, - {"removePropertyLayer",(PyCFunction)MEdgeSeq_del_layertype, METH_VARARGS, + {"removePropertyLayer",(PyCFunction)MEdgeSeq_del_layertype, METH_O, "removes a property layer"}, {"renamePropertyLayer",(PyCFunction)MEdgeSeq_rename_layertype, METH_VARARGS, "renames an existing property layer"}, @@ -5611,10 +5611,10 @@ static PyObject *MFaceSeq_add_layertype(BPy_MFaceSeq *self, PyObject *args) Mesh *me = (Mesh*)self->mesh; return Mesh_addPropLayer_internal(me, &(me->fdata), me->totface, args); } -static PyObject *MFaceSeq_del_layertype(BPy_MFaceSeq *self, PyObject *args) +static PyObject *MFaceSeq_del_layertype(BPy_MFaceSeq *self, PyObject *value) { Mesh *me = (Mesh*)self->mesh; - return Mesh_removePropLayer_internal(me, &(me->fdata), me->totface, args); + return Mesh_removePropLayer_internal(me, &(me->fdata), me->totface, value); } static PyObject *MFaceSeq_rename_layertype(BPy_MFaceSeq *self, PyObject *args) { @@ -5636,7 +5636,7 @@ static struct PyMethodDef BPy_MFaceSeq_methods[] = { "returns a list containing indices of selected faces"}, {"addPropertyLayer",(PyCFunction)MFaceSeq_add_layertype, METH_VARARGS, "add a new property layer"}, - {"removePropertyLayer",(PyCFunction)MFaceSeq_del_layertype, METH_VARARGS, + {"removePropertyLayer",(PyCFunction)MFaceSeq_del_layertype, METH_O, "removes a property layer"}, {"renamePropertyLayer",(PyCFunction)MFaceSeq_rename_layertype, METH_VARARGS, "renames an existing property layer"}, @@ -6325,21 +6325,21 @@ static PyObject *Mesh_transform( BPy_Mesh *self, PyObject *args, PyObject *kwd ) Py_RETURN_NONE; } -static PyObject *Mesh_addVertGroup( PyObject * self, PyObject * args ) +static PyObject *Mesh_addVertGroup( PyObject * self, PyObject * value ) { - char *groupStr; + char *groupStr = PyString_AsString(value); struct Object *object; - if( !PyArg_ParseTuple( args, "s", &groupStr ) ) + if( !groupStr ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); - if( ( ( BPy_Mesh * ) self )->object == NULL ) + object = ( ( BPy_Mesh * ) self )->object; + + if( object == NULL ) return EXPP_ReturnPyObjError( PyExc_AttributeError, "mesh not linked to an object" ); - object = ( ( BPy_Mesh * ) self )->object; - /* add_defgroup_name clamps the name to 32, make sure that dosnt change */ add_defgroup_name( object, groupStr ); @@ -6348,14 +6348,14 @@ static PyObject *Mesh_addVertGroup( PyObject * self, PyObject * args ) Py_RETURN_NONE; } -static PyObject *Mesh_removeVertGroup( PyObject * self, PyObject * args ) +static PyObject *Mesh_removeVertGroup( PyObject * self, PyObject * value ) { - char *groupStr; + char *groupStr = PyString_AsString(value); struct Object *object; int nIndex; bDeformGroup *pGroup; - if( !PyArg_ParseTuple( args, "s", &groupStr ) ) + if( !groupStr ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); @@ -6842,14 +6842,14 @@ static PyObject *Mesh_addColorLayer( BPy_Mesh * self, PyObject * args ) return Mesh_addCustomLayer_internal(self->mesh, args, CD_MCOL); } -static PyObject *Mesh_removeLayer_internal( BPy_Mesh * self, PyObject * args, int type ) +static PyObject *Mesh_removeLayer_internal( BPy_Mesh * self, PyObject * value, int type ) { Mesh *me = self->mesh; CustomData *data = &me->fdata; - char *name; + char *name = PyString_AsString(value); int i; - if( !PyArg_ParseTuple( args, "s", &name ) ) + if( !name ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); @@ -6881,14 +6881,14 @@ static PyObject *Mesh_removeLayer_internal( BPy_Mesh * self, PyObject * args, in } -static PyObject *Mesh_removeUVLayer( BPy_Mesh * self, PyObject * args ) +static PyObject *Mesh_removeUVLayer( BPy_Mesh * self, PyObject * value ) { - return Mesh_removeLayer_internal(self, args, CD_MTFACE); + return Mesh_removeLayer_internal(self, value, CD_MTFACE); } -static PyObject *Mesh_removeColorLayer( BPy_Mesh * self, PyObject * args ) +static PyObject *Mesh_removeColorLayer( BPy_Mesh * self, PyObject * value ) { - return Mesh_removeLayer_internal(self, args, CD_MCOL); + return Mesh_removeLayer_internal(self, value, CD_MCOL); } @@ -7346,18 +7346,17 @@ static short pointInside_internal(float *vec, float *v1, float *v2, float *v3 ) return 0; } -static PyObject *Mesh_pointInside( BPy_Mesh * self, PyObject *args ) +static PyObject *Mesh_pointInside( BPy_Mesh * self, VectorObject * vec ) { - VectorObject *vec = NULL; Mesh *mesh = self->mesh; MFace *mf = mesh->mface; MVert *mvert = mesh->mvert; int i; int isect_count=0; - if(!PyArg_ParseTuple(args, "O!", &vector_Type, &vec)) + if(!VectorObject_Check(vec)) return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected one or 2 vector types" ); + "expected one vector type" ); if(vec->size < 3) return EXPP_ReturnPyObjError(PyExc_AttributeError, @@ -7412,9 +7411,9 @@ static struct PyMethodDef BPy_Mesh_methods[] = { "Update display lists after changes to mesh"}, {"transform", (PyCFunction)Mesh_transform, METH_VARARGS | METH_KEYWORDS, "Applies a transformation matrix to mesh's vertices"}, - {"addVertGroup", (PyCFunction)Mesh_addVertGroup, METH_VARARGS, + {"addVertGroup", (PyCFunction)Mesh_addVertGroup, METH_O, "Assign vertex group name to the object linked to the mesh"}, - {"removeVertGroup", (PyCFunction)Mesh_removeVertGroup, METH_VARARGS, + {"removeVertGroup", (PyCFunction)Mesh_removeVertGroup, METH_O, "Delete vertex group name from the object linked to the mesh"}, {"assignVertsToGroup", (PyCFunction)Mesh_assignVertsToGroup, METH_VARARGS, "Assigns vertices to a vertex group"}, @@ -7452,7 +7451,7 @@ static struct PyMethodDef BPy_Mesh_methods[] = { "Removes duplicates from selected vertices (experimental)"}, {"recalcNormals", (PyCFunction)Mesh_recalcNormals, METH_VARARGS, "Recalculates inside or outside normals (experimental)"}, - {"pointInside", (PyCFunction)Mesh_pointInside, METH_VARARGS, + {"pointInside", (PyCFunction)Mesh_pointInside, METH_O, "Recalculates inside or outside normals (experimental)"}, /* mesh custom data layers */ @@ -7460,9 +7459,9 @@ static struct PyMethodDef BPy_Mesh_methods[] = { "adds a UV layer to this mesh"}, {"addColorLayer", (PyCFunction)Mesh_addColorLayer, METH_VARARGS, "adds a color layer to this mesh "}, - {"removeUVLayer", (PyCFunction)Mesh_removeUVLayer, METH_VARARGS, + {"removeUVLayer", (PyCFunction)Mesh_removeUVLayer, METH_O, "removes a UV layer to this mesh"}, - {"removeColorLayer", (PyCFunction)Mesh_removeColorLayer, METH_VARARGS, + {"removeColorLayer", (PyCFunction)Mesh_removeColorLayer, METH_O, "removes a color layer to this mesh"}, {"getUVLayerNames", (PyCFunction)Mesh_getUVLayerNames, METH_NOARGS, "Get names of UV layers"}, diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c index aeb935c72e1..b8d3bd3dba0 100644 --- a/source/blender/python/api2_2x/Metaball.c +++ b/source/blender/python/api2_2x/Metaball.c @@ -1066,12 +1066,11 @@ static PyObject *MetaElemSeq_add( BPy_MetaElemSeq * self ) * no args are taken so the returned metaball must be modified after adding. * Accessed as mball.elements.add() where mball is a python metaball data type. */ -static PyObject *MetaElemSeq_remove( BPy_MetaElemSeq * self, PyObject *args ) +static PyObject *MetaElemSeq_remove( BPy_MetaElemSeq * self, BPy_Metaelem *elem ) { - BPy_Metaelem *elem; MetaElem *ml_iter, *ml_py; - if( !PyArg_ParseTuple( args, "O!", &Metaelem_Type, &elem) ) + if( !BPy_Metaelem_Check(elem) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "elements.remove(metaelem) - expected a Metaball element" ); @@ -1095,7 +1094,7 @@ static PyObject *MetaElemSeq_remove( BPy_MetaElemSeq * self, PyObject *args ) static struct PyMethodDef BPy_MetaElemSeq_methods[] = { {"add", (PyCFunction)MetaElemSeq_add, METH_NOARGS, "add metaelem to metaball data"}, - {"remove", (PyCFunction)MetaElemSeq_remove, METH_VARARGS, + {"remove", (PyCFunction)MetaElemSeq_remove, METH_O, "remove element from metaball data"}, {NULL, NULL, 0, NULL} }; diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 9be64fc72a6..73859bedcdd 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -394,7 +394,7 @@ static PyObject *Object_getProperty( BPy_Object * self, PyObject * args ); static PyObject *Object_removeAllProperties( BPy_Object * self ); static PyObject *Object_copyAllPropertiesTo( BPy_Object * self, PyObject * args ); -static PyObject *Object_getScriptLinks( BPy_Object * self, PyObject * args ); +static PyObject *Object_getScriptLinks( BPy_Object * self, PyObject * value ); static PyObject *Object_addScriptLink( BPy_Object * self, PyObject * args ); static PyObject *Object_clearScriptLinks( BPy_Object * self, PyObject *args ); static PyObject *Object_getPIStrength( BPy_Object * self ); @@ -744,7 +744,7 @@ works only if self and the object specified are of the same type."}, {"copyAllPropertiesTo", ( PyCFunction ) Object_copyAllPropertiesTo, METH_VARARGS, "() - copy all properties from this object to another object"}, - {"getScriptLinks", ( PyCFunction ) Object_getScriptLinks, METH_VARARGS, + {"getScriptLinks", ( PyCFunction ) Object_getScriptLinks, METH_O, "(eventname) - Get a list of this object's scriptlinks (Text names) " "of the given type\n" "(eventname) - string: FrameChanged, Redraw or Render."}, @@ -2929,11 +2929,11 @@ static PyObject *Object_clearScriptLinks( BPy_Object * self, PyObject * args ) return EXPP_clearScriptLinks( slink, args ); } -static PyObject *Object_getScriptLinks( BPy_Object * self, PyObject * args ) +static PyObject *Object_getScriptLinks( BPy_Object * self, PyObject * value ) { Object *obj = self->object; ScriptLink *slink = &obj->scriptlink; - return EXPP_getScriptLinks( slink, args, 0 ); + return EXPP_getScriptLinks( slink, value, 0 ); } static PyObject *Object_getNLAflagBits ( BPy_Object * self ) diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c index fd139c4fe6e..3bb509eb070 100644 --- a/source/blender/python/api2_2x/Scene.c +++ b/source/blender/python/api2_2x/Scene.c @@ -145,7 +145,7 @@ static PyObject *Scene_getCurrentCamera( BPy_Scene * self ); static PyObject *Scene_setCurrentCamera( BPy_Scene * self, PyObject * args ); static PyObject *Scene_getRenderingContext( BPy_Scene * self ); static PyObject *Scene_getRadiosityContext( BPy_Scene * self ); -static PyObject *Scene_getScriptLinks( BPy_Scene * self, PyObject * args ); +static PyObject *Scene_getScriptLinks( BPy_Scene * self, PyObject * value ); static PyObject *Scene_getSequence( BPy_Scene * self ); static PyObject *Scene_addScriptLink( BPy_Scene * self, PyObject * args ); static PyObject *Scene_clearScriptLinks( BPy_Scene * self, PyObject * args ); @@ -194,7 +194,7 @@ static PyMethodDef BPy_Scene_methods[] = { {"getCurrentCamera", ( PyCFunction ) Scene_getCurrentCamera, METH_NOARGS, "() - Return current active Camera"}, - {"getScriptLinks", ( PyCFunction ) Scene_getScriptLinks, METH_VARARGS, + {"getScriptLinks", ( PyCFunction ) Scene_getScriptLinks, METH_O, "(eventname) - Get a list of this scene's scriptlinks (Text names) " "of the given type\n" "(eventname) - string: FrameChanged, OnLoad, OnSave, Redraw or Render."}, @@ -1109,7 +1109,7 @@ static PyObject *Scene_clearScriptLinks( BPy_Scene * self, PyObject * args ) } /* scene.getScriptLinks */ -static PyObject *Scene_getScriptLinks( BPy_Scene * self, PyObject * args ) +static PyObject *Scene_getScriptLinks( BPy_Scene * self, PyObject * value ) { Scene *scene = self->scene; ScriptLink *slink = NULL; @@ -1119,7 +1119,7 @@ static PyObject *Scene_getScriptLinks( BPy_Scene * self, PyObject * args ) slink = &( scene )->scriptlink; - ret = EXPP_getScriptLinks( slink, args, 1 ); + ret = EXPP_getScriptLinks( slink, value, 1 ); if( ret ) return ret; diff --git a/source/blender/python/api2_2x/Text3d.c b/source/blender/python/api2_2x/Text3d.c index 4e860113ac8..695f84728c7 100644 --- a/source/blender/python/api2_2x/Text3d.c +++ b/source/blender/python/api2_2x/Text3d.c @@ -83,7 +83,7 @@ static PyObject *generate_ModuleIntConstant(char *name, int value); struct PyMethodDef M_Text3d_methods[] = { {"New", ( PyCFunction ) M_Text3d_New, METH_VARARGS, NULL}, {"Get", ( PyCFunction ) M_Text3d_Get, METH_VARARGS, NULL}, - {"LoadFont", ( PyCFunction ) M_Text3d_LoadFont, METH_VARARGS, NULL}, + {"LoadFont", ( PyCFunction ) M_Text3d_LoadFont, METH_O, NULL}, {NULL, NULL, 0, NULL} }; @@ -1173,13 +1173,13 @@ static PyObject *Text3d_removeFrame( BPy_Text3d * self, PyObject * args ) } -PyObject *M_Text3d_LoadFont( PyObject * self, PyObject * args ) +PyObject *M_Text3d_LoadFont( PyObject * self, PyObject * value ) { - char *fontfile= NULL; + char *fontfile= PyString_AsString(value); FILE *file= NULL; VFont *vf= NULL; - if( !PyArg_ParseTuple( args, "s", &fontfile ) ) + if( !fontfile ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a string" ); vf= exist_vfont(fontfile); diff --git a/source/blender/python/api2_2x/World.c b/source/blender/python/api2_2x/World.c index ec73caa962b..aa956e15ebb 100644 --- a/source/blender/python/api2_2x/World.c +++ b/source/blender/python/api2_2x/World.c @@ -98,7 +98,7 @@ static int World_setStar( BPy_World * self, PyObject * args ); static PyObject *World_getMist( BPy_World * self ); static PyObject *World_oldsetMist( BPy_World * self, PyObject * args ); static int World_setMist( BPy_World * self, PyObject * args ); -static PyObject *World_getScriptLinks( BPy_World * self, PyObject * args ); +static PyObject *World_getScriptLinks( BPy_World * self, PyObject * value ); static PyObject *World_addScriptLink( BPy_World * self, PyObject * args ); static PyObject *World_clearScriptLinks( BPy_World * self, PyObject * args ); static PyObject *World_setCurrent( BPy_World * self ); @@ -209,7 +209,7 @@ static PyMethodDef BPy_World_methods[] = { "() - Return World Data mist"}, {"setMist", ( PyCFunction ) World_oldsetMist, METH_VARARGS, "() - Return World Data mist"}, - {"getScriptLinks", ( PyCFunction ) World_getScriptLinks, METH_VARARGS, + {"getScriptLinks", ( PyCFunction ) World_getScriptLinks, METH_O, "(eventname) - Get a list of this world's scriptlinks (Text names) " "of the given type\n" "(eventname) - string: FrameChanged, Redraw or Render."}, @@ -874,7 +874,7 @@ static PyObject *World_clearScriptLinks( BPy_World * self, PyObject * args ) } /* world.getScriptLinks */ -static PyObject *World_getScriptLinks( BPy_World * self, PyObject * args ) +static PyObject *World_getScriptLinks( BPy_World * self, PyObject * value ) { World *world = self->world; ScriptLink *slink = NULL; @@ -882,7 +882,7 @@ static PyObject *World_getScriptLinks( BPy_World * self, PyObject * args ) slink = &( world )->scriptlink; - ret = EXPP_getScriptLinks( slink, args, 0 ); + ret = EXPP_getScriptLinks( slink, value, 0 ); if( ret ) return ret; diff --git a/source/blender/python/api2_2x/bpy_data.c b/source/blender/python/api2_2x/bpy_data.c index d2cd650a814..63aae24afec 100644 --- a/source/blender/python/api2_2x/bpy_data.c +++ b/source/blender/python/api2_2x/bpy_data.c @@ -593,21 +593,15 @@ PyObject *LibBlockSeq_new(BPy_LibBlockSeq *self, PyObject * args, PyObject *kwd) } -PyObject *LibBlockSeq_unlink(BPy_LibBlockSeq *self, PyObject * args) +PyObject *LibBlockSeq_unlink(BPy_LibBlockSeq *self, PyObject * value) { - PyObject *pyobj; - switch (self->type) { case ID_SCE: - if( !PyArg_ParseTuple( args, "O!", &Scene_Type, &pyobj ) ) { + if( !BPy_Scene_Check(value) ) { return EXPP_ReturnPyObjError( PyExc_TypeError, "expected Scene object" ); } else { - BPy_Scene *bpydata; - Scene *data; - - bpydata = (BPy_Scene *)pyobj; - data = bpydata->scene; + Scene *data = ((BPy_Scene *)value)->scene; if (!data) return EXPP_ReturnPyObjError( PyExc_RuntimeError, @@ -615,20 +609,15 @@ PyObject *LibBlockSeq_unlink(BPy_LibBlockSeq *self, PyObject * args) /* Run the removal code */ free_libblock( &G.main->scene, data ); - bpydata->scene= NULL; - + ((BPy_Scene *)value)->scene = NULL; Py_RETURN_NONE; } case ID_GR: - if( !PyArg_ParseTuple( args, "O!", &Group_Type, &pyobj ) ) { + if( !BPy_Group_Check(value) ) { return EXPP_ReturnPyObjError( PyExc_TypeError, "expected Group object" ); } else { - BPy_Group *bpydata; - Group *data; - - bpydata = (BPy_Group *)pyobj; - data = bpydata->group; + Group *data = ((BPy_Group *)value)->group; if (!data) return EXPP_ReturnPyObjError( PyExc_RuntimeError, @@ -639,20 +628,17 @@ PyObject *LibBlockSeq_unlink(BPy_LibBlockSeq *self, PyObject * args) unlink_group(data); data->id.us= 0; free_libblock( &G.main->group, data ); - bpydata->group= NULL; + ((BPy_Group *)value)->group = NULL; Py_RETURN_NONE; } case ID_TXT: - if( !PyArg_ParseTuple( args, "O!", &Text_Type, &pyobj ) ) { + if( !BPy_Text_Check(value) ) { return EXPP_ReturnPyObjError( PyExc_TypeError, "expected Text object" ); } else { - BPy_Text *bpydata; - Text *data; - bpydata = (BPy_Text *)pyobj; - data = bpydata->text; + Text *data = ((BPy_Text *)value)->text; if (!data) return EXPP_ReturnPyObjError( PyExc_RuntimeError, @@ -663,7 +649,7 @@ PyObject *LibBlockSeq_unlink(BPy_LibBlockSeq *self, PyObject * args) free_text_controllers( data ); unlink_text( data ); free_libblock( &G.main->text, data ); - bpydata->text = NULL; + ((BPy_Text *)value)->text = NULL; Py_RETURN_NONE; } @@ -701,7 +687,7 @@ static PyGetSetDef LibBlockSeq_getseters[] = { static struct PyMethodDef BPy_LibBlockSeq_methods[] = { {"new", (PyCFunction)LibBlockSeq_new, METH_VARARGS | METH_KEYWORDS, "(name) - Create a new object in this scene from the obdata given and return a new object"}, - {"unlink", (PyCFunction)LibBlockSeq_unlink, METH_VARARGS, + {"unlink", (PyCFunction)LibBlockSeq_unlink, METH_O, "unlinks the object from the scene"}, {NULL, NULL, 0, NULL} }; diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c index b60a699fe47..09f887fafb8 100644 --- a/source/blender/python/api2_2x/gen_utils.c +++ b/source/blender/python/api2_2x/gen_utils.c @@ -383,15 +383,15 @@ void EXPP_allqueue(unsigned short event, short val) /************************************************************************/ /* Scriptlink-related functions, used by scene, object, etc. bpyobjects */ /************************************************************************/ -PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * args, +PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * value, int is_scene ) { PyObject *list = NULL, *tmpstr; - char *eventname = NULL; + char *eventname = PyString_AsString(value); int i, event = 0; - if( !PyArg_ParseTuple( args, "s", &eventname ) ) + if( !eventname ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected event name (string) as argument" ); diff --git a/source/blender/python/api2_2x/gen_utils.h b/source/blender/python/api2_2x/gen_utils.h index 519c7ba9d22..39e3e96d9ec 100644 --- a/source/blender/python/api2_2x/gen_utils.h +++ b/source/blender/python/api2_2x/gen_utils.h @@ -161,7 +161,7 @@ PyObject *EXPP_setterWrapperTuple ( PyObject * self, PyObject * args, setter func); /* scriplinks-related: */ -PyObject *EXPP_getScriptLinks(ScriptLink *slink, PyObject *args, int is_scene); +PyObject *EXPP_getScriptLinks(ScriptLink *slink, PyObject *value, int is_scene); PyObject *EXPP_addScriptLink(ScriptLink *slink, PyObject *args, int is_scene); PyObject *EXPP_clearScriptLinks(ScriptLink *slink, PyObject *args); diff --git a/source/blender/python/api2_2x/logic.c b/source/blender/python/api2_2x/logic.c index f7e8e27c2f5..8630dcaf4f2 100644 --- a/source/blender/python/api2_2x/logic.c +++ b/source/blender/python/api2_2x/logic.c @@ -38,7 +38,7 @@ //--------------- Python BPy_Property methods declarations:--------------- static PyObject *Property_getName( BPy_Property * self ); -static PyObject *Property_setName( BPy_Property * self, PyObject * args ); +static PyObject *Property_setName( BPy_Property * self, PyObject * value ); static PyObject *Property_getData( BPy_Property * self ); static PyObject *Property_setData( BPy_Property * self, PyObject * args ); static PyObject *Property_getType( BPy_Property * self ); @@ -46,7 +46,7 @@ static PyObject *Property_getType( BPy_Property * self ); static PyMethodDef BPy_Property_methods[] = { {"getName", ( PyCFunction ) Property_getName, METH_NOARGS, "() - return Property name"}, - {"setName", ( PyCFunction ) Property_setName, METH_VARARGS, + {"setName", ( PyCFunction ) Property_setName, METH_O, "() - set the name of this Property"}, {"getData", ( PyCFunction ) Property_getData, METH_NOARGS, "() - return Property data"}, @@ -203,25 +203,25 @@ static PyObject *Property_getAttr( BPy_Property * self, char *name ) static int Property_setAttr( BPy_Property * self, char *name, PyObject * value ) { - PyObject *valtuple; PyObject *error = NULL; checkValidData_ptr( self ); - valtuple = Py_BuildValue( "(O)", value ); - if( !valtuple ) - return EXPP_ReturnIntError( PyExc_MemoryError, - "PropertySetAttr: couldn't create tuple" ); - if( strcmp( name, "name" ) == 0 ) - error = Property_setName( self, valtuple ); - else if( strcmp( name, "data" ) == 0 ) + if( strcmp( name, "name" ) == 0 ) { + error = Property_setName( self, value ); + } else if( strcmp( name, "data" ) == 0 ) { + PyObject *valtuple = Py_BuildValue( "(O)", value ); + if( !valtuple ) + return EXPP_ReturnIntError( PyExc_MemoryError, + "PropertySetAttr: couldn't create tuple" ); + error = Property_setData( self, valtuple ); - else { Py_DECREF( valtuple ); + } else { return ( EXPP_ReturnIntError ( PyExc_KeyError, "attribute not found" ) ); } - Py_DECREF( valtuple ); + if( error != Py_None ) return -1; @@ -395,11 +395,11 @@ static PyObject *Property_getName( BPy_Property * self ) } //--------------- BPy_Property.setName()---------------------------- -static PyObject *Property_setName( BPy_Property * self, PyObject * args ) +static PyObject *Property_setName( BPy_Property * self, PyObject * value ) { - char *name; + char *name = PyString_AsString(value); - if( !PyArg_ParseTuple( args, "s", &name ) ) + if( !name ) return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "expected string argument" ) ); -- cgit v1.2.3