diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-06-16 17:17:41 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-06-16 17:17:41 +0400 |
commit | 84749aa3ff39af08cdccfea462fb4a6a266ca7b8 (patch) | |
tree | 63954fcd3eb073fe8e057974f750c641b6d17bfd /source | |
parent | 3e490c020324dcd4d7a3a3acd62f48d3fd781afc (diff) |
Python API, more METH_VARARGS to METH_O
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/api2_2x/Constraint.c | 31 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Modifier.c | 45 | ||||
-rw-r--r-- | source/blender/python/api2_2x/NLA.c | 37 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Sound.c | 10 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Sys.c | 54 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Text.c | 20 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Text3d.c | 8 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Texture.c | 9 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Window.c | 10 | ||||
-rw-r--r-- | source/blender/python/api2_2x/windowTheme.c | 10 |
10 files changed, 113 insertions, 121 deletions
diff --git a/source/blender/python/api2_2x/Constraint.c b/source/blender/python/api2_2x/Constraint.c index 6ab0f861509..55e7e480d6b 100644 --- a/source/blender/python/api2_2x/Constraint.c +++ b/source/blender/python/api2_2x/Constraint.c @@ -1612,18 +1612,17 @@ static PySequenceMethods ConstraintSeq_as_sequence = { * helper function to check for a valid constraint argument */ -static bConstraint *locate_constr( BPy_ConstraintSeq *self, PyObject * args ) +static bConstraint *locate_constr( BPy_ConstraintSeq *self, BPy_Constraint * value ) { - BPy_Constraint *pyobj; bConstraint *con; /* check that argument is a modifier */ - if( !PyArg_ParseTuple( args, "O!", &Constraint_Type, &pyobj ) ) + if (!BPy_Constraint_Check(value)) return (bConstraint *)EXPP_ReturnPyObjError( PyExc_TypeError, "expected a constraint as an argument" ); /* check whether constraint has been removed */ - if( !pyobj->con ) + if( !value->con ) return (bConstraint *)EXPP_ReturnPyObjError( PyExc_RuntimeError, "This constraint has been removed!" ); @@ -1632,7 +1631,7 @@ static bConstraint *locate_constr( BPy_ConstraintSeq *self, PyObject * args ) con = self->pchan->constraints.first; else con = self->obj->constraints.first; - while( con && con != pyobj->con ) + while( con && con != value->con ) con = con->next; /* if we didn't find it, exception */ @@ -1670,9 +1669,9 @@ static PyObject *ConstraintSeq_append( BPy_ConstraintSeq *self, PyObject *value /* move the constraint up in the stack */ -static PyObject *ConstraintSeq_moveUp( BPy_ConstraintSeq *self, PyObject *args ) +static PyObject *ConstraintSeq_moveUp( BPy_ConstraintSeq *self, BPy_Constraint *value ) { - bConstraint *con = locate_constr( self, args ); + bConstraint *con = locate_constr( self, value ); /* if we can't locate the constraint, return (exception already set) */ if( !con ) @@ -1684,9 +1683,9 @@ static PyObject *ConstraintSeq_moveUp( BPy_ConstraintSeq *self, PyObject *args ) /* move the constraint down in the stack */ -static PyObject *ConstraintSeq_moveDown( BPy_ConstraintSeq *self, PyObject *args ) +static PyObject *ConstraintSeq_moveDown( BPy_ConstraintSeq *self, BPy_Constraint *value ) { - bConstraint *con = locate_constr( self, args ); + bConstraint *con = locate_constr( self, value ); /* if we can't locate the constraint, return (exception already set) */ if( !con ) @@ -1698,10 +1697,9 @@ static PyObject *ConstraintSeq_moveDown( BPy_ConstraintSeq *self, PyObject *args /* remove an existing constraint */ -static PyObject *ConstraintSeq_remove( BPy_ConstraintSeq *self, PyObject *args ) +static PyObject *ConstraintSeq_remove( BPy_ConstraintSeq *self, BPy_Constraint *value ) { - BPy_Constraint *pyobj; - bConstraint *con = locate_constr( self, args ); + bConstraint *con = locate_constr( self, value ); /* if we can't locate the constraint, return (exception already set) */ if( !con ) @@ -1715,8 +1713,7 @@ static PyObject *ConstraintSeq_remove( BPy_ConstraintSeq *self, PyObject *args ) del_constr_func( self->obj, con ); /* erase the link to the constraint */ - pyobj = ( BPy_Constraint * )PyTuple_GET_ITEM( args, 0 ); - pyobj->con = NULL; + value->con = NULL; Py_RETURN_NONE; } @@ -1738,11 +1735,11 @@ static PyMethodDef BPy_ConstraintSeq_methods[] = { /* name, method, flags, doc */ {"append", ( PyCFunction ) ConstraintSeq_append, METH_O, "(type) - add a new constraint, where type is the constraint type"}, - {"remove", ( PyCFunction ) ConstraintSeq_remove, METH_VARARGS, + {"remove", ( PyCFunction ) ConstraintSeq_remove, METH_O, "(con) - remove an existing constraint, where con is a constraint from this object."}, - {"moveUp", ( PyCFunction ) ConstraintSeq_moveUp, METH_VARARGS, + {"moveUp", ( PyCFunction ) ConstraintSeq_moveUp, METH_O, "(con) - Move constraint up in stack"}, - {"moveDown", ( PyCFunction ) ConstraintSeq_moveDown, METH_VARARGS, + {"moveDown", ( PyCFunction ) ConstraintSeq_moveDown, METH_O, "(con) - Move constraint down in stack"}, {NULL, NULL, 0, NULL} }; diff --git a/source/blender/python/api2_2x/Modifier.c b/source/blender/python/api2_2x/Modifier.c index 5a820ae4bdc..93f0f76af02 100644 --- a/source/blender/python/api2_2x/Modifier.c +++ b/source/blender/python/api2_2x/Modifier.c @@ -1261,24 +1261,23 @@ static PySequenceMethods ModSeq_as_sequence = { * helper function to check for a valid modifier argument */ -static ModifierData *locate_modifier( BPy_ModSeq *self, PyObject * args ) +static ModifierData *locate_modifier( BPy_ModSeq *self, BPy_Modifier * value ) { - BPy_Modifier *pyobj; ModifierData *md; /* check that argument is a modifier */ - if( !PyArg_ParseTuple( args, "O!", &Modifier_Type, &pyobj ) ) + if( !BPy_Modifier_Check(value) ) return (ModifierData *)EXPP_ReturnPyObjError( PyExc_TypeError, "expected an modifier as an argument" ); /* check whether modifier has been removed */ - if( !pyobj->md ) + if( !value->md ) return (ModifierData *)EXPP_ReturnPyObjError( PyExc_RuntimeError, "This modifier has been removed!" ); /* find the modifier in the object's list */ for( md = self->object->modifiers.first; md; md = md->next ) - if( md == pyobj->md ) + if( md == value->md ) return md; /* return exception if we can't find the modifier */ @@ -1288,18 +1287,14 @@ static ModifierData *locate_modifier( BPy_ModSeq *self, PyObject * args ) /* create a new modifier at the end of the list */ -static PyObject *ModSeq_append( BPy_ModSeq *self, PyObject *args ) +static PyObject *ModSeq_append( BPy_ModSeq *self, PyObject *value ) { - int type; - - if( !PyArg_ParseTuple( args, "i", &type ) ) - return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected int argument" ); - + int type = PyInt_AsLong(value); + /* type 0 is eModifierType_None, should we be able to add one of these? */ if( type <= 0 || type >= NUM_MODIFIER_TYPES ) return EXPP_ReturnPyObjError( PyExc_ValueError, - "int argument out of range, expected an int from Blender.Modifier.Type" ); + "Not an int or argument out of range, expected an int from Blender.Modifier.Type" ); BLI_addtail( &self->object->modifiers, modifier_new( type ) ); return Modifier_CreatePyObject( self->object, self->object->modifiers.last ); @@ -1307,10 +1302,9 @@ static PyObject *ModSeq_append( BPy_ModSeq *self, PyObject *args ) /* remove an existing modifier */ -static PyObject *ModSeq_remove( BPy_ModSeq *self, PyObject *args ) +static PyObject *ModSeq_remove( BPy_ModSeq *self, BPy_Modifier *value ) { - ModifierData *md = locate_modifier( self, args ); - BPy_Modifier *py_obj; + ModifierData *md = locate_modifier( self, value ); /* if we can't locate the modifier, return (exception already set) */ if( !md ) @@ -1321,17 +1315,16 @@ static PyObject *ModSeq_remove( BPy_ModSeq *self, PyObject *args ) modifier_free( md ); /* erase the link to the modifier */ - py_obj = ( BPy_Modifier * )PyTuple_GET_ITEM( args, 0 ); - py_obj->md = NULL; + value->md = NULL; Py_RETURN_NONE; } /* move the modifier up in the stack */ -static PyObject *ModSeq_moveUp( BPy_ModSeq * self, PyObject * args ) +static PyObject *ModSeq_moveUp( BPy_ModSeq * self, BPy_Modifier * value ) { - ModifierData *md = locate_modifier( self, args ); + ModifierData *md = locate_modifier( self, value ); /* if we can't locate the modifier, return (exception already set) */ if( !md ) @@ -1346,9 +1339,9 @@ static PyObject *ModSeq_moveUp( BPy_ModSeq * self, PyObject * args ) /* move the modifier down in the stack */ -static PyObject *ModSeq_moveDown( BPy_ModSeq * self, PyObject *args ) +static PyObject *ModSeq_moveDown( BPy_ModSeq * self, BPy_Modifier *value ) { - ModifierData *md = locate_modifier( self, args ); + ModifierData *md = locate_modifier( self, value ); /* if we can't locate the modifier, return (exception already set) */ if( !md ) @@ -1366,13 +1359,13 @@ static PyObject *ModSeq_moveDown( BPy_ModSeq * self, PyObject *args ) /*****************************************************************************/ static PyMethodDef BPy_ModSeq_methods[] = { /* name, method, flags, doc */ - {"append", ( PyCFunction ) ModSeq_append, METH_VARARGS, + {"append", ( PyCFunction ) ModSeq_append, METH_O, "(type) - add a new modifier, where type is the type of modifier"}, - {"remove", ( PyCFunction ) ModSeq_remove, METH_VARARGS, + {"remove", ( PyCFunction ) ModSeq_remove, METH_O, "(modifier) - remove an existing modifier, where modifier is a modifier from this object."}, - {"moveUp", ( PyCFunction ) ModSeq_moveUp, METH_VARARGS, + {"moveUp", ( PyCFunction ) ModSeq_moveUp, METH_O, "(modifier) - Move a modifier up in stack"}, - {"moveDown", ( PyCFunction ) ModSeq_moveDown, METH_VARARGS, + {"moveDown", ( PyCFunction ) ModSeq_moveDown, METH_O, "(modifier) - Move a modifier down in stack"}, {NULL, NULL, 0, NULL} }; diff --git a/source/blender/python/api2_2x/NLA.c b/source/blender/python/api2_2x/NLA.c index 12d948120dd..31a420a15a2 100644 --- a/source/blender/python/api2_2x/NLA.c +++ b/source/blender/python/api2_2x/NLA.c @@ -87,11 +87,11 @@ struct PyMethodDef M_NLA_methods[] = { /*****************************************************************************/ static PyObject *Action_setActive( BPy_Action * self, PyObject * args ); static PyObject *Action_getFrameNumbers(BPy_Action *self); -static PyObject *Action_getChannelIpo( BPy_Action * self, PyObject * args ); +static PyObject *Action_getChannelIpo( BPy_Action * self, PyObject * value ); static PyObject *Action_getChannelNames( BPy_Action * self ); static PyObject *Action_renameChannel( BPy_Action * self, PyObject * args ); -static PyObject *Action_verifyChannel( BPy_Action * self, PyObject * args ); -static PyObject *Action_removeChannel( BPy_Action * self, PyObject * args ); +static PyObject *Action_verifyChannel( BPy_Action * self, PyObject * value ); +static PyObject *Action_removeChannel( BPy_Action * self, PyObject * value ); static PyObject *Action_getAllChannelIpos( BPy_Action * self ); /*****************************************************************************/ @@ -107,15 +107,15 @@ static PyMethodDef BPy_Action_methods[] = { "(str) -set this action as the active action for an object"}, {"getFrameNumbers", (PyCFunction) Action_getFrameNumbers, METH_NOARGS, "() - get the frame numbers at which keys have been inserted"}, - {"getChannelIpo", ( PyCFunction ) Action_getChannelIpo, METH_VARARGS, + {"getChannelIpo", ( PyCFunction ) Action_getChannelIpo, METH_O, "(str) -get the Ipo from a named action channel in this action"}, {"getChannelNames", ( PyCFunction ) Action_getChannelNames, METH_NOARGS, "() -get the channel names for this action"}, {"renameChannel", ( PyCFunction ) Action_renameChannel, METH_VARARGS, "(from, to) -rename the channel from string to string"}, - {"verifyChannel", ( PyCFunction ) Action_verifyChannel, METH_VARARGS, + {"verifyChannel", ( PyCFunction ) Action_verifyChannel, METH_O, "(str) -verify the channel in this action"}, - {"removeChannel", ( PyCFunction ) Action_removeChannel, METH_VARARGS, + {"removeChannel", ( PyCFunction ) Action_removeChannel, METH_O, "(str) -remove the channel from the action"}, {"getAllChannelIpos", ( PyCFunction ) Action_getAllChannelIpos, METH_NOARGS, @@ -268,12 +268,12 @@ static PyObject *Action_setActive( BPy_Action * self, PyObject * args ) Py_RETURN_NONE; } -static PyObject *Action_getChannelIpo( BPy_Action * self, PyObject * args ) +static PyObject *Action_getChannelIpo( BPy_Action * self, PyObject * value ) { - char *chanName; + char *chanName = PyString_AsString(value); bActionChannel *chan; - if( !PyArg_ParseTuple( args, "s", &chanName ) ) + if( !chanName ) return EXPP_ReturnPyObjError( PyExc_AttributeError, "string expected" ); @@ -328,16 +328,16 @@ static PyObject *Action_renameChannel( BPy_Action * self, PyObject * args ) } /*----------------------------------------------------------------------*/ -static PyObject *Action_verifyChannel( BPy_Action * self, PyObject * args ) +static PyObject *Action_verifyChannel( BPy_Action * self, PyObject * value ) { - char *chanName; + char *chanName = PyString_AsString(value); bActionChannel *chan; if( !self->action ) ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "couldn't create channel for a NULL action" ) ); - if( !PyArg_ParseTuple( args, "s", &chanName ) ) + if( !chanName ) return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "expected string argument" ) ); @@ -347,16 +347,15 @@ static PyObject *Action_verifyChannel( BPy_Action * self, PyObject * args ) } -static PyObject *Action_removeChannel( BPy_Action * self, PyObject * args ) +static PyObject *Action_removeChannel( BPy_Action * self, PyObject * value ) { - char *chanName; + char *chanName = PyString_AsString(value); bActionChannel *chan; - if( !PyArg_ParseTuple( args, "s", &chanName ) ) { - EXPP_ReturnPyObjError( PyExc_AttributeError, - "string expected" ); - return NULL; - } + if( !chanName ) + return (EXPP_ReturnPyObjError( PyExc_AttributeError, + "string expected" )); + chan = get_action_channel( self->action, chanName ); if( chan == NULL ) { diff --git a/source/blender/python/api2_2x/Sound.c b/source/blender/python/api2_2x/Sound.c index 350d04e5a63..66da43e6fad 100644 --- a/source/blender/python/api2_2x/Sound.c +++ b/source/blender/python/api2_2x/Sound.c @@ -59,7 +59,7 @@ /* Python API function prototypes for the Sound module. */ /*****************************************************************************/ static PyObject *M_Sound_Get( PyObject * self, PyObject * args ); -static PyObject *M_Sound_Load( PyObject * self, PyObject * args ); +static PyObject *M_Sound_Load( PyObject * self, PyObject * value ); /************************************************************************/ /* The following string definitions are used for documentation strings. */ @@ -82,7 +82,7 @@ returns None if not found."; /*****************************************************************************/ struct PyMethodDef M_Sound_methods[] = { {"Get", M_Sound_Get, METH_VARARGS, M_Sound_Get_doc}, - {"Load", M_Sound_Load, METH_VARARGS, M_Sound_Load_doc}, + {"Load", M_Sound_Load, METH_O, M_Sound_Load_doc}, {NULL, NULL, 0, NULL} }; @@ -265,13 +265,13 @@ static PyObject *M_Sound_Get( PyObject * self, PyObject * args ) /* Description: Receives a string and returns the Sound object */ /* whose filename matches the string. */ /*****************************************************************************/ -static PyObject *M_Sound_Load( PyObject * self, PyObject * args ) +static PyObject *M_Sound_Load( PyObject * self, PyObject * value ) { - char *fname; + char *fname = PyString_AsString(value); bSound *snd_ptr; BPy_Sound *snd; - if( !PyArg_ParseTuple( args, "s", &fname ) ) + if( !fname ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ) ); diff --git a/source/blender/python/api2_2x/Sys.c b/source/blender/python/api2_2x/Sys.c index db74ce40b4a..7dc841e9d68 100644 --- a/source/blender/python/api2_2x/Sys.c +++ b/source/blender/python/api2_2x/Sys.c @@ -51,16 +51,16 @@ /*****************************************************************************/ /* Python API function prototypes for the sys module. */ /*****************************************************************************/ -static PyObject *M_sys_basename( PyObject * self, PyObject * args ); -static PyObject *M_sys_dirname( PyObject * self, PyObject * args ); +static PyObject *M_sys_basename( PyObject * self, PyObject * value ); +static PyObject *M_sys_dirname( PyObject * self, PyObject * value ); static PyObject *M_sys_join( PyObject * self, PyObject * args ); -static PyObject *M_sys_splitext( PyObject * self, PyObject * args ); +static PyObject *M_sys_splitext( PyObject * self, PyObject * value ); static PyObject *M_sys_makename( PyObject * self, PyObject * args, PyObject * kw ); -static PyObject *M_sys_exists( PyObject * self, PyObject * args ); +static PyObject *M_sys_exists( PyObject * self, PyObject * value ); static PyObject *M_sys_time( PyObject * self ); static PyObject *M_sys_sleep( PyObject * self, PyObject * args ); -static PyObject *M_sys_expandpath( PyObject *self, PyObject *args); +static PyObject *M_sys_expandpath( PyObject *self, PyObject *value); /*****************************************************************************/ /* The following string definitions are used for documentation strings. */ @@ -131,17 +131,17 @@ If the special chars are not found in the given path, it is simply returned."; /* Python method structure definition for Blender.sys module: */ /*****************************************************************************/ struct PyMethodDef M_sys_methods[] = { - {"basename", M_sys_basename, METH_VARARGS, M_sys_basename_doc}, - {"dirname", M_sys_dirname, METH_VARARGS, M_sys_dirname_doc}, + {"basename", M_sys_basename, METH_O, M_sys_basename_doc}, + {"dirname", M_sys_dirname, METH_O, M_sys_dirname_doc}, {"join", M_sys_join, METH_VARARGS, M_sys_join_doc}, - {"splitext", M_sys_splitext, METH_VARARGS, M_sys_splitext_doc}, + {"splitext", M_sys_splitext, METH_O, M_sys_splitext_doc}, {"makename", ( PyCFunction ) M_sys_makename, METH_VARARGS | METH_KEYWORDS, M_sys_makename_doc}, - {"exists", M_sys_exists, METH_VARARGS, M_sys_exists_doc}, + {"exists", M_sys_exists, METH_O, M_sys_exists_doc}, {"sleep", M_sys_sleep, METH_VARARGS, M_sys_sleep_doc}, {"time", ( PyCFunction ) M_sys_time, METH_NOARGS, M_sys_time_doc}, - {"expandpath", M_sys_expandpath, METH_VARARGS, M_sys_expandpath_doc}, + {"expandpath", M_sys_expandpath, METH_O, M_sys_expandpath_doc}, {NULL, NULL, 0, NULL} }; @@ -165,12 +165,13 @@ PyObject *sys_Init( void ) return submodule; } -static PyObject *M_sys_basename( PyObject * self, PyObject * args ) +static PyObject *M_sys_basename( PyObject * self, PyObject * value ) { - char *name, *p, basename[FILE_MAXDIR + FILE_MAXFILE]; + char *name = PyString_AsString(value); + char *p, basename[FILE_MAXDIR + FILE_MAXFILE]; int n, len; - if( !PyArg_ParseTuple( args, "s", &name ) ) + if( !name ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); @@ -196,12 +197,13 @@ static PyObject *M_sys_basename( PyObject * self, PyObject * args ) return PyString_FromString( name ); } -static PyObject *M_sys_dirname( PyObject * self, PyObject * args ) +static PyObject *M_sys_dirname( PyObject * self, PyObject * value ) { - char *name, *p, dirname[FILE_MAXDIR + FILE_MAXFILE]; + char *name = PyString_AsString(value); + char *p, dirname[FILE_MAXDIR + FILE_MAXFILE]; int n; - if( !PyArg_ParseTuple( args, "s", &name ) ) + if( !name ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); @@ -254,12 +256,13 @@ static PyObject *M_sys_join( PyObject * self, PyObject * args ) return PyString_FromString( filename ); } -static PyObject *M_sys_splitext( PyObject * self, PyObject * args ) +static PyObject *M_sys_splitext( PyObject * self, PyObject * value ) { - char *name, *dot, *p, path[FILE_MAXDIR + FILE_MAXFILE], ext[FILE_MAXDIR + FILE_MAXFILE]; + char *name = PyString_AsString(value); + char *dot, *p, path[FILE_MAXDIR + FILE_MAXFILE], ext[FILE_MAXDIR + FILE_MAXFILE]; int n, len; - if( !PyArg_ParseTuple( args, "s", &name ) ) + if( !name ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); @@ -358,12 +361,13 @@ static PyObject *M_sys_sleep( PyObject * self, PyObject * args ) return EXPP_incr_ret( Py_None ); } -static PyObject *M_sys_exists( PyObject * self, PyObject * args ) +static PyObject *M_sys_exists( PyObject * self, PyObject * value ) { - char *fname = NULL; + char *fname = PyString_AsString(value); + int mode = 0, i = -1; - if( !PyArg_ParseTuple( args, "s", &fname ) ) + if( !fname ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string (pathname) argument" ); @@ -380,12 +384,12 @@ static PyObject *M_sys_exists( PyObject * self, PyObject * args ) return PyInt_FromLong(i); } -static PyObject *M_sys_expandpath( PyObject * self, PyObject * args ) +static PyObject *M_sys_expandpath( PyObject * self, PyObject * value ) { - char *path = NULL; + char *path = PyString_AsString(value); char expanded[FILE_MAXDIR + FILE_MAXFILE]; - if (!PyArg_ParseTuple( args, "s", &path)) + if (!path) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c index da4fbe44eb0..c98c542962a 100644 --- a/source/blender/python/api2_2x/Text.c +++ b/source/blender/python/api2_2x/Text.c @@ -51,7 +51,7 @@ /*****************************************************************************/ static PyObject *M_Text_New( PyObject * self, PyObject * args); static PyObject *M_Text_Get( PyObject * self, PyObject * args ); -static PyObject *M_Text_Load( PyObject * self, PyObject * args ); +static PyObject *M_Text_Load( PyObject * self, PyObject * value ); static PyObject *M_Text_unlink( PyObject * self, PyObject * args ); /*****************************************************************************/ @@ -81,7 +81,7 @@ struct PyMethodDef M_Text_methods[] = { {"New", M_Text_New, METH_VARARGS, M_Text_New_doc}, {"Get", M_Text_Get, METH_VARARGS, M_Text_Get_doc}, {"get", M_Text_Get, METH_VARARGS, M_Text_Get_doc}, - {"Load", M_Text_Load, METH_VARARGS, M_Text_Load_doc}, + {"Load", M_Text_Load, METH_O, M_Text_Load_doc}, {"unlink", M_Text_unlink, METH_VARARGS, M_Text_unlink_doc}, {NULL, NULL, 0, NULL} }; @@ -93,7 +93,7 @@ struct PyMethodDef M_Text_methods[] = { static PyObject *Text_getFilename( BPy_Text * self ); static PyObject *Text_getNLines( BPy_Text * self ); static PyObject *Text_clear( BPy_Text * self ); -static PyObject *Text_write( BPy_Text * self, PyObject * args ); +static PyObject *Text_write( BPy_Text * self, PyObject * value ); static PyObject *Text_set( BPy_Text * self, PyObject * args ); static PyObject *Text_asLines( BPy_Text * self ); @@ -112,7 +112,7 @@ static PyMethodDef BPy_Text_methods[] = { "(str) - Change Text Object name"}, {"clear", ( PyCFunction ) Text_clear, METH_NOARGS, "() - Clear Text buffer"}, - {"write", ( PyCFunction ) Text_write, METH_VARARGS, + {"write", ( PyCFunction ) Text_write, METH_O, "(line) - Append string 'str' to Text buffer"}, {"set", ( PyCFunction ) Text_set, METH_VARARGS, "(name, val) - Set attribute 'name' to value 'val'"}, @@ -240,14 +240,14 @@ static PyObject *M_Text_Get( PyObject * self, PyObject * args ) /* Description: Receives a filename and returns the text object */ /* created from the corresponding file. */ /*****************************************************************************/ -static PyObject *M_Text_Load( PyObject * self, PyObject * args ) +static PyObject *M_Text_Load( PyObject * self, PyObject * value ) { - char *fname = NULL; + char *fname = PyString_AsString(value); char fpath[FILE_MAXDIR + FILE_MAXFILE]; Text *txt_ptr = NULL; unsigned int maxlen = FILE_MAXDIR + FILE_MAXFILE; - if( !PyArg_ParseTuple( args, "s", &fname ) ) + if( !fname ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ) ); @@ -413,16 +413,16 @@ static PyObject *Text_set( BPy_Text * self, PyObject * args ) Py_RETURN_NONE; } -static PyObject *Text_write( BPy_Text * self, PyObject * args ) +static PyObject *Text_write( BPy_Text * self, PyObject * value ) { - char *str; + char *str = PyString_AsString(value); int oldstate; if( !self->text ) return EXPP_ReturnPyObjError( PyExc_RuntimeError, "This object isn't linked to a Blender Text Object" ); - if( !PyArg_ParseTuple( args, "s", &str ) ) + if( !str ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); diff --git a/source/blender/python/api2_2x/Text3d.c b/source/blender/python/api2_2x/Text3d.c index 695f84728c7..6ac6f61cbd5 100644 --- a/source/blender/python/api2_2x/Text3d.c +++ b/source/blender/python/api2_2x/Text3d.c @@ -102,7 +102,7 @@ static int Text3d_compare( BPy_Text3d * a, BPy_Text3d * b ); /*PyObject *Text3d_getType(BPy_Text3d *self);*/ static PyObject *Text3d_getName( BPy_Text3d * self ); static PyObject *Text3d_setName( BPy_Text3d * self, PyObject * args ); -static PyObject *Text3d_setText( BPy_Text3d * self, PyObject * args ); +static PyObject *Text3d_setText( BPy_Text3d * self, PyObject * value ); static PyObject *Text3d_getText( BPy_Text3d * self ); static PyObject *Text3d_getDrawMode( BPy_Text3d * self ); static PyObject *Text3d_setDrawMode( BPy_Text3d * self, PyObject * args ); @@ -664,11 +664,11 @@ static PyObject *Text3d_setName( BPy_Text3d * self, PyObject * args ) return Curve_setName( (BPy_Curve*)self,args ); } -static PyObject *Text3d_setText( BPy_Text3d * self, PyObject * args ) +static PyObject *Text3d_setText( BPy_Text3d * self, PyObject * value ) { - char *text; + char *text = PyString_AsString(value); - if( !PyArg_ParseTuple( args, "s", &text ) ) + if( !text ) return EXPP_ReturnPyObjError( PyExc_AttributeError, "expected string argument" ); diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c index 607ff6fe008..82fbb262a1b 100644 --- a/source/blender/python/api2_2x/Texture.c +++ b/source/blender/python/api2_2x/Texture.c @@ -498,7 +498,7 @@ static int Texture_setNoiseBasis2( BPy_Texture *self, PyObject *args, static PyObject *Texture_getColorband( BPy_Texture * self); int Texture_setColorband( BPy_Texture * self, PyObject * value); -static PyObject *Texture_evaluate( BPy_Texture *self, PyObject *args ); +static PyObject *Texture_evaluate( BPy_Texture *self, VectorObject *vec_in ); static PyObject *Texture_copy( BPy_Texture *self ); /*****************************************************************************/ @@ -542,7 +542,7 @@ static PyMethodDef BPy_Texture_methods[] = { "(s) - Set Dist Noise"}, {"setDistMetric", ( PyCFunction ) Texture_oldsetDistMetric, METH_VARARGS, "(s) - Set Dist Metric"}, - {"evaluate", ( PyCFunction ) Texture_evaluate, METH_VARARGS, + {"evaluate", ( PyCFunction ) Texture_evaluate, METH_O, "(vector) - evaluate the texture at this position"}, {"__copy__", ( PyCFunction ) Texture_copy, METH_NOARGS, "() - return a copy of the the texture"}, @@ -2704,14 +2704,13 @@ int Texture_setColorband( BPy_Texture * self, PyObject * value) return EXPP_Colorband_fromPyList( &self->texture->coba, value ); } -static PyObject *Texture_evaluate( BPy_Texture * self, PyObject * args ) +static PyObject *Texture_evaluate( BPy_Texture * self, VectorObject * vec_in ) { - VectorObject *vec_in = NULL; TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; float vec[4]; /* int rgbnor; dont use now */ - if(!PyArg_ParseTuple(args, "O!", &vector_Type, &vec_in) || vec_in->size < 3) + if(!VectorObject_Check(vec_in) || vec_in->size < 3) return EXPP_ReturnPyObjError(PyExc_TypeError, "expects a 3D vector object"); diff --git a/source/blender/python/api2_2x/Window.c b/source/blender/python/api2_2x/Window.c index 92cae6e4422..35b26051cf9 100644 --- a/source/blender/python/api2_2x/Window.c +++ b/source/blender/python/api2_2x/Window.c @@ -100,7 +100,7 @@ static PyObject *M_Window_GetAreaSize( PyObject * self ); static PyObject *M_Window_GetAreaID( PyObject * self ); static PyObject *M_Window_GetScreenSize( PyObject * self ); static PyObject *M_Window_GetScreens( PyObject * self ); -static PyObject *M_Window_SetScreen( PyObject * self, PyObject * args ); +static PyObject *M_Window_SetScreen( PyObject * self, PyObject * value ); static PyObject *M_Window_GetScreenInfo( PyObject * self, PyObject * args, PyObject * kwords ); PyObject *Window_Init( void ); @@ -362,7 +362,7 @@ struct PyMethodDef M_Window_methods[] = { M_Window_GetScreenSize_doc}, {"GetScreens", ( PyCFunction ) M_Window_GetScreens, METH_NOARGS, M_Window_GetScreens_doc}, - {"SetScreen", ( PyCFunction ) M_Window_SetScreen, METH_VARARGS, + {"SetScreen", ( PyCFunction ) M_Window_SetScreen, METH_O, M_Window_SetScreen_doc}, {"GetScreenInfo", ( PyCFunction ) M_Window_GetScreenInfo, METH_VARARGS | METH_KEYWORDS, M_Window_GetScreenInfo_doc}, @@ -1334,12 +1334,12 @@ static PyObject *M_Window_GetScreenSize( PyObject * self ) } -static PyObject *M_Window_SetScreen( PyObject * self, PyObject * args ) +static PyObject *M_Window_SetScreen( PyObject * self, PyObject * value ) { bScreen *scr = G.main->screen.first; - char *name = NULL; + char *name = PyString_AsString(value); - if( !PyArg_ParseTuple( args, "s", &name ) ) + if( !name ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string as argument" ); diff --git a/source/blender/python/api2_2x/windowTheme.c b/source/blender/python/api2_2x/windowTheme.c index 7ae7a0a32de..c8adec8e7a3 100644 --- a/source/blender/python/api2_2x/windowTheme.c +++ b/source/blender/python/api2_2x/windowTheme.c @@ -519,7 +519,7 @@ static PyObject *Theme_repr( BPy_Theme * self ); static PyObject *Theme_get( BPy_Theme * self, PyObject * args ); static PyObject *Theme_getName( BPy_Theme * self ); -static PyObject *Theme_setName( BPy_Theme * self, PyObject * args ); +static PyObject *Theme_setName( BPy_Theme * self, PyObject * value ); static PyMethodDef BPy_Theme_methods[] = { {"get", ( PyCFunction ) Theme_get, METH_VARARGS, @@ -530,7 +530,7 @@ static PyMethodDef BPy_Theme_methods[] = { - (s) - string: 'UI' or a space name, like 'VIEW3D', etc."}, {"getName", ( PyCFunction ) Theme_getName, METH_NOARGS, "() - Return Theme name"}, - {"setName", ( PyCFunction ) Theme_setName, METH_VARARGS, + {"setName", ( PyCFunction ) Theme_setName, METH_O, "(s) - Set Theme name"}, {NULL, NULL, 0, NULL} }; @@ -775,11 +775,11 @@ static PyObject *Theme_getName( BPy_Theme * self ) return PyString_FromString( self->theme->name ); } -static PyObject *Theme_setName( BPy_Theme * self, PyObject * args ) +static PyObject *Theme_setName( BPy_Theme * self, PyObject * value ) { - char *name = NULL; + char *name = PyString_AsString(value); - if( !PyArg_ParseTuple( args, "s", &name ) ) + if( !name ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected string argument" ); |