BGE Python API cleanup - no functionality changes
[blender.git] / source / gameengine / Ketsji / KX_ConstraintWrapper.cpp
index 9ca9517c0358c41237477e2ae49998058440c0e5..d557758461624e339f7a5c13ecc6fc6fffffcc9a 100644 (file)
@@ -1,15 +1,12 @@
 /**
  * $Id$
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
  */
 #include <Python.h>
+#include "PyObjectPlus.h"
 #include "KX_ConstraintWrapper.h"
 #include "PHY_IPhysicsEnvironment.h"
 
@@ -56,8 +54,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, 
@@ -72,22 +69,22 @@ PyObject* KX_ConstraintWrapper::PyGetConstraintId(PyObject* self,
 
 //python specific stuff
 PyTypeObject KX_ConstraintWrapper::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_ConstraintWrapper",
-               sizeof(KX_ConstraintWrapper),
+               sizeof(PyObjectPlus_Proxy),
                0,
-               PyDestructor,
+               py_base_dealloc,
                0,
-               __getattr,
-               __setattr,
-               0, //&MyPyCompare,
-               __repr,
-               0, //&cvalue_as_number,
                0,
                0,
                0,
-               0
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
+               Methods
 };
 
 PyParentObject KX_ConstraintWrapper::Parents[] = {
@@ -95,37 +92,35 @@ PyParentObject KX_ConstraintWrapper::Parents[] = {
        NULL
 };
 
-PyObject*      KX_ConstraintWrapper::_getattr(const STR_String& attr)
+PyObject*      KX_ConstraintWrapper::py_getattro(PyObject *attr)
 {
        //here you can search for existing data members (like mass,friction etc.)
-       _getattr_up(PyObjectPlus);
+       py_getattro_up(PyObjectPlus);
 }
 
-int    KX_ConstraintWrapper::_setattr(const STR_String& attr,PyObject* pyobj)
+int    KX_ConstraintWrapper::py_setattro(PyObject *attr,PyObject* pyobj)
 {
-       
-       PyTypeObject* type = pyobj->ob_type;
        int result = 1;
-
-       if (type == &PyList_Type)
+       /* what the heck is this supposed to do?, needs attention */
+       if (PyList_Check(pyobj))
        {
                result = 0;
        }
-       if (type == &PyFloat_Type)
+       if (PyFloat_Check(pyobj))
        {
                result = 0;
 
        }
-       if (type == &PyInt_Type)
+       if (PyInt_Check(pyobj))
        {
                result = 0;
        }
-       if (type == &PyString_Type)
+       if (PyString_Check(pyobj))
        {
                result = 0;
        }
        if (result)
-               result = PyObjectPlus::_setattr(attr,pyobj);
+               result = PyObjectPlus::py_setattro(attr,pyobj);
        return result;
 };
 
@@ -135,3 +130,7 @@ PyMethodDef KX_ConstraintWrapper::Methods[] = {
        {"getConstraintId",(PyCFunction) KX_ConstraintWrapper::sPyGetConstraintId, METH_VARARGS},
        {NULL,NULL} //Sentinel
 };
+
+PyAttributeDef KX_ConstraintWrapper::Attributes[] = {
+       { NULL }        //Sentinel
+};