[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10945] trunk/blender/source/blender/ python/api2_2x: Python API, more METH_VARARGS to METH_O
Campbell Barton
cbarton at metavr.com
Sat Jun 16 15:17:41 CEST 2007
Revision: 10945
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=10945
Author: campbellbarton
Date: 2007-06-16 15:17:41 +0200 (Sat, 16 Jun 2007)
Log Message:
-----------
Python API, more METH_VARARGS to METH_O
Modified Paths:
--------------
trunk/blender/source/blender/python/api2_2x/Constraint.c
trunk/blender/source/blender/python/api2_2x/Modifier.c
trunk/blender/source/blender/python/api2_2x/NLA.c
trunk/blender/source/blender/python/api2_2x/Sound.c
trunk/blender/source/blender/python/api2_2x/Sys.c
trunk/blender/source/blender/python/api2_2x/Text.c
trunk/blender/source/blender/python/api2_2x/Text3d.c
trunk/blender/source/blender/python/api2_2x/Texture.c
trunk/blender/source/blender/python/api2_2x/Window.c
trunk/blender/source/blender/python/api2_2x/windowTheme.c
Modified: trunk/blender/source/blender/python/api2_2x/Constraint.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Constraint.c 2007-06-16 13:01:10 UTC (rev 10944)
+++ trunk/blender/source/blender/python/api2_2x/Constraint.c 2007-06-16 13:17:41 UTC (rev 10945)
@@ -1612,18 +1612,17 @@
* 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_Constant_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 @@
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 @@
/* 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 @@
/* 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 @@
/* 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 @@
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 @@
/* 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}
};
Modified: trunk/blender/source/blender/python/api2_2x/Modifier.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Modifier.c 2007-06-16 13:01:10 UTC (rev 10944)
+++ trunk/blender/source/blender/python/api2_2x/Modifier.c 2007-06-16 13:17:41 UTC (rev 10945)
@@ -1261,24 +1261,23 @@
* 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 @@
/* 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 @@
/* 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 @@
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 @@
/* 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 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}
};
Modified: trunk/blender/source/blender/python/api2_2x/NLA.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/NLA.c 2007-06-16 13:01:10 UTC (rev 10944)
+++ trunk/blender/source/blender/python/api2_2x/NLA.c 2007-06-16 13:17:41 UTC (rev 10945)
@@ -87,11 +87,11 @@
/*****************************************************************************/
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 @@
"(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,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list