BGE PyAPI support for subclassing any BGE game type from python, scripters define...
authorCampbell Barton <ideasman42@gmail.com>
Mon, 29 Jun 2009 12:06:46 +0000 (12:06 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 29 Jun 2009 12:06:46 +0000 (12:06 +0000)
Adding a UI to set the type on startup can be added easily.

# ----
class myPlayer(GameTypes.KX_GameObject):
  def die(self):
    # ... do stuff ...
    self.endObject()

# make an instance
player = myPlayer(gameOb) # gameOb is made invalid now.
player.die()

# ----

One limitation (which could also be an advantage), is making the subclass instance will return that subclass everywhere, you cant have 2 different subclasses of the same BGE data at once.

71 files changed:
source/blender/python/intern/bpy_rna.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_keymap.c
source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Converter/BL_ShapeActionActuator.cpp
source/gameengine/Expressions/BoolValue.cpp
source/gameengine/Expressions/ListValue.cpp
source/gameengine/Expressions/PyObjectPlus.cpp
source/gameengine/Expressions/PyObjectPlus.h
source/gameengine/Expressions/Value.cpp
source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
source/gameengine/GameLogic/SCA_ANDController.cpp
source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
source/gameengine/GameLogic/SCA_DelaySensor.cpp
source/gameengine/GameLogic/SCA_IController.cpp
source/gameengine/GameLogic/SCA_ILogicBrick.cpp
source/gameengine/GameLogic/SCA_IObject.cpp
source/gameengine/GameLogic/SCA_ISensor.cpp
source/gameengine/GameLogic/SCA_JoystickSensor.cpp
source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
source/gameengine/GameLogic/SCA_LogicManager.cpp
source/gameengine/GameLogic/SCA_MouseSensor.cpp
source/gameengine/GameLogic/SCA_NANDController.cpp
source/gameengine/GameLogic/SCA_NORController.cpp
source/gameengine/GameLogic/SCA_ORController.cpp
source/gameengine/GameLogic/SCA_PropertyActuator.cpp
source/gameengine/GameLogic/SCA_PropertySensor.cpp
source/gameengine/GameLogic/SCA_PythonController.cpp
source/gameengine/GameLogic/SCA_RandomActuator.cpp
source/gameengine/GameLogic/SCA_RandomSensor.cpp
source/gameengine/GameLogic/SCA_XNORController.cpp
source/gameengine/GameLogic/SCA_XORController.cpp
source/gameengine/Ketsji/BL_Shader.cpp
source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
source/gameengine/Ketsji/KX_BlenderMaterial.cpp
source/gameengine/Ketsji/KX_CDActuator.cpp
source/gameengine/Ketsji/KX_Camera.cpp
source/gameengine/Ketsji/KX_CameraActuator.cpp
source/gameengine/Ketsji/KX_ConstraintActuator.cpp
source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
source/gameengine/Ketsji/KX_GameActuator.cpp
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_IpoActuator.cpp
source/gameengine/Ketsji/KX_Light.cpp
source/gameengine/Ketsji/KX_MeshProxy.cpp
source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
source/gameengine/Ketsji/KX_NearSensor.cpp
source/gameengine/Ketsji/KX_ObjectActuator.cpp
source/gameengine/Ketsji/KX_ParentActuator.cpp
source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp
source/gameengine/Ketsji/KX_PolyProxy.cpp
source/gameengine/Ketsji/KX_PolygonMaterial.cpp
source/gameengine/Ketsji/KX_PyMath.h
source/gameengine/Ketsji/KX_PythonInitTypes.cpp
source/gameengine/Ketsji/KX_RadarSensor.cpp
source/gameengine/Ketsji/KX_RaySensor.cpp
source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp
source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
source/gameengine/Ketsji/KX_Scene.cpp
source/gameengine/Ketsji/KX_SceneActuator.cpp
source/gameengine/Ketsji/KX_SoundActuator.cpp
source/gameengine/Ketsji/KX_StateActuator.cpp
source/gameengine/Ketsji/KX_TouchSensor.cpp
source/gameengine/Ketsji/KX_TrackToActuator.cpp
source/gameengine/Ketsji/KX_VehicleWrapper.cpp
source/gameengine/Ketsji/KX_VertexProxy.cpp
source/gameengine/Ketsji/KX_VisibilityActuator.cpp

index 558722c..f07c85f 100644 (file)
@@ -204,13 +204,13 @@ static long pyrna_struct_hash( BPy_StructRNA * self )
 /* use our own dealloc so we can free a property if we use one */
 static void pyrna_struct_dealloc( BPy_StructRNA * self )
 {
-       /* Note!! for some weired reason calling PyObject_DEL() directly crashes blender! */
        if (self->freeptr && self->ptr.data) {
                IDP_FreeProperty(self->ptr.data);
                MEM_freeN(self->ptr.data);
                self->ptr.data= NULL;
        }
 
+       /* Note, for subclassed PyObjects we cant just call PyObject_DEL() directly or it will crash */
        Py_TYPE(self)->tp_free(self);
        return;
 }
index 92b71e9..ffeb342 100644 (file)
@@ -79,7 +79,7 @@ void          WM_keymap_tweak (ListBase *lb, short type, short val, int modifier, short
 ListBase       *WM_keymap_listbase     (struct wmWindowManager *wm, const char *nameid, 
                                                                 int spaceid, int regionid);
 
-char           *WM_key_event_string(short type);
+const char     *WM_key_event_string(short type);
 char           *WM_key_event_operator_string(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, char *str, int len);
 
                        /* handlers */
index 85028e3..b914e63 100644 (file)
@@ -154,7 +154,7 @@ ListBase *WM_keymap_listbase(wmWindowManager *wm, const char *nameid, int spacei
 
 /* ***************** get string from key events **************** */
 
-char *WM_key_event_string(short type)
+const char *WM_key_event_string(short type)
 {
        const char *name= NULL;
        if(RNA_enum_name(event_type_items, (int)type, &name))
index d9e65c5..bed99a4 100644 (file)
@@ -1005,19 +1005,17 @@ PyTypeObject BL_ActionActuator::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &SCA_IActuator::Type
+               &SCA_IActuator::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
-
 PyMethodDef BL_ActionActuator::Methods[] = {
        //Deprecated ----->
        {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc},
index 4c9a584..9705397 100644 (file)
@@ -427,16 +427,15 @@ PyTypeObject BL_ShapeActionActuator::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &SCA_IActuator::Type
+               &SCA_IActuator::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 
index 1102b12..6779c2e 100644 (file)
@@ -29,7 +29,6 @@
 const STR_String CBoolValue::sTrueString  = "TRUE";
 const STR_String CBoolValue::sFalseString = "FALSE";
 
-
 CBoolValue::CBoolValue()
 /*
 pre: false
index 34a357a..38b00dc 100644 (file)
@@ -225,7 +225,7 @@ static int listvalue_buffer_contains(PyObject *self_v, PyObject *value)
                        return 1;
                }
        }
-       else if (BGE_PROXY_CHECK_TYPE(value)) { /* not dict like at all but this worked before __contains__ was used */
+       else if (PyObject_TypeCheck(value, &CValue::Type)) { /* not dict like at all but this worked before __contains__ was used */
                CValue *item= static_cast<CValue *>(BGE_PROXY_REF(value));
                for (int i=0; i < self->GetCount(); i++)
                        if (self->GetValue(i) == item) // Com
@@ -289,15 +289,17 @@ PyTypeObject CListValue::Type = {
        0,                              /*tp_hash*/
        0,                              /*tp_call */
        0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
+       NULL,
+       NULL,
        0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &CValue::Type
+       &CValue::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef CListValue::Methods[] = {
index 863390f..4759537 100644 (file)
@@ -74,10 +74,7 @@ PyTypeObject PyObjectPlus::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
@@ -96,6 +93,88 @@ PyObjectPlus::~PyObjectPlus()
 //     assert(ob_refcnt==0);
 }
 
+
+PyObject *PyObjectPlus::py_base_repr(PyObject *self)                   // This should be the entry in Type.
+{
+       PyObjectPlus *self_plus= BGE_PROXY_REF(self);
+       if(self_plus==NULL) {
+               PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
+               return NULL;
+       }
+       
+       return self_plus->py_repr();  
+}
+
+
+PyObject * PyObjectPlus::py_base_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+       PyTypeObject *base_type;
+       PyObjectPlus_Proxy *base = NULL;
+
+       if (!PyArg_ParseTuple(args, "O:Base PyObjectPlus", &base))
+               return NULL;
+
+       /* the 'base' PyObject may be subclassed (multiple times even)
+        * we need to find the first C++ defined class to check 'type'
+        * is a subclass of the base arguments type.
+        *
+        * This way we can share one tp_new function for every PyObjectPlus
+        *
+        * eg.
+        *
+        * # CustomOb is called 'type' in this C code
+        * class CustomOb(GameTypes.KX_GameObject):
+        *     pass
+        *
+        * # this calls py_base_new(...), the type of 'CustomOb' is checked to be a subclass of the 'cont.owner' type
+        * ob = CustomOb(cont.owner)
+        *
+        * */
+       base_type= Py_TYPE(base);
+       while(base_type && !BGE_PROXY_CHECK_TYPE(base_type))
+               base_type= base_type->tp_base;
+
+       if(base_type==NULL || !BGE_PROXY_CHECK_TYPE(base_type)) {
+               PyErr_SetString(PyExc_TypeError, "can't subclass from a blender game type because the argument given is not a game class or subclass");
+               return NULL;
+       }
+
+       /* use base_type rather then Py_TYPE(base) because we could alredy be subtyped */
+       if(!PyType_IsSubtype(type, base_type)) {
+               PyErr_Format(PyExc_TypeError, "can't subclass blender game type <%s> from <%s> because it is not a subclass", base_type->tp_name, type->tp_name);
+               return NULL;
+       }
+
+       /* invalidate the existing base and return a new subclassed one,
+        * this is a bit dodgy in that it also attaches its self to the existing object
+        * which is not really 'correct' python OO but for our use its OK. */
+
+       PyObjectPlus_Proxy *ret = (PyObjectPlus_Proxy *) type->tp_alloc(type, 0); /* starts with 1 ref, used for the return ref' */
+       ret->ref= base->ref;
+       base->ref= NULL;                /* invalidate! disallow further access */
+
+       ret->py_owns= base->py_owns;
+
+       ret->ref->m_proxy= NULL;
+
+       /* 'base' may be free'd after this func finished but not necessarily
+        * there is no reference to the BGE data now so it will throw an error on access */
+       Py_DECREF(base);
+
+       ret->ref->m_proxy= (PyObject *)ret; /* no need to add a ref because one is added when creating. */
+       Py_INCREF(ret); /* we return a new ref but m_proxy holds a ref so we need to add one */
+
+
+       /* 'ret' will have 2 references.
+        * - One ref is needed because ret->ref->m_proxy holds a refcount to the current proxy.
+        * - Another is needed for returning the value.
+        *
+        * So we should be ok with 2 refs, but for some reason this crashes. so adding a new ref...
+        * */
+
+       return (PyObject *)ret;
+}
+
 void PyObjectPlus::py_base_dealloc(PyObject *self)                             // python wrapper
 {
        PyObjectPlus *self_plus= BGE_PROXY_REF(self);
@@ -104,17 +183,23 @@ void PyObjectPlus::py_base_dealloc(PyObject *self)                                // python wrapper
                        self_plus->m_proxy = NULL; /* Need this to stop ~PyObjectPlus from decrefing m_proxy otherwise its decref'd twice and py-debug crashes */
                        delete self_plus;
                }
-               
+
                BGE_PROXY_REF(self)= NULL; // not really needed
        }
+
+#if 0
+       /* is ok normally but not for subtyping, use tp_free instead. */
        PyObject_DEL( self );
+#else
+       Py_TYPE(self)->tp_free(self);
+#endif
 };
 
 PyObjectPlus::PyObjectPlus() : SG_QList()                              // constructor
 {
        m_proxy= NULL;
 };
-  
+
 /*------------------------------
  * PyObjectPlus Methods        -- Every class, even the abstract one should have a Methods
 ------------------------------*/
@@ -131,20 +216,8 @@ PyAttributeDef PyObjectPlus::Attributes[] = {
 
 
 PyObject* PyObjectPlus::pyattr_get_invalid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{      
-       return PyBool_FromLong(self_v ? 1:0);
-}
-
-PyObject *PyObjectPlus::py_base_repr(PyObject *self)                   // This should be the entry in Type.
 {
-       
-       PyObjectPlus *self_plus= BGE_PROXY_REF(self);
-       if(self_plus==NULL) {
-               PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG);
-               return NULL;
-       }
-       
-       return self_plus->py_repr();  
+       return PyBool_FromLong(self_v ? 1:0);
 }
 
 /* note, this is called as a python 'getset, where the PyAttributeDef is the closure */
index ee69e7d..a18df9d 100644 (file)
@@ -135,7 +135,7 @@ typedef struct {
 #define BGE_PROXY_PYOWNS(_self) (((PyObjectPlus_Proxy *)_self)->py_owns)
 
 /* Note, sometimes we dont care what BGE type this is as long as its a proxy */
-#define BGE_PROXY_CHECK_TYPE(_self) ((_self)->ob_type->tp_dealloc == PyObjectPlus::py_base_dealloc)
+#define BGE_PROXY_CHECK_TYPE(_type) ((_type)->tp_dealloc == PyObjectPlus::py_base_dealloc)
 
 
                                                                // This must be the first line of each 
@@ -439,6 +439,8 @@ public:
         * they take the C++ reference from the PyObjectPlus_Proxy and call
         * its own virtual py_repr, py_base_dealloc ,etc. functions.
         */
+
+       static PyObject*                py_base_new(PyTypeObject *type, PyObject *args, PyObject *kwds); /* allows subclassing */
        static void                     py_base_dealloc(PyObject *self);
        static PyObject*                py_base_repr(PyObject *self);
 
index a9b4449..d8c81f5 100644 (file)
@@ -54,15 +54,17 @@ PyTypeObject CValue::Type = {
        py_base_repr,
        0,
        0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
+       NULL,
+       NULL,
        0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &PyObjectPlus::Type
+       &PyObjectPlus::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef CValue::Methods[] = {
@@ -613,18 +615,9 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix)
        {
                vallie = new CStringValue(_PyUnicode_AsString(pyobj),"");
        } else
-       if (BGE_PROXY_CHECK_TYPE(pyobj)) /* Note, dont let these get assigned to GameObject props, must check elsewhere */
+       if (PyObject_TypeCheck(pyobj, &CValue::Type)) /* Note, dont let these get assigned to GameObject props, must check elsewhere */
        {
-               if (BGE_PROXY_REF(pyobj) && PyObject_TypeCheck((PyObject *)BGE_PROXY_REF(pyobj), &CValue::Type))
-               {
-                       vallie = (static_cast<CValue *>(BGE_PROXY_REF(pyobj)))->AddRef();
-               } else {
-                       
-                       if(BGE_PROXY_REF(pyobj))        /* this is not a CValue */
-                               PyErr_Format(PyExc_TypeError, "%sgame engine python type cannot be used as a property", error_prefix);
-                       else                                            /* PyObjectPlus_Proxy has been removed, cant use */
-                               PyErr_Format(PyExc_SystemError, "%s"BGE_PROXY_ERROR_MSG, error_prefix);
-               }
+               vallie = (static_cast<CValue *>(BGE_PROXY_REF(pyobj)))->AddRef();
        } else
        {
                /* return an error value from the caller */
index 8e54043..04d46e2 100644 (file)
@@ -123,16 +123,15 @@ PyTypeObject SCA_2DFilterActuator::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &SCA_IActuator::Type
+               &SCA_IActuator::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef SCA_2DFilterActuator::Methods[] = {
index fc2f9cd..78e1350 100644 (file)
@@ -115,16 +115,15 @@ PyTypeObject SCA_ANDController::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IController::Type
+       &SCA_IController::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_ANDController::Methods[] = {
index 9d2642b..bdcc923 100644 (file)
@@ -137,16 +137,15 @@ PyTypeObject SCA_ActuatorSensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_ISensor::Type
+       &SCA_ISensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_ActuatorSensor::Methods[] = {
index a14db7d..ddb54c5 100644 (file)
@@ -120,16 +120,15 @@ PyTypeObject SCA_AlwaysSensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_ISensor::Type
+       &SCA_ISensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_AlwaysSensor::Methods[] = {
index db6a6af..11c6996 100644 (file)
@@ -146,16 +146,15 @@ PyTypeObject SCA_DelaySensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_ISensor::Type
+       &SCA_ISensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_DelaySensor::Methods[] = {
index 4b7c462..7cbb728 100644 (file)
@@ -215,16 +215,15 @@ PyTypeObject SCA_IController::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &SCA_ILogicBrick::Type
+               &SCA_ILogicBrick::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef SCA_IController::Methods[] = {
index 9d0b9b3..ccb79a2 100644 (file)
@@ -193,16 +193,15 @@ PyTypeObject SCA_ILogicBrick::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &CValue::Type
+       &CValue::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_ILogicBrick::Methods[] = {
index 698e845..6cd11f9 100644 (file)
@@ -221,51 +221,6 @@ SCA_IActuator* SCA_IObject::FindActuator(const STR_String& actuatorname)
 }
 
 
-
-#if 0
-const MT_Point3& SCA_IObject::ConvertPythonPylist(PyObject* pylist)
-{
-       bool error = false;
-       m_sDummy = MT_Vector3(0,0,0);
-       if (pylist->ob_type == &CListValue::Type)
-       {
-               CListValue* listval = (CListValue*) pylist;
-               int numelem = listval->GetCount();
-               if ( numelem <= 3)
-               {
-                       int index;
-                       for (index = 0;index<numelem;index++)
-                       {
-                               m_sDummy[index] = listval->GetValue(index)->GetNumber();
-                       }
-               }       else
-               {
-                       error = true;
-               }
-               
-       } else
-       {
-               
-               // assert the list is long enough...
-               int numitems = PyList_Size(pylist);
-               if (numitems <= 3)
-               {
-                       int index;
-                       for (index=0;index<numitems;index++)
-                       {
-                               m_sDummy[index] = PyFloat_AsDouble(PyList_GetItem(pylist,index));
-                       }
-               }
-               else
-               {
-                       error = true;
-               }
-
-       }
-       return m_sDummy;
-}
-#endif
-
 void SCA_IObject::Suspend()
 {
        if ((!m_ignore_activity_culling) 
@@ -349,16 +304,15 @@ PyTypeObject SCA_IObject::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &CValue::Type
+       &CValue::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_IObject::Methods[] = {
index d68afeb..4c1e0bd 100644 (file)
@@ -488,16 +488,15 @@ PyTypeObject SCA_ISensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_ILogicBrick::Type
+       &SCA_ILogicBrick::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_ISensor::Methods[] = {
index f91ccff..f55921e 100644 (file)
@@ -268,16 +268,15 @@ PyTypeObject SCA_JoystickSensor::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &SCA_ISensor::Type
+               &SCA_ISensor::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef SCA_JoystickSensor::Methods[] = {
index cbf25f1..999e34d 100644 (file)
@@ -630,16 +630,15 @@ PyTypeObject SCA_KeyboardSensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_ISensor::Type
+       &SCA_ISensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_KeyboardSensor::Methods[] = {
index 8327128..b782c6d 100644 (file)
@@ -307,6 +307,7 @@ void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_I
        controller->Activate(m_triggeredControllerSet);
        // so that the controller knows which sensor has activited it
        // only needed for python controller
+       // Note that this is safe even if the controller is subclassed.
        if (controller->GetType() == &SCA_PythonController::Type)
        {
                SCA_PythonController* pythonController = (SCA_PythonController*)controller;
index 608aa04..49fa19d 100644 (file)
@@ -311,16 +311,15 @@ PyTypeObject SCA_MouseSensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_ISensor::Type
+       &SCA_ISensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_MouseSensor::Methods[] = {
index d4a6a44..c00e5d6 100644 (file)
@@ -115,16 +115,15 @@ PyTypeObject SCA_NANDController::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IController::Type
+       &SCA_IController::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_NANDController::Methods[] = {
index 67e0916..9762d44 100644 (file)
@@ -115,16 +115,15 @@ PyTypeObject SCA_NORController::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IController::Type
+       &SCA_IController::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_NORController::Methods[] = {
index 1dd8166..a526dd8 100644 (file)
@@ -109,16 +109,15 @@ PyTypeObject SCA_ORController::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IController::Type
+       &SCA_IController::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_ORController::Methods[] = {
index f3c0a76..215e30e 100644 (file)
@@ -244,16 +244,15 @@ PyTypeObject SCA_PropertyActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_PropertyActuator::Methods[] = {
index ea928bb..6d2e1a0 100644 (file)
@@ -318,16 +318,15 @@ PyTypeObject SCA_PropertySensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_ISensor::Type
+       &SCA_ISensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_PropertySensor::Methods[] = {
index 7eecb6c..ffd95f0 100644 (file)
@@ -187,7 +187,7 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value)
                        }
                }
        }
-       else if (BGE_PROXY_CHECK_TYPE(value)) {
+       else if (PyObject_TypeCheck(value, &SCA_IActuator::Type)) {
                PyObjectPlus *value_plus= BGE_PROXY_REF(value);
                for(it = lacts.begin(); it!= lacts.end(); ++it) {
                        if( static_cast<SCA_IActuator*>(value_plus) == (*it) ) {
@@ -243,16 +243,15 @@ PyTypeObject SCA_PythonController::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &SCA_IController::Type
+               &SCA_IController::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef SCA_PythonController::Methods[] = {
index 0474cb4..e903d10 100644 (file)
@@ -331,16 +331,15 @@ PyTypeObject SCA_RandomActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_RandomActuator::Methods[] = {
index 9d3501a..e036a77 100644 (file)
@@ -146,16 +146,15 @@ PyTypeObject SCA_RandomSensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_ISensor::Type
+       &SCA_ISensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_RandomSensor::Methods[] = {
index 584a6b1..527adc7 100644 (file)
@@ -119,16 +119,15 @@ PyTypeObject SCA_XNORController::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IController::Type
+       &SCA_IController::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_XNORController::Methods[] = {
index 9f570ac..c091622 100644 (file)
@@ -119,16 +119,15 @@ PyTypeObject SCA_XORController::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IController::Type
+       &SCA_IController::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef SCA_XORController::Methods[] = {
index b6debb4..8bde5dd 100644 (file)
@@ -781,16 +781,15 @@ PyTypeObject BL_Shader::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &PyObjectPlus::Type
+               &PyObjectPlus::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProgram)" )
index 6080591..7cb287d 100644 (file)
@@ -117,16 +117,15 @@ PyTypeObject KX_NetworkMessageActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_NetworkMessageActuator::Methods[] = {
index bfc4904..78dda1f 100644 (file)
@@ -181,16 +181,15 @@ PyTypeObject KX_NetworkMessageSensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_ISensor::Type
+       &SCA_ISensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_NetworkMessageSensor::Methods[] = {
index ea819ce..314becc 100644 (file)
@@ -811,16 +811,15 @@ PyTypeObject KX_BlenderMaterial::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &PyObjectPlus::Type
+               &PyObjectPlus::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
index d025dbf..bfca81f 100644 (file)
@@ -170,16 +170,15 @@ PyTypeObject KX_CDActuator::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &SCA_IActuator::Type
+               &SCA_IActuator::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef KX_CDActuator::Methods[] = {
index 85fa579..f762699 100644 (file)
@@ -550,15 +550,17 @@ PyTypeObject KX_Camera::Type = {
                &KX_GameObject::Sequence,
                &KX_GameObject::Mapping,
                0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
+               NULL,
+               NULL,
                0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &KX_GameObject::Type
+               &KX_GameObject::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, sphereInsideFrustum,
index e2c3ecb..3d3b68e 100644 (file)
@@ -384,16 +384,15 @@ PyTypeObject KX_CameraActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_CameraActuator::Methods[] = {
index 8470c2c..d09eae6 100644 (file)
@@ -580,16 +580,15 @@ PyTypeObject KX_ConstraintActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_ConstraintActuator::Methods[] = {
index 955dd18..ec7bb47 100644 (file)
@@ -99,16 +99,15 @@ PyTypeObject KX_ConstraintWrapper::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &PyObjectPlus::Type
+               &PyObjectPlus::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef KX_ConstraintWrapper::Methods[] = {
index 029f1f0..560c7fa 100644 (file)
@@ -223,16 +223,15 @@ PyTypeObject KX_GameActuator::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &SCA_IActuator::Type
+               &SCA_IActuator::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef KX_GameActuator::Methods[] =
index 5798830..bf80eec 100644 (file)
@@ -1562,7 +1562,7 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val)
                int set= 0;
                
                /* as CValue */
-               if(attr_str && BGE_PROXY_CHECK_TYPE(val)==0) /* dont allow GameObjects for eg to be assigned to CValue props */
+               if(attr_str && PyObject_TypeCheck(val, &PyObjectPlus::Type)==0) /* dont allow GameObjects for eg to be assigned to CValue props */
                {
                        CValue* vallie = self->ConvertPythonToValue(val, ""); /* error unused */
                        
@@ -1672,15 +1672,17 @@ PyTypeObject KX_GameObject::Type = {
                &Sequence,
                &Mapping,
                0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
+               NULL,
+               NULL,
                0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &SCA_IObject::Type
+               &SCA_IObject::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyObject* KX_GameObject::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
index 0edb674..73a370a 100644 (file)
@@ -428,16 +428,15 @@ PyTypeObject KX_IpoActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_IpoActuator::Methods[] = {
index 08542ec..fb385f8 100644 (file)
@@ -289,15 +289,17 @@ PyTypeObject KX_LightObject::Type = {
                &KX_GameObject::Sequence,
                &KX_GameObject::Mapping,
                0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
+               NULL,
+               NULL,
                0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &KX_GameObject::Type
+               &KX_GameObject::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef KX_LightObject::Methods[] = {
index 2c0c31c..96e8f61 100644 (file)
@@ -62,16 +62,15 @@ PyTypeObject KX_MeshProxy::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &CValue::Type
+       &CValue::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_MeshProxy::Methods[] = {
index e38ec70..ba4b47c 100644 (file)
@@ -355,16 +355,15 @@ PyTypeObject KX_MouseFocusSensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_MouseSensor::Type
+       &SCA_MouseSensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_MouseFocusSensor::Methods[] = {
index 64f6b93..1a211a6 100644 (file)
@@ -270,16 +270,15 @@ PyTypeObject KX_NearSensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &KX_TouchSensor::Type
+       &KX_TouchSensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_NearSensor::Methods[] = {
index b13c225..ae340d1 100644 (file)
@@ -341,16 +341,15 @@ PyTypeObject KX_ObjectActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_ObjectActuator::Methods[] = {
index fb2fd61..befa2aa 100644 (file)
@@ -156,16 +156,15 @@ PyTypeObject KX_ParentActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_ParentActuator::Methods[] = {
index fb6bc8b..7bce311 100644 (file)
@@ -129,16 +129,15 @@ PyTypeObject KX_PhysicsObjectWrapper::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &PyObjectPlus::Type
+               &PyObjectPlus::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef KX_PhysicsObjectWrapper::Methods[] = {
index 7fd667e..a1571b1 100644 (file)
@@ -55,16 +55,15 @@ PyTypeObject KX_PolyProxy::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &CValue::Type
+       &CValue::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_PolyProxy::Methods[] = {
index 4d5e7ca..9bc8412 100644 (file)
@@ -255,16 +255,15 @@ PyTypeObject KX_PolygonMaterial::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &PyObjectPlus::Type
+               &PyObjectPlus::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setCustomMaterial, "setCustomMaterial(material)")
index 4fd1608..9ee11c9 100644 (file)
@@ -154,7 +154,7 @@ bool PyVecTo(PyObject* pyval, T& vec)
                
                return true;
        }
-       else if (BGE_PROXY_CHECK_TYPE(pyval))
+       else if (PyObject_TypeCheck(pyval, &PyObjectPlus::Type))
        {       /* note, include this check because PySequence_Check does too much introspection
                 * on the PyObject (like getting its __class__, on a BGE type this means searching up
                 * the parent list each time only to discover its not a sequence.
index b7a573f..8ff0bfd 100644 (file)
 #include "SCA_RandomActuator.h"
 #include "SCA_IController.h"
 
-
-void initPyObjectPlusType(PyTypeObject **parents)
-{
-       int i;
-
-       for (i=0; parents[i]; i++) {
-               if(PyType_Ready(parents[i]) < 0) {
-                       /* This is very very unlikely */
-                       printf("Error, pytype could not initialize, Blender may crash \"%s\"\n", parents[i]->tp_name);
-                       return;
-               }
-
-#if 0
-               PyObject_Print(reinterpret_cast<PyObject *>parents[i], stderr, 0);
-               fprintf(stderr, "\n");
-               PyObject_Print(parents[i]->tp_dict, stderr, 0);
-               fprintf(stderr, "\n\n");
-#endif
-
-       }
-
-        PyObject *dict= NULL;
-
-        while(i) {
-                i--;
-
-                if (dict) {
-                       PyDict_Update(parents[i]->tp_dict, dict);
-                }
-                dict= parents[i]->tp_dict;
-
-#if 1
-               PyObject_Print(reinterpret_cast<PyObject *>(parents[i]), stderr, 0);
-               fprintf(stderr, "\n");
-               PyObject_Print(parents[i]->tp_dict, stderr, 0);
-               fprintf(stderr, "\n\n");
-#endif
-
-       }
-}
-
-/*
-typedef PyObject *(*getter)(PyObject *, void *);
-typedef int (*setter)(PyObject *, PyObject *, void *);
-*/
-
 static void PyType_Ready_ADD(PyObject *dict, PyTypeObject *tp, PyAttributeDef *attributes, int init_getset)
 {
        PyAttributeDef *attr;
@@ -169,9 +123,6 @@ static void PyType_Ready_ADD(PyObject *dict, PyTypeObject *tp, PyAttributeDef *a
 
                        memset(attr_getset, 0, sizeof(PyGetSetDef));
                }
-
-
-               return;
        } else {
        
                PyObject *item;
index 3423fec..e39d375 100644 (file)
@@ -244,16 +244,15 @@ PyTypeObject KX_RadarSensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &KX_NearSensor::Type
+       &KX_NearSensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_RadarSensor::Methods[] = {
index ebdef52..3f27496 100644 (file)
@@ -335,16 +335,15 @@ PyTypeObject KX_RaySensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_ISensor::Type
+       &SCA_ISensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 
 };
 
index 69214db..239c4a0 100644 (file)
@@ -186,16 +186,15 @@ PyTypeObject KX_SCA_AddObjectActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_SCA_AddObjectActuator::Methods[] = {
index 3cff945..423fd0d 100644 (file)
@@ -64,16 +64,15 @@ PyTypeObject KX_SCA_DynamicActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_SCA_DynamicActuator::Methods[] = {
index bf1ada9..47c5c3a 100644 (file)
@@ -107,16 +107,15 @@ PyTypeObject KX_SCA_EndObjectActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_SCA_EndObjectActuator::Methods[] = {
index ee50008..2884bb7 100644 (file)
@@ -67,16 +67,15 @@ PyTypeObject KX_SCA_ReplaceMeshActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_SCA_ReplaceMeshActuator::Methods[] = {
index 5f3ed69..51f5276 100644 (file)
@@ -1629,16 +1629,15 @@ PyTypeObject KX_Scene::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &CValue::Type
+               &CValue::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef KX_Scene::Methods[] = {
index 76869f8..5528e58 100644 (file)
@@ -238,16 +238,15 @@ PyTypeObject KX_SceneActuator::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &SCA_IActuator::Type
+               &SCA_IActuator::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef KX_SceneActuator::Methods[] =
index 0ad699f..673f422 100644 (file)
@@ -249,16 +249,15 @@ PyTypeObject KX_SoundActuator::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &SCA_IActuator::Type
+               &SCA_IActuator::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef KX_SoundActuator::Methods[] = {
index ad21258..9815d62 100644 (file)
@@ -153,16 +153,15 @@ PyTypeObject KX_StateActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_StateActuator::Methods[] = {
index 32c19df..b0cf172 100644 (file)
@@ -310,16 +310,15 @@ PyTypeObject KX_TouchSensor::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_ISensor::Type
+       &SCA_ISensor::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_TouchSensor::Methods[] = {
index 49737a6..e8a06d8 100644 (file)
@@ -447,16 +447,15 @@ PyTypeObject KX_TrackToActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_TrackToActuator::Methods[] = {
index 484c8f3..7001bfc 100644 (file)
@@ -289,16 +289,15 @@ PyTypeObject KX_VehicleWrapper::Type = {
                0,
                0,
                py_base_repr,
-               0,0,0,0,0,0,
-               NULL, //py_base_getattro,
-               NULL, //py_base_setattro,
-               0,
+               0,0,0,0,0,0,0,0,0,
                Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
                0,0,0,0,0,0,0,
                Methods,
                0,
                0,
-               &PyObjectPlus::Type
+               &PyObjectPlus::Type,
+               0,0,0,0,0,0,
+               py_base_new
 };
 
 PyMethodDef KX_VehicleWrapper::Methods[] = {
index 34a84f9..cb8c891 100644 (file)
@@ -53,16 +53,15 @@ PyTypeObject KX_VertexProxy::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &CValue::Type
+       &CValue::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_VertexProxy::Methods[] = {
index 260d764..3561ccd 100644 (file)
@@ -107,16 +107,15 @@ PyTypeObject KX_VisibilityActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       NULL, //py_base_getattro,
-       NULL, //py_base_setattro,
-       0,
+       0,0,0,0,0,0,0,0,0,
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        0,0,0,0,0,0,0,
        Methods,
        0,
        0,
-       &SCA_IActuator::Type
+       &SCA_IActuator::Type,
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_VisibilityActuator::Methods[] = {