[Bf-python] unreachable code
Joseph Gilbert
models at paposo.com
Thu Jul 14 21:37:46 CEST 2005
Im working on a quick clean up of some compiler warnings and came across
a large unreachable code block in effect.c. I was wondering if anyone
has any insight into this:
If you notice the function exits early and the rest is unreachable. Was
this simply not implemented?
PyObject *M_Effect_New( PyObject * self, PyObject * args )
{
BPy_Effect *pyeffect;
Effect *bleffect = 0;
int type = -1;
char *btype = NULL;
Py_INCREF( Py_None );
return Py_None; <---------------------********exits
//everthing else is unreachable
/* if( !PyArg_ParseTuple( args, "s", &btype ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected type argument(wave,build or particle)"
) );
if( !strcmp( btype, "wave" ) )
type = EFF_WAVE;
if( !strcmp( btype, "build" ) )
type = EFF_BUILD;
if( !strcmp( btype, "particle" ) )
type = EFF_PARTICLE;
if( type == -1 )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"unknown type " ) );
bleffect = add_effect( type );
if( bleffect == NULL )
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create Effect Data in Blender" ) );
pyeffect = ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type );
if( pyeffect == NULL )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create Effect Data object" ) );
pyeffect->effect = bleffect;
return ( PyObject * ) pyeffect;*/
Also a similar deal with this one:
static int Sound_setAttr( BPy_Sound * self, char *name, PyObject * value )
{
PyObject *valtuple;
PyObject *error = NULL;
/* We're playing a trick on the Python API users here. Even if they use
* Sound.member = val instead of Sound.setMember(value), we end up using the
* function anyway, since it already has error checking, clamps to the right
* interval and updates the Blender Sound structure when necessary. */
valtuple = Py_BuildValue( "(O)", value ); /*the set* functions
expect a tuple */
if( !valtuple )
return EXPP_ReturnIntError( PyExc_MemoryError,
"SoundSetAttr: couldn't create PyTuple" );
/* if (strcmp (name, "name") == 0)
error = Sound_setName (self, valtuple);
else */ {
/* Error: no such member in the Sound object structure */
Py_DECREF( value );
Py_DECREF( valtuple );
return ( EXPP_ReturnIntError( PyExc_KeyError,
"attribute not found or immutable" ) );
}
//unreachable past this point *********************
Py_DECREF( valtuple );
if( error != Py_None )
return -1;
Py_DECREF( Py_None ); /* incref'ed by the called set* function */
return 0; /* normal exit */
}
More information about the Bf-python
mailing list