Added some extra parameter checking in Ipo driver code.
This commit is contained in:
@@ -677,20 +677,25 @@ char *getIpoCurveName( IpoCurve * icu )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject *IpoCurve_getDriver( C_IpoCurve * self ){
|
static PyObject *IpoCurve_getDriver( C_IpoCurve * self )
|
||||||
IpoCurve *ipo = self->ipocurve;
|
{
|
||||||
if(ipo->driver == NULL){
|
if( self->ipocurve->driver == NULL ) {
|
||||||
return PyInt_FromLong( 0 );
|
return PyInt_FromLong( 0 );
|
||||||
} else {
|
} else {
|
||||||
return PyInt_FromLong( 1 );
|
return PyInt_FromLong( 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int IpoCurve_setDriver( C_IpoCurve * self, PyObject * args ){
|
static int IpoCurve_setDriver( C_IpoCurve * self, PyObject * args )
|
||||||
|
{
|
||||||
IpoCurve *ipo = self->ipocurve;
|
IpoCurve *ipo = self->ipocurve;
|
||||||
short mode;
|
short mode;
|
||||||
|
|
||||||
mode = (short)PyInt_AS_LONG ( args );
|
if( !PyInt_CheckExact( args ) )
|
||||||
|
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||||
|
"expected int argument 0 or 1" );
|
||||||
|
|
||||||
|
mode = (short)PyInt_AS_LONG ( args );
|
||||||
|
|
||||||
if(mode == 1){
|
if(mode == 1){
|
||||||
if(ipo->driver == NULL){
|
if(ipo->driver == NULL){
|
||||||
@@ -698,32 +703,30 @@ static int IpoCurve_setDriver( C_IpoCurve * self, PyObject * args ){
|
|||||||
ipo->driver->blocktype = ID_OB;
|
ipo->driver->blocktype = ID_OB;
|
||||||
ipo->driver->adrcode = OB_LOC_X;
|
ipo->driver->adrcode = OB_LOC_X;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
} else if(mode == 0){
|
} else if(mode == 0){
|
||||||
if(ipo->driver != NULL){
|
if(ipo->driver != NULL){
|
||||||
MEM_freeN(ipo->driver);
|
MEM_freeN(ipo->driver);
|
||||||
ipo->driver= NULL;
|
ipo->driver= NULL;
|
||||||
}
|
}
|
||||||
return 0;
|
} else
|
||||||
}
|
return EXPP_ReturnIntError( PyExc_ValueError,
|
||||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
"expected int argument: 0 or 1" );
|
||||||
"expected int argument: 1 or 0 " );
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *IpoCurve_getDriverObject( C_IpoCurve * self )
|
||||||
static PyObject *IpoCurve_getDriverObject( C_IpoCurve * self ){
|
{
|
||||||
BPy_Object *blen_object;
|
|
||||||
IpoCurve *ipo = self->ipocurve;
|
IpoCurve *ipo = self->ipocurve;
|
||||||
|
|
||||||
if(ipo->driver == NULL)
|
if( ipo->driver )
|
||||||
return Py_None;
|
return Object_CreatePyObject( ipo->driver->ob );
|
||||||
|
|
||||||
blen_object = ( BPy_Object * ) PyObject_NEW( BPy_Object,&Object_Type );
|
Py_RETURN_NONE;
|
||||||
blen_object->object = ipo->driver->ob;
|
|
||||||
return ( ( PyObject * ) blen_object );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int IpoCurve_setDriverObject( C_IpoCurve * self, PyObject * arg ){
|
static int IpoCurve_setDriverObject( C_IpoCurve * self, PyObject * arg )
|
||||||
|
{
|
||||||
IpoCurve *ipo = self->ipocurve;
|
IpoCurve *ipo = self->ipocurve;
|
||||||
|
|
||||||
if(ipo->driver == NULL)
|
if(ipo->driver == NULL)
|
||||||
@@ -731,28 +734,37 @@ static int IpoCurve_setDriverObject( C_IpoCurve * self, PyObject * arg ){
|
|||||||
"This IpoCurve does not have an active driver" );
|
"This IpoCurve does not have an active driver" );
|
||||||
|
|
||||||
if(!BPy_Object_Check(arg) )
|
if(!BPy_Object_Check(arg) )
|
||||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||||
"expected an object argument" );
|
"expected an object argument" );
|
||||||
ipo->driver->ob = ((BPy_Object *)arg)->object;
|
|
||||||
|
|
||||||
|
ipo->driver->ob = ((BPy_Object *)arg)->object;
|
||||||
DAG_scene_sort(G.scene);
|
DAG_scene_sort(G.scene);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static PyObject *IpoCurve_getDriverChannel( C_IpoCurve * self ){
|
|
||||||
|
static PyObject *IpoCurve_getDriverChannel( C_IpoCurve * self )
|
||||||
|
{
|
||||||
|
if( self->ipocurve->driver == NULL)
|
||||||
|
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||||
|
"This IpoCurve does not have an active driver" );
|
||||||
|
|
||||||
return PyInt_FromLong( self->ipocurve->driver->adrcode );
|
return PyInt_FromLong( self->ipocurve->driver->adrcode );
|
||||||
}
|
}
|
||||||
static int IpoCurve_setDriverChannel( C_IpoCurve * self, PyObject * args ){
|
|
||||||
int code;
|
static int IpoCurve_setDriverChannel( C_IpoCurve * self, PyObject * args )
|
||||||
|
{
|
||||||
IpoCurve *ipo = self->ipocurve;
|
IpoCurve *ipo = self->ipocurve;
|
||||||
|
|
||||||
if(ipo->driver == NULL)
|
if(ipo->driver == NULL)
|
||||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||||
"This IpoCurve does not have an active driver" );
|
"This IpoCurve does not have an active driver" );
|
||||||
|
|
||||||
code = (short)PyInt_AS_LONG ( args );
|
if( !PyInt_CheckExact( args ) )
|
||||||
ipo->driver->adrcode = (short)code;
|
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||||
|
"expected int argument 0 or 1" );
|
||||||
|
|
||||||
|
ipo->driver->adrcode = (short)PyInt_AS_LONG( args );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user