removing unneeded checks
authorCampbell Barton <ideasman42@gmail.com>
Wed, 25 Jul 2007 04:45:20 +0000 (04:45 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 25 Jul 2007 04:45:20 +0000 (04:45 +0000)
source/blender/python/BPY_interface.c
source/blender/python/api2_2x/Scene.c
source/blender/python/api2_2x/Window.c

index f5de2b48c6a46a3cc5b054e091bfecd45b1e1488..bcdf5ecee9c5623018e1fdee46b62e212990768a 100644 (file)
@@ -1341,7 +1341,7 @@ int BPY_pyconstraint_targets(bPythonConstraint *con, float targetmat[][4])
                return 0;
        }
 
-       if (retval) {Py_XDECREF( retval );}
+       Py_XDECREF( retval );
        retval = NULL;
        
        /* try to find USE_TARGET global constant */
index 1414f949f2fa34a9d64c6d42628b186f625da453..62b3a44690b8f4d2d28d54680ac3975cee1adf03 100644 (file)
@@ -999,9 +999,6 @@ static PyObject *Scene_getActiveObject(BPy_Scene *self)
 /*-----------------------Scene.getCurrentCamera()------------------------*/
 static PyObject *Scene_getCurrentCamera( BPy_Scene * self )
 {
-       Object *cam_obj;
-       PyObject *pyob;
-       Scene *scene = self->scene;
        static char warning = 1;
        
        if( warning ) {
@@ -1010,18 +1007,8 @@ static PyObject *Scene_getCurrentCamera( BPy_Scene * self )
        }
 
        SCENE_DEL_CHECK_PY(self);
-
-       cam_obj = scene->camera;
-
-       if( cam_obj ) {         /* if found, return a wrapper for it */
-               pyob = Object_CreatePyObject( cam_obj );
-               if (!pyob)
-                       return EXPP_ReturnPyObjError(PyExc_MemoryError,
-                                       "couldn't create new object wrapper!");
-               return pyob;
-       }
-
-       Py_RETURN_NONE; /* none found */
+       /* None is ok */
+       return Object_CreatePyObject( self->scene->camera );
 }
 
 /*-----------------------Scene.setCurrentCamera()------------------------*/
@@ -1333,7 +1320,6 @@ static int SceneObSeq_len( BPy_SceneObSeq * self )
 static PyObject *SceneObSeq_item( BPy_SceneObSeq * self, int i )
 {
        int index=0;
-       PyObject *bpy_obj;
        Base *base= NULL;
        Scene *scene= self->bpyscene->scene;
        
@@ -1360,13 +1346,7 @@ static PyObject *SceneObSeq_item( BPy_SceneObSeq * self, int i )
                return EXPP_ReturnPyObjError( PyExc_IndexError,
                                              "array index out of range" );
        
-       bpy_obj = Object_CreatePyObject( base->object );
-
-       if( !bpy_obj )
-               return EXPP_ReturnPyObjError( PyExc_RuntimeError,
-                               "PyObject_New() failed" );
-
-       return (PyObject *)bpy_obj;
+       return Object_CreatePyObject( base->object );
 }
 
 static PySequenceMethods SceneObSeq_as_sequence = {
@@ -1630,9 +1610,7 @@ static PyObject *SceneObSeq_unlink( BPy_SceneObSeq * self, PyObject *args )
 
 PyObject *SceneObSeq_getActive(BPy_SceneObSeq *self)
 {
-       PyObject *pyob;
        Base *base;
-       
        SCENE_DEL_CHECK_PY(self->bpyscene);
        
        if (self->mode!=EXPP_OBSEQ_NORMAL)
@@ -1643,13 +1621,7 @@ PyObject *SceneObSeq_getActive(BPy_SceneObSeq *self)
        if (!base)
                Py_RETURN_NONE;
        
-       pyob = Object_CreatePyObject( base->object );
-       
-       if (!pyob)
-               return EXPP_ReturnPyObjError(PyExc_MemoryError,
-                                       "couldn't create new object wrapper!");
-       
-       return pyob;
+       return Object_CreatePyObject( base->object );
 }
 
 static int SceneObSeq_setActive(BPy_SceneObSeq *self, PyObject *value)
@@ -1683,26 +1655,13 @@ static int SceneObSeq_setActive(BPy_SceneObSeq *self, PyObject *value)
 
 PyObject *SceneObSeq_getCamera(BPy_SceneObSeq *self)
 {
-       PyObject *pyob;
-       Object *ob;
-       
        SCENE_DEL_CHECK_PY(self->bpyscene);
        
        if (self->mode!=EXPP_OBSEQ_NORMAL)
                        return (EXPP_ReturnPyObjError( PyExc_TypeError,
                                                "cannot get camera from objects.selected or objects.context" ));
        
-       ob= self->bpyscene->scene->camera;
-       if (!ob)
-               Py_RETURN_NONE;
-       
-       pyob = Object_CreatePyObject( ob );
-       
-       if (!pyob)
-               return EXPP_ReturnPyObjError(PyExc_MemoryError,
-                                       "couldn't create new object wrapper!");
-       
-       return pyob;
+       return Object_CreatePyObject( self->bpyscene->scene->camera );
 }
 
 static int SceneObSeq_setCamera(BPy_SceneObSeq *self, PyObject *value)
index 5538d9d3d881b33b6a7b019452f72668f58b1765..22ae5586e2c4a0de25a2d54510481b1a8d7bdf24 100644 (file)
@@ -722,20 +722,13 @@ static PyObject *M_Window_WaitCursor( PyObject * self, PyObject * args )
 static PyObject *M_Window_GetViewVector( PyObject * self )
 {
        float *vec = NULL;
-       PyObject *pylist;
 
        if( !G.vd )
                Py_RETURN_NONE;
 
        vec = G.vd->viewinv[2];
 
-       pylist = Py_BuildValue( "[fff]", vec[0], vec[1], vec[2] );
-
-       if( !pylist )
-               return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
-                                               "GetViewVector: couldn't create pylist" ) );
-
-       return pylist;
+       return Py_BuildValue( "[fff]", vec[0], vec[1], vec[2] );
 }
 
 /*****************************************************************************/
