Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2006-08-26 11:26:04 +0400
committerCampbell Barton <ideasman42@gmail.com>2006-08-26 11:26:04 +0400
commitee302f869314bc47097c34fb16f5d9636b1f52c3 (patch)
treee1e1308aa427c9746e91bf893800d844387226d7 /source/blender/python/api2_2x/Metaball.c
parentf479235f8e2086695d527ce3c851aae1efc06280 (diff)
Metaball wasnt checking the length of any of the input arg lists which resulted in errors in unrelated parts of the script.
Updated the doc too and added a longer example (converting an envalope armature into a meta object)
Diffstat (limited to 'source/blender/python/api2_2x/Metaball.c')
-rw-r--r--source/blender/python/api2_2x/Metaball.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c
index c4ddac7d684..e5dc401d7fe 100644
--- a/source/blender/python/api2_2x/Metaball.c
+++ b/source/blender/python/api2_2x/Metaball.c
@@ -413,21 +413,24 @@ static PyObject *Metaball_addMetaelem( BPy_Metaball * self, PyObject * args )
float x, y, z, rad, s, expx, expy, expz;
if( !PyArg_ParseTuple( args, "O", &listargs ) )
return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected a list" ) );
+ ( PyExc_TypeError, "expected a list of 9 args" ) );
if( !PyList_Check( listargs ) )
return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected a list" ) );
-
+ ( PyExc_TypeError, "expected a list of 9 args" ) );
+
+ if (PyList_Size(listargs) != 9)
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list of 9 args" ) );
type = PyInt_AsLong( PyList_GetItem( listargs, 0 ) );
x = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 1 ) );
y = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 2 ) );
z = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 3 ) );
rad = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 4 ) );
- s = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 6 ) );
- expx = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 7 ) );
- expy = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 8 ) );
- expz = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 9 ) );
+ s = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 5 ) );
+ expx = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 6 ) );
+ expy = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 7 ) );
+ expz = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 8 ) );
ml = MEM_callocN( sizeof( MetaElem ), "metaelem" );
BLI_addhead( &( self->metaball->elems ), ml );
@@ -533,10 +536,14 @@ static PyObject *Metaball_setloc( BPy_Metaball * self, PyObject * args )
int i;
if( !PyArg_ParseTuple( args, "O", &listargs ) )
return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected a list" ) );
+ ( PyExc_TypeError, "expected a list of 3 floats" ) );
if( !PyList_Check( listargs ) )
return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected a list" ) );
+ ( PyExc_TypeError, "expected a list of 3 floats" ) );
+ if (PyList_Size(listargs) != 3)
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list of 3 floats" ) );
+
for( i = 0; i < 3; i++ ) {
PyObject *xx = PyList_GetItem( listargs, i );
self->metaball->loc[i] = (float)PyFloat_AsDouble( xx );
@@ -564,6 +571,10 @@ static PyObject *Metaball_setrot( BPy_Metaball * self, PyObject * args )
if( !PyList_Check( listargs ) )
return ( EXPP_ReturnPyObjError
( PyExc_TypeError, "expected a list" ) );
+ if (PyList_Size(listargs) != 3)
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list of 3 floats" ) );
+
for( i = 0; i < 3; i++ ) {
PyObject *xx = PyList_GetItem( listargs, i );
self->metaball->rot[i] = (float)PyFloat_AsDouble( xx );
@@ -614,6 +625,10 @@ static PyObject *Metaball_setsize( BPy_Metaball * self, PyObject * args )
if( !PyList_Check( listargs ) )
return ( EXPP_ReturnPyObjError
( PyExc_TypeError, "expected a list" ) );
+ if (PyList_Size(listargs) != 3)
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list of 3 floats" ) );
+
for( i = 0; i < 3; i++ ) {
PyObject *xx = PyList_GetItem( listargs, i );
self->metaball->size[i] = (float)PyFloat_AsDouble( xx );
@@ -1192,6 +1207,10 @@ static PyObject *Metaelem_setdims( BPy_Metaelem * self, PyObject * args )
if( !PyList_Check( listargs ) )
return ( EXPP_ReturnPyObjError
( PyExc_TypeError, "expected a list" ) );
+ if (PyList_Size(listargs) != 3)
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list of 3 floats" ) );
+
self->metaelem->expx =
(float)PyFloat_AsDouble( PyList_GetItem( listargs, 0 ) );
self->metaelem->expy =
@@ -1224,6 +1243,10 @@ static PyObject *Metaelem_setcoords( BPy_Metaelem * self, PyObject * args )
if( !PyList_Check( listargs ) )
return ( EXPP_ReturnPyObjError
( PyExc_TypeError, "expected a list" ) );
+ if (PyList_Size(listargs) != 3)
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected a list of 3 floats" ) );
+
self->metaelem->x = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 0 ) );
self->metaelem->y = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 1 ) );
self->metaelem->z = (float)PyFloat_AsDouble( PyList_GetItem( listargs, 2 ) );