game engine python api
authorCampbell Barton <ideasman42@gmail.com>
Thu, 14 Aug 2008 03:23:36 +0000 (03:23 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 14 Aug 2008 03:23:36 +0000 (03:23 +0000)
* removed macros that were not used much, some misleading.
* removed error string setting calls that overwrote the error set by PyArg_ParseTuple with a less useful one.
* use python macros Py_RETURN_NONE, Py_RETURN_TRUE, Py_RETURN_FALSE

20 files changed:
source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Converter/BL_ShapeActionActuator.cpp
source/gameengine/Expressions/InputParser.cpp
source/gameengine/Expressions/ListValue.cpp
source/gameengine/Expressions/PyObjectPlus.cpp
source/gameengine/Expressions/PyObjectPlus.h
source/gameengine/Expressions/Value.cpp
source/gameengine/Expressions/Value.h
source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
source/gameengine/GameLogic/SCA_ILogicBrick.cpp
source/gameengine/Ketsji/BL_Shader.cpp
source/gameengine/Ketsji/KX_ConstraintActuator.cpp
source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
source/gameengine/Ketsji/KX_IpoActuator.cpp
source/gameengine/Ketsji/KX_MeshProxy.cpp
source/gameengine/Ketsji/KX_ObjectActuator.cpp
source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp
source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Ketsji/KX_VehicleWrapper.cpp

index 2ee8b54a0148790f4b81e2f1fff56d9e1b615800..d8b2e063a9daa5e054e3a21db94b0cd1162fff10 100644 (file)
@@ -484,17 +484,10 @@ char BL_ActionActuator::GetAction_doc[] =
 PyObject* BL_ActionActuator::PyGetAction(PyObject* self, 
                                                                                 PyObject* args, 
                                                                                 PyObject* kwds) {
-       PyObject *result;
-       
        if (m_action){
-               result = Py_BuildValue("s", m_action->id.name+2);
-       }
-       else{
-               Py_INCREF(Py_None);
-               result = Py_None;
+               return PyString_FromString(m_action->id.name+2);
        }
-       
-       return result;
+       Py_RETURN_NONE;
 }
 
 /*     getProperty                                                             */
@@ -640,8 +633,7 @@ PyObject* BL_ActionActuator::PySetAction(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setStart                                                              */
@@ -662,8 +654,7 @@ PyObject* BL_ActionActuator::PySetStart(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setEnd                                                                */
@@ -684,8 +675,7 @@ PyObject* BL_ActionActuator::PySetEnd(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setBlendin                                                            */
@@ -707,8 +697,7 @@ PyObject* BL_ActionActuator::PySetBlendin(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setBlendtime                                                          */
@@ -735,8 +724,7 @@ PyObject* BL_ActionActuator::PySetBlendtime(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setPriority                                                           */
@@ -759,8 +747,7 @@ PyObject* BL_ActionActuator::PySetPriority(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setFrame                                                              */
@@ -785,8 +772,7 @@ PyObject* BL_ActionActuator::PySetFrame(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setProperty                                                           */
@@ -808,8 +794,7 @@ PyObject* BL_ActionActuator::PySetProperty(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setFrameProperty                                                          */
@@ -830,8 +815,7 @@ PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*
@@ -848,8 +832,7 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 */
 
@@ -934,8 +917,7 @@ PyObject* BL_ActionActuator::PySetChannel(PyObject* self,
                }
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /* getType */
index 242d648b06271a12e04368d19559fdea60433cff..942e3b502e05d0cbef57cfe147c3e6d483cc7bf2 100644 (file)
@@ -464,17 +464,10 @@ char BL_ShapeActionActuator::GetAction_doc[] =
 "\tReturns a string containing the name of the current action.\n";
 
 PyObject* BL_ShapeActionActuator::PyGetAction(PyObject* self) {
-       PyObject *result;
-       
        if (m_action){
-               result = Py_BuildValue("s", m_action->id.name+2);
-       }
-       else{
-               Py_INCREF(Py_None);
-               result = Py_None;
+               return PyString_FromString(m_action->id.name+2);
        }
-       
-       return result;
+       Py_RETURN_NONE;
 }
 
 /*     getProperty                                                             */
@@ -591,12 +584,10 @@ PyObject* BL_ShapeActionActuator::PySetAction(PyObject* self,
                }
        }
        else {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setStart                                                              */
@@ -614,12 +605,10 @@ PyObject* BL_ShapeActionActuator::PySetStart(PyObject* self,
                m_startframe = start;
        }
        else {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setEnd                                                                */
@@ -637,12 +626,10 @@ PyObject* BL_ShapeActionActuator::PySetEnd(PyObject* self,
                m_endframe = end;
        }
        else {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setBlendin                                                            */
@@ -661,12 +648,10 @@ PyObject* BL_ShapeActionActuator::PySetBlendin(PyObject* self,
                m_blendin = blendin;
        }
        else {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setBlendtime                                                          */
@@ -690,12 +675,10 @@ PyObject* BL_ShapeActionActuator::PySetBlendtime(PyObject* self,
                        m_blendframe = m_blendin;
        }
        else {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setPriority                                                           */
@@ -715,12 +698,10 @@ PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self,
                m_priority = priority;
        }
        else {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setFrame                                                              */
@@ -742,12 +723,10 @@ PyObject* BL_ShapeActionActuator::PySetFrame(PyObject* self,
                        m_localtime=m_endframe;
        }
        else {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /*     setProperty                                                           */
@@ -766,12 +745,10 @@ PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self,
                m_propname = string;
        }
        else {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /* getType */
@@ -793,7 +770,6 @@ PyObject* BL_ShapeActionActuator::PySetType(PyObject* self,
        short typeArg;
                                                                                                              
     if (!PyArg_ParseTuple(args, "h", &typeArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
         return NULL;
     }
 
index 24033dd21a2d0bff4c45f6de9cbaf17fe61956b7..32a9de32e21b539a3ecbba2e51b357d1b542ad7a 100644 (file)
@@ -631,7 +631,8 @@ void CParser::SetContext(CValue* context)
 PyObject*      CParserPyMake(PyObject* ignored,PyObject* args)
 {
        char* txt;
-       Py_Try(PyArg_ParseTuple(args,"s",&txt));
+       if (!PyArg_ParseTuple(args,"s",&txt))
+               return NULL;
        CParser parser;
        CExpression* expr = parser.ProcessText(txt);
        CValue* val = expr->Calculate();
@@ -641,7 +642,7 @@ PyObject*   CParserPyMake(PyObject* ignored,PyObject* args)
 
 static PyMethodDef     CParserMethods[] = 
 {
-       { "calc", CParserPyMake , Py_NEWARGS},
+       { "calc", CParserPyMake , METH_VARARGS},
        { NULL,NULL}    // Sentinel
 };
 
index bbf58a8a06e60100a2f4c03a5d25c796f59fc7c3..9ffdbb1223c930da662314e43751fea758b86066 100644 (file)
@@ -43,7 +43,7 @@ PyObject* listvalue_buffer_item(PyObject* list,Py_ssize_t index)
                        return ((CListValue*) list)->GetValue(index)->AddRef();
 
        }
-       Py_Error(PyExc_IndexError, "Python ListIndex out of range");  
+       PyErr_SetString(PyExc_IndexError, "Python ListIndex out of range");
        return NULL;
 }
 
@@ -130,9 +130,10 @@ listvalue_buffer_concat(PyObject * self, PyObject * other)
                        }
                }
 
-               if (error)
-                       Py_Error(PyExc_SystemError, "Python Error: couldn't add one or more items to a list");  
-               
+               if (error) {
+                       PyErr_SetString(PyExc_SystemError, "Python Error: couldn't add one or more items to a list");
+                       return NULL;
+               }
 
        } else
        {
@@ -155,8 +156,8 @@ listvalue_buffer_concat(PyObject * self, PyObject * other)
                                listval->Add(objval);
                        } else
                        {
-                               Py_Error(PyExc_SystemError, "Python Error: couldn't add item to a list");  
-                               // bad luck
+                               PyErr_SetString(PyExc_SystemError, "Python Error: couldn't add item to a list");  
+                               return NULL;
                        }
                }
        }
index aabcd6cb71d10486b97292a3073b21b23b9cadf2..8937f481922616d3335882948995d30f7fe72943 100644 (file)
@@ -94,7 +94,7 @@ PyObjectPlus::PyObjectPlus(PyTypeObject *T)                           // constructor
  * PyObjectPlus Methods        -- Every class, even the abstract one should have a Methods
 ------------------------------*/
 PyMethodDef PyObjectPlus::Methods[] = {
-  {"isA",               (PyCFunction) sPy_isA,                 Py_NEWARGS},
+  {"isA",               (PyCFunction) sPy_isA,                 METH_VARARGS},
   {NULL, NULL}         /* Sentinel */
 };
 
@@ -134,7 +134,8 @@ int PyObjectPlus::_setattr(const STR_String& attr, PyObject *value)
 ------------------------------*/
 PyObject *PyObjectPlus::_repr(void)
 {
-  Py_Error(PyExc_SystemError, "Representation not overridden by object.");  
+       PyErr_SetString(PyExc_SystemError, "Representation not overridden by object.");  
+       return NULL;
 }
 
 /*------------------------------
@@ -164,11 +165,12 @@ bool PyObjectPlus::isA(const char *mytypename)            // check typename of each parent
 PyObject *PyObjectPlus::Py_isA(PyObject *args)         // Python wrapper for isA
 {
   char *mytypename;
-  Py_Try(PyArg_ParseTuple(args, "s", &mytypename));
+  if (!PyArg_ParseTuple(args, "s", &mytypename))
+    return NULL;
   if(isA(mytypename))
-    {Py_INCREF(Py_True); return Py_True;}
+    Py_RETURN_TRUE;
   else
-    {Py_INCREF(Py_False); return Py_False;};
+    Py_RETURN_FALSE;
 }
 
 #endif //NO_EXP_PYTHON_EMBEDDING
index 2bcb604dd23b7a1853b9cd31c3dde4dacb7dfb53..595940274c474d12c24f1ff21ba9a88be30d4301 100644 (file)
 ------------------------------*/
 
                                                                // some basic python macros
-#define Py_NEWARGS 1                   
 #define Py_Return { Py_INCREF(Py_None); return Py_None;}
-static inline PyObject* Py_Success(bool truth)
-{
-       if (truth)
-       {
-               Py_INCREF(Py_True);
-               return Py_True;
-       }
-       Py_INCREF(Py_False);
-       return Py_False;
-}
-
-#define Py_Error(E, M)   {PyErr_SetString(E, M); return NULL;}
-#define Py_Try(F) {if (!(F)) return NULL;}
-#define Py_Assert(A,E,M) {if (!(A)) {PyErr_SetString(E, M); return NULL;}}
 
 static inline void Py_Fatal(char *M) {
        //cout << M << endl; 
index b469474067945ba76598a1be8ed6b9302582ed86..7bcb45228dbdcf2474e3ef9b3b7f2e16ba0b39a6 100644 (file)
@@ -158,15 +158,14 @@ PyParentObject CValue::Parents[] = {
 };
 
 PyMethodDef CValue::Methods[] = {
-//     { "printHello", (PyCFunction) CValue::sPyPrintHello, Py_NEWARGS},
-       { "getName", (PyCFunction) CValue::sPyGetName, Py_NEWARGS},
+//     { "printHello", (PyCFunction) CValue::sPyPrintHello, METH_VARARGS},
+       { "getName", (PyCFunction) CValue::sPyGetName, METH_NOARGS},
        {NULL,NULL} //Sentinel
 };
 
-PyObject* CValue::PyGetName(PyObject* self,PyObject* args,PyObject* kwds)
+PyObject* CValue::PyGetName(PyObject* self)
 {
-       PyObject* pyname = PyString_FromString(this->GetName());
-       return pyname;
+       return PyString_FromString(this->GetName());
 }
 
 /*#define CVALUE_DEBUG*/
@@ -662,7 +661,7 @@ CValue*     CValue::FindIdentifier(const STR_String& identifiername)
 
 static PyMethodDef     CValueMethods[] = 
 {
-       //{ "new", CValue::PyMake , Py_NEWARGS},
+       //{ "new", CValue::PyMake , METH_VARARGS},
        { NULL,NULL}    // Sentinel
 };
 
@@ -806,9 +805,8 @@ PyObject*   CValue::ConvertKeysToPython( void )
 PyObject*      CValue::PyMake(PyObject* ignored,PyObject* args)
 {
 
-       //Py_Try(PyArg_ParseTuple(args,"s",&name));
-       Py_INCREF(Py_None);
-       return Py_None;//new CValue();
+       //if (!PyArg_ParseTuple(args,"s",&name)) return NULL;
+       Py_RETURN_NONE;//new CValue();
 }
 */
 
index bcf231cf4f0bd71679f18c7bbc1e924c0533a45c..74fcdae5756817b9892442bc6a131a683b8deeb9 100644 (file)
@@ -255,7 +255,7 @@ public:
        
        virtual PyObject* ConvertKeysToPython( void );
        
-       KX_PYMETHOD(CValue,GetName);
+       KX_PYMETHOD_NOARGS(CValue,GetName);
 
 #else
        CValue();
index 099cb8eebd0b77214bf21ad85a561421aa00f751..44a488fa71965bad59c35f63b2b9660678d60edf 100644 (file)
@@ -180,7 +180,6 @@ PyObject* SCA_ActuatorSensor::PySetActuator(PyObject* self, PyObject* args, PyOb
        char *actNameArg = NULL;
 
        if (!PyArg_ParseTuple(args, "s", &actNameArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
 
index e73358bc1e89546aa1f68b859348b6eca9973731..f5512664d8fcbcbdb8808ceb384abef58e57f32f 100644 (file)
@@ -271,8 +271,7 @@ PyObject* SCA_ILogicBrick::PyGetOwner(PyObject* self)
        }
 
        printf("ERROR: Python scriptblock without owner\n");
-       Py_INCREF(Py_None);
-       return Py_None;//Int_FromLong(IsPositiveTrigger());
+       Py_RETURN_NONE; //Int_FromLong(IsPositiveTrigger());
 }
 
 
index f6f9a29b0e2754dff1129fb7433ccc5ef97a5d58..57d0fe4140f16d1dd22cd0ebff9347b29133efa2 100644 (file)
@@ -846,8 +846,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" )
 KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()")
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
        if(mShader==0) {
                PyErr_Format(PyExc_TypeError, "invalid shader object");
@@ -877,8 +876,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()")
 KX_PYMETHODDEF_DOC( BL_Shader, setSampler, "setSampler(name, index)" )
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
 
        char *uniform="";
@@ -900,7 +898,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSampler, "setSampler(name, index)" )
                        //else
                        //      spit("Invalid texture sample index: " << index);
                }
-               Py_Return;
+               Py_RETURN_NONE;
        }
        return NULL;
 }
@@ -919,8 +917,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setNumberOfPasses, "setNumberOfPasses( max-pass )
 KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" )
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
 
        char *uniform="";
@@ -945,8 +942,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" )
 KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)")
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
        char *uniform="";
        float array[2]={ 0,0 };
@@ -970,8 +966,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)")
 KX_PYMETHODDEF_DOC( BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ")
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
        char *uniform="";
        float array[3]={0,0,0};
@@ -996,8 +991,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ")
 KX_PYMETHODDEF_DOC( BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) ")
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
        char *uniform="";
        float array[4]={0,0,0,0};
@@ -1021,8 +1015,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) "
 KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" )
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
        char *uniform="";
        int value=0;
@@ -1046,8 +1039,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" )
 KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)")
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
        char *uniform="";
        int array[2]={ 0,0 };
@@ -1071,8 +1063,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)")
 KX_PYMETHODDEF_DOC( BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ")
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
 
        char *uniform="";
@@ -1096,8 +1087,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ")
 KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) ")
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
        char *uniform="";
        int array[4]={0,0,0, 0};
@@ -1120,8 +1110,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) "
 KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or list3 or list4) )")
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
        char*uniform = "";
        PyObject *listPtr =0;
@@ -1190,8 +1179,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or lis
 KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( int (list2 or list3 or list4) )")
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
        char*uniform = "";
        PyObject *listPtr =0;
@@ -1263,8 +1251,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix4,
 "setUniformMatrix4(uniform-name, mat-4x4, transpose(row-major=true, col-major=false)" )
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
 
        float matr[16] = {
@@ -1306,8 +1293,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3,
 "setUniformMatrix3(uniform-name, list[3x3], transpose(row-major=true, col-major=false)" )
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
 
        float matr[9] = {
@@ -1347,8 +1333,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3,
 KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" )
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
        int attr=0;
        if(PyArg_ParseTuple(args, "i", &attr )) {
@@ -1368,8 +1353,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" )
 KX_PYMETHODDEF_DOC( BL_Shader, setUniformDef, "setUniformDef(name, enum)" )
 {
        if(mError) {
-               Py_INCREF(Py_None);
-               return Py_None;
+               Py_RETURN_NONE;
        }
 
        char *uniform="";
index 2401d69d3a306dd69d641a2bf7141905663dffa1..e00ec68ad331575dba14689d85168e0665a2d7aa 100644 (file)
@@ -476,7 +476,6 @@ PyObject* KX_ConstraintActuator::PySetDamp(PyObject* self,
                                                                                   PyObject* kwds) {
        int dampArg;
        if(!PyArg_ParseTuple(args, "i", &dampArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;            
        }
        
@@ -504,7 +503,6 @@ PyObject* KX_ConstraintActuator::PySetRotDamp(PyObject* self,
                                                                                      PyObject* kwds) {
        int dampArg;
        if(!PyArg_ParseTuple(args, "i", &dampArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;            
        }
        
@@ -534,7 +532,6 @@ PyObject* KX_ConstraintActuator::PySetDirection(PyObject* self,
        MT_Vector3 dir;
 
        if(!PyArg_ParseTuple(args, "(fff)", &x, &y, &z)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;            
        }
        dir[0] = x;
@@ -577,7 +574,6 @@ PyObject* KX_ConstraintActuator::PySetOption(PyObject* self,
                                                                                     PyObject* kwds) {
        int option;
        if(!PyArg_ParseTuple(args, "i", &option)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;            
        }
        
@@ -605,7 +601,6 @@ PyObject* KX_ConstraintActuator::PySetTime(PyObject* self,
                                                                                   PyObject* kwds) {
        int t;
        if(!PyArg_ParseTuple(args, "i", &t)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;            
        }
        
@@ -634,7 +629,6 @@ PyObject* KX_ConstraintActuator::PySetProperty(PyObject* self,
                                                                                       PyObject* kwds) {
        char *property;
        if (!PyArg_ParseTuple(args, "s", &property)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        if (property == NULL) {
@@ -670,7 +664,6 @@ PyObject* KX_ConstraintActuator::PySetMin(PyObject* self,
                                                                                  PyObject* kwds) {
        float minArg;
        if(!PyArg_ParseTuple(args, "f", &minArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;            
        }
 
@@ -716,7 +709,6 @@ PyObject* KX_ConstraintActuator::PySetMax(PyObject* self,
                                                                                  PyObject* kwds){
        float maxArg;
        if(!PyArg_ParseTuple(args, "f", &maxArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;            
        }
 
@@ -770,7 +762,6 @@ PyObject* KX_ConstraintActuator::PySetLimit(PyObject* self,
                                                                                        PyObject* kwds) {
        int locrotArg;
        if(!PyArg_ParseTuple(args, "i", &locrotArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;            
        }
        
index 987125ca9ba5bb93c1c161f630dd5ac7e956b46e..b54da6eb753c4db3ec9c25cbf049aa0a81c5c008 100644 (file)
@@ -53,8 +53,7 @@ PyObject* KX_ConstraintWrapper::PyTestMethod(PyObject* self,
                                                                                        PyObject* kwds)
 {
        
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 PyObject* KX_ConstraintWrapper::PyGetConstraintId(PyObject* self, 
index af3add8a323a53197b326721cf18933bc21d9e0a..a203ea6a6ff30ada6676ea60f3b5f7c84774260a 100644 (file)
@@ -480,7 +480,6 @@ PyObject* KX_IpoActuator::PySet(PyObject* self,
        int startFrame, stopFrame;
        if(!PyArg_ParseTuple(args, "siii", &mode, &startFrame, 
                                                 &stopFrame, &forceToggle)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        modenum = string2mode(mode);
@@ -516,7 +515,6 @@ PyObject* KX_IpoActuator::PySetProperty(PyObject* self,
        /* args: property */
        char *propertyName;
        if(!PyArg_ParseTuple(args, "s", &propertyName)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
 
@@ -535,7 +533,6 @@ PyObject* KX_IpoActuator::PySetStart(PyObject* self,
                                                                         PyObject* kwds) {
        float startArg;
        if(!PyArg_ParseTuple(args, "f", &startArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;            
        }
        
@@ -561,7 +558,6 @@ PyObject* KX_IpoActuator::PySetEnd(PyObject* self,
                                                                   PyObject* kwds) {
        float endArg;
        if(!PyArg_ParseTuple(args, "f", &endArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;            
        }
        
@@ -588,7 +584,6 @@ PyObject* KX_IpoActuator::PySetIpoAsForce(PyObject* self,
        int boolArg;
        
        if (!PyArg_ParseTuple(args, "i", &boolArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
 
@@ -617,7 +612,6 @@ PyObject* KX_IpoActuator::PySetIpoAdd(PyObject* self,
        int boolArg;
        
        if (!PyArg_ParseTuple(args, "i", &boolArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
 
@@ -646,7 +640,6 @@ PyObject* KX_IpoActuator::PySetType(PyObject* self,
        int typeArg;
        
        if (!PyArg_ParseTuple(args, "i", &typeArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        
@@ -678,7 +671,6 @@ PyObject* KX_IpoActuator::PySetForceIpoActsLocal(PyObject* self,
        int boolArg;
        
        if (!PyArg_ParseTuple(args, "i", &boolArg)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
 
index c7a251751cd042c7e9a62119fcda8a4340e1f5f3..7bffb5ac854fb0dead576d1179874fd542d1755a 100644 (file)
@@ -238,5 +238,5 @@ KX_PYMETHODDEF_DOC(KX_MeshProxy, reinstancePhysicsMesh,
 "Reinstance the physics mesh.")
 {
        //this needs to be reviewed, it is dependend on Sumo/Solid. Who is using this ?
-       return Py_None;//Py_Success(KX_ReInstanceShapeFromMesh(m_meshobj));
+       return Py_None;//(KX_ReInstanceShapeFromMesh(m_meshobj)) ? Py_RETURN_TRUE : Py_RETURN_FALSE;
 }
index 5cd4d089c147d706d7a3cbd06b7a6e35fc3a5c39..98e73d4f0d76aa0bf773e71567563350d7f074bc 100644 (file)
@@ -360,7 +360,6 @@ PyObject* KX_ObjectActuator::PySetForce(PyObject* self,
        int bToggle = 0;
        if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], 
                                                  &vecArg[2], &bToggle)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        m_force.setValue(vecArg);
@@ -390,7 +389,6 @@ PyObject* KX_ObjectActuator::PySetTorque(PyObject* self,
        int bToggle = 0;
        if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], 
                                                  &vecArg[2], &bToggle)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        m_torque.setValue(vecArg);
@@ -420,7 +418,6 @@ PyObject* KX_ObjectActuator::PySetDLoc(PyObject* self,
        int bToggle = 0;
        if(!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], 
                                                 &vecArg[2], &bToggle)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        m_dloc.setValue(vecArg);
@@ -450,7 +447,6 @@ PyObject* KX_ObjectActuator::PySetDRot(PyObject* self,
        int bToggle = 0;
        if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], 
                                                  &vecArg[2], &bToggle)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        m_drot.setValue(vecArg);
@@ -479,7 +475,6 @@ PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* self,
        int bToggle = 0;
        if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], 
                                                  &vecArg[2], &bToggle)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        m_linear_velocity.setValue(vecArg);
@@ -508,7 +503,6 @@ PyObject* KX_ObjectActuator::PySetAngularVelocity(PyObject* self,
        int bToggle = 0;
        if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], 
                                                  &vecArg[2], &bToggle)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        m_angular_velocity.setValue(vecArg);
@@ -523,7 +517,6 @@ PyObject* KX_ObjectActuator::PySetDamping(PyObject* self,
                                                                                  PyObject* kwds) {
        int damping = 0;
        if (!PyArg_ParseTuple(args, "i", &damping) || damping < 0 || damping > 1000) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        m_damping = damping;
@@ -553,7 +546,6 @@ PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* self,
        float vecArg[2];
        int bToggle = 0;
        if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        m_drot[0] = vecArg[0];
@@ -581,7 +573,6 @@ PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* self,
        float vecArg[2];
        int bToggle = 0;
        if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        m_drot[1] = vecArg[0];
@@ -609,7 +600,6 @@ PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* self,
        float vecArg[2];
        int bToggle = 0;
        if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        m_drot[2] = vecArg[0];
@@ -636,7 +626,6 @@ PyObject* KX_ObjectActuator::PySetPID(PyObject* self,
 {
        float vecArg[3];
        if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2])) {
-               PyErr_SetString(PyExc_TypeError, "Invalid arguments");
                return NULL;
        }
        m_torque.setValue(vecArg);
index 2df4c6a99809c57880d651bf9c11f836cf6f8118..9291199d859569c0979404e36673ea1b22003476 100644 (file)
@@ -61,7 +61,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetPosition(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -78,7 +78,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetLinearVelocity(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 PyObject* KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject* self, 
@@ -94,7 +94,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 PyObject*      KX_PhysicsObjectWrapper::PySetActive(PyObject* self, 
@@ -109,7 +109,7 @@ PyObject*   KX_PhysicsObjectWrapper::PySetActive(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
index c01d6a632a3835e9cf1b752ecc4d0a02947681eb..26243c7dba1e1b1db0ad4bf3cbe6db98b8c0cd9f 100644 (file)
@@ -91,7 +91,7 @@ static PyObject* gPySetGravity(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject* gPySetDebugMode(PyObject* self,
@@ -112,7 +112,7 @@ static PyObject* gPySetDebugMode(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -132,7 +132,7 @@ static PyObject* gPySetNumTimeSubSteps(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -151,7 +151,7 @@ static PyObject* gPySetNumIterations(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -171,7 +171,7 @@ static PyObject* gPySetDeactivationTime(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -190,7 +190,7 @@ static PyObject* gPySetDeactivationLinearTreshold(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -209,7 +209,7 @@ static PyObject* gPySetDeactivationAngularTreshold(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject* gPySetContactBreakingTreshold(PyObject* self,
@@ -227,7 +227,7 @@ static PyObject* gPySetContactBreakingTreshold(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -246,7 +246,7 @@ static PyObject* gPySetCcdMode(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject* gPySetSorConstant(PyObject* self,
@@ -264,7 +264,7 @@ static PyObject* gPySetSorConstant(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject* gPySetSolverTau(PyObject* self,
@@ -282,7 +282,7 @@ static PyObject* gPySetSolverTau(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -301,7 +301,7 @@ static PyObject* gPySetSolverDamping(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject* gPySetLinearAirDamping(PyObject* self,
@@ -319,7 +319,7 @@ static PyObject* gPySetLinearAirDamping(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -338,7 +338,7 @@ static PyObject* gPySetUseEpa(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 static PyObject* gPySetSolverType(PyObject* self,
                                                                                 PyObject* args, 
@@ -355,7 +355,7 @@ static PyObject* gPySetSolverType(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -388,7 +388,7 @@ static PyObject* gPyGetVehicleConstraint(PyObject* self,
                return NULL;
        }
 
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -448,7 +448,7 @@ static PyObject* gPyCreateConstraint(PyObject* self,
                return NULL;
        }
 
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -502,7 +502,7 @@ static PyObject* gPyRemoveConstraint(PyObject* self,
                return NULL;
        }
        
-       Py_INCREF(Py_None); return Py_None;
+       Py_RETURN_NONE;
 }
 
 
index db4793de23da9eea63d6a80d6b02e8c8f26b9c09..868439546c3cff404f04b3fdf970e0653989da46 100644 (file)
@@ -355,8 +355,7 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
        if(!count)
                pprint("No extenstions are used in this build");
 
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 
index 7e8160a4d67766f168fd233d17097bf4998649aa..f5a2b5e02feabac92e0f2003710b11864a7e0faf 100644 (file)
@@ -71,8 +71,7 @@ PyObject* KX_VehicleWrapper::PyAddWheel(PyObject* self,
        } else {
                return NULL;
        }
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -157,8 +156,7 @@ PyObject* KX_VehicleWrapper::PyApplyEngineForce(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 PyObject* KX_VehicleWrapper::PySetTyreFriction(PyObject* self, 
@@ -175,8 +173,7 @@ PyObject* KX_VehicleWrapper::PySetTyreFriction(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 PyObject* KX_VehicleWrapper::PySetSuspensionStiffness(PyObject* self, 
@@ -193,8 +190,7 @@ PyObject* KX_VehicleWrapper::PySetSuspensionStiffness(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 PyObject* KX_VehicleWrapper::PySetSuspensionDamping(PyObject* self, 
@@ -210,8 +206,7 @@ PyObject* KX_VehicleWrapper::PySetSuspensionDamping(PyObject* self,
        } else {
                return NULL;
        }
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 PyObject* KX_VehicleWrapper::PySetSuspensionCompression(PyObject* self, 
@@ -227,8 +222,7 @@ PyObject* KX_VehicleWrapper::PySetSuspensionCompression(PyObject* self,
        } else {
                return NULL;
        }
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 PyObject* KX_VehicleWrapper::PySetRollInfluence(PyObject* self, 
@@ -245,8 +239,7 @@ PyObject* KX_VehicleWrapper::PySetRollInfluence(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -264,8 +257,7 @@ PyObject* KX_VehicleWrapper::PyApplyBraking(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 
@@ -285,8 +277,7 @@ PyObject* KX_VehicleWrapper::PySetSteeringValue(PyObject* self,
        else {
                return NULL;
        }
-       Py_INCREF(Py_None);
-       return Py_None;
+       Py_RETURN_NONE;
 }