@@ -786,20 +779,13 @@ static PyObject *M_Window_SetActiveLayer( PyObject * self, PyObject * args )
 static PyObject *M_Window_GetViewQuat( PyObject * self )
 {
        float *vec = NULL;
-       PyObject *pylist;
 
        if( !G.vd )
                Py_RETURN_NONE;
 
        vec = G.vd->viewquat;
 
-       pylist = Py_BuildValue( "[ffff]", vec[0], vec[1], vec[2], vec[3] );
-
-       if( !pylist )
-               return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
-                                               "GetViewQuat: couldn't create pylist" ) );
-
-       return pylist;
+       return Py_BuildValue( "[ffff]", vec[0], vec[1], vec[2], vec[3] );
 }
 
 static PyObject *M_Window_SetViewQuat( PyObject * self, PyObject * args )
@@ -831,21 +817,9 @@ static PyObject *M_Window_SetViewQuat( PyObject * self, PyObject * args )
 
 static PyObject *M_Window_GetViewOffset( PyObject * self )
 {
-       float *vec = NULL;
-       PyObject *pylist;
-
        if( !G.vd )
                Py_RETURN_NONE;
-
-       vec = G.vd->ofs;
-
-       pylist = Py_BuildValue( "[fff]", vec[0], vec[1], vec[2] );
-
-       if( !pylist )
-               return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
-                                               "GetViewQuat: couldn't create pylist" ) );
-
-       return pylist;
+       return Py_BuildValue( "[fff]", G.vd->ofs[0], G.vd->ofs[1], G.vd->ofs[2] );
 }
 
 static PyObject *M_Window_SetViewOffset( PyObject * self, PyObject * args )
@@ -881,20 +855,10 @@ static PyObject *M_Window_SetViewOffset( PyObject * self, PyObject * args )
 /*****************************************************************************/
 static PyObject *M_Window_GetViewMatrix( PyObject * self )
 {
-       PyObject *viewmat;
-
        if( !G.vd )
                Py_RETURN_NONE;
 
-       viewmat =
-               ( PyObject * ) newMatrixObject( ( float * ) G.vd->viewmat, 4,
-                                               4, Py_WRAP );
-
-       if( !viewmat )
-               return EXPP_ReturnPyObjError( PyExc_MemoryError,
-                                             "GetViewMatrix: couldn't create matrix pyobject" );
-
-       return viewmat;
+       return newMatrixObject( ( float * ) G.vd->viewmat, 4, 4, Py_WRAP );
 }
 
 /*****************************************************************************/
@@ -903,20 +867,10 @@ static PyObject *M_Window_GetViewMatrix( PyObject * self )
 /*****************************************************************************/
 static PyObject *M_Window_GetPerspMatrix( PyObject * self )
 {
-       PyObject *perspmat;
-
        if( !G.vd )
                Py_RETURN_NONE;
 
-       perspmat =
-               ( PyObject * ) newMatrixObject( ( float * ) G.vd->persmat, 4,
-                                               4, Py_WRAP );
-
-       if( !perspmat )
-               return EXPP_ReturnPyObjError( PyExc_MemoryError,
-                                             "GetPerspMatrix: couldn't create matrix pyobject" );
-
-       return perspmat;
+       return newMatrixObject( ( float * ) G.vd->persmat, 4, 4, Py_WRAP );
 }