BGE Python API
authorCampbell Barton <ideasman42@gmail.com>
Mon, 20 Apr 2009 23:17:52 +0000 (23:17 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 20 Apr 2009 23:17:52 +0000 (23:17 +0000)
Separate getting a normal attribute and getting __dict__, was having to do too a check for __dict__ on each class (multiple times per getattro call from python) when its not used that often.

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

index 7515f3f..3002005 100644 (file)
@@ -1020,6 +1020,10 @@ PyObject* BL_ActionActuator::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* BL_ActionActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int BL_ActionActuator::py_setattro(PyObject *attr, PyObject* value) {
        py_setattro_up(SCA_IActuator);
 }
index 6ae7f71..b3c15c0 100644 (file)
@@ -114,6 +114,7 @@ public:
        KX_PYMETHOD_DOC(BL_ActionActuator,setChannel);
 
        virtual PyObject* py_getattro(PyObject* attr);
+       virtual PyObject*               py_getattro_dict();
        virtual int py_setattro(PyObject* attr, PyObject* value);
 
        static PyObject*        pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
index 62bc99b..a447ffb 100644 (file)
@@ -489,6 +489,10 @@ PyObject* BL_ShapeActionActuator::py_getattro(PyObject* attr) {
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* BL_ShapeActionActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int BL_ShapeActionActuator::py_setattro(PyObject *attr, PyObject* value) {
        py_setattro_up(SCA_IActuator);
 }
index 3bc35ac..d268eef 100644 (file)
@@ -107,6 +107,7 @@ public:
        KX_PYMETHOD_DOC_VARARGS(BL_ShapeActionActuator,SetType);
 
        virtual PyObject* py_getattro(PyObject* attr);
+       virtual PyObject*               py_getattro_dict();
        virtual int py_setattro(PyObject* attr, PyObject* value);
 
        static PyObject*        pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
index dd9b296..7c31a29 100644 (file)
@@ -273,6 +273,10 @@ PyObject* CListValue::py_getattro(PyObject* attr) {
        py_getattro_up(CValue);
 }
 
+PyObject* CListValue::py_getattro_dict() {
+       py_getattro_dict_up(CValue);
+}
+
 
 //////////////////////////////////////////////////////////////////////
 // Construction/Destruction
index 2af5a33..3d88b5a 100644 (file)
@@ -60,6 +60,7 @@ public:
        bool CheckEqual(CValue* first,CValue* second);
 
        virtual PyObject* py_getattro(PyObject* attr);
+       virtual PyObject* py_getattro_dict();
        virtual PyObject* py_repr(void) {
                PyObject *py_proxy= this->GetProxy();
                PyObject *py_list= PySequence_List(py_proxy);
index 6cfa14d..c4daaff 100644 (file)
@@ -143,7 +143,13 @@ PyObject *PyObjectPlus::py_base_getattro(PyObject * self, PyObject *attr)
                PyErr_SetString(PyExc_RuntimeError, BGE_PROXY_ERROR_MSG);
                return NULL;
        }
-       return self_plus->py_getattro(attr); 
+       
+       PyObject *ret= self_plus->py_getattro(attr);
+       
+       if(ret==NULL && (strcmp(PyString_AsString(attr), "__dict__")==0))
+               ret= self_plus->py_getattro_dict();
+       
+       return ret;
 }
 
 /* This should be the entry in Type since it takes the C++ class from PyObjectPlus_Proxy */
@@ -177,9 +183,6 @@ PyObject *PyObjectPlus::py_getattro(PyObject* attr)
 {
        PyObject *descr = PyDict_GetItem(Type.tp_dict, attr); \
        if (descr == NULL) {
-               if (strcmp(PyString_AsString(attr), "__dict__")==0) {
-                       return py_getattr_dict(NULL, Type.tp_dict); /* no Attributes yet */
-               }
                PyErr_Format(PyExc_AttributeError, "attribute \"%s\" not found", PyString_AsString(attr));
                return NULL;
        } else {
@@ -196,6 +199,10 @@ PyObject *PyObjectPlus::py_getattro(PyObject* attr)
        }
 }
 
+PyObject* PyObjectPlus::py_getattro_dict() {
+       return py_getattr_dict(NULL, Type.tp_dict);
+}
+
 int PyObjectPlus::py_delattro(PyObject* attr)
 {
        PyErr_SetString(PyExc_AttributeError, "attribute cant be deleted");
index 370717a..b0ddfa0 100644 (file)
@@ -130,16 +130,12 @@ typedef struct {
                } \
        } else { \
                PyErr_Clear(); \
-               PyObject *rvalue= Parent::py_getattro(attr); \
-                \
-               if (strcmp(PyString_AsString(attr), "__dict__")==0) { \
-                       return py_getattr_dict(rvalue, Type.tp_dict); \
-               } \
-                \
-               return rvalue; \
+               return Parent::py_getattro(attr); \
        } \
        return NULL;
 
+#define py_getattro_dict_up(Parent) \
+       return py_getattr_dict(Parent::py_getattro_dict(), Type.tp_dict);
 
 /*
  * nonzero values are an error for setattr
@@ -434,6 +430,7 @@ public:
        /* These are all virtual python methods that are defined in each class
         * Our own fake subclassing calls these on each class, then calls the parent */
        virtual PyObject*               py_getattro(PyObject *attr);
+       virtual PyObject*               py_getattro_dict();
        virtual int                     py_delattro(PyObject *attr);
        virtual int                     py_setattro(PyObject *attr, PyObject *value);
        virtual PyObject*               py_repr(void);
index 7cb9790..106bd12 100644 (file)
@@ -612,6 +612,10 @@ PyObject*  CValue::py_getattro(PyObject *attr)
        py_getattro_up(PyObjectPlus);
 }
 
+PyObject* CValue::py_getattro_dict() {
+       py_getattro_dict_up(PyObjectPlus);
+}
+
 CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
 {
 
index a687e1a..88186fa 100644 (file)
@@ -225,6 +225,7 @@ public:
 
 
        virtual PyObject*                       py_getattro(PyObject *attr);
+       virtual PyObject*                       py_getattro_dict();
        virtual PyObject*       ConvertValueToPython() {
                return NULL;
        }
index 251a586..9bf03bf 100644 (file)
@@ -157,6 +157,10 @@ PyObject* SCA_2DFilterActuator::py_getattro(PyObject *attr)
     py_getattro_up(SCA_IActuator);
 }
 
+PyObject* SCA_2DFilterActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int SCA_2DFilterActuator::py_setattro(PyObject *attr, PyObject* value) 
 {
        py_setattro_up(SCA_IActuator);
index de0201a..b43dc09 100644 (file)
@@ -71,6 +71,7 @@ public:
        /* --------------------------------------------------------------------- */
 
     virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject* value);
 
 };
index 1cb03f3..e464275 100644 (file)
@@ -145,4 +145,8 @@ PyObject* SCA_ANDController::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IController);
 }
 
+PyObject* SCA_ANDController::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IController);
+}
+
 /* eof */
index fdb93d0..9a359d5 100644 (file)
@@ -49,6 +49,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
 
 };
 
index acd906e..4c85c4f 100644 (file)
@@ -165,6 +165,10 @@ PyObject* SCA_ActuatorSensor::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_ISensor);
 }
 
+PyObject* SCA_ActuatorSensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_ISensor);
+}
+
 int SCA_ActuatorSensor::py_setattro(PyObject *attr, PyObject *value) {
        py_setattro_up(SCA_ISensor);
 }
index 2196099..974b2e4 100644 (file)
@@ -62,6 +62,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* 3. setProperty */
index b7ecb02..874883c 100644 (file)
@@ -143,4 +143,8 @@ PyObject* SCA_AlwaysSensor::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_ISensor);
 }
 
+PyObject* SCA_AlwaysSensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_ISensor);
+}
+
 /* eof */
index 87949ba..769e1e8 100644 (file)
@@ -53,7 +53,7 @@ public:
        /* --------------------------------------------------------------------- */
        
        virtual PyObject* py_getattro(PyObject *attr);
-
+       virtual PyObject* py_getattro_dict();
        
 };
 
index 44a0175..0e4a00e 100644 (file)
@@ -182,6 +182,10 @@ PyObject* SCA_DelaySensor::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_ISensor);
 }
 
+PyObject* SCA_DelaySensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_ISensor);
+}
+
 int SCA_DelaySensor::py_setattro(PyObject *attr, PyObject *value) {
        py_setattro_up(SCA_ISensor);
 }
index 8da76ff..31394fd 100644 (file)
@@ -61,6 +61,7 @@ public:
        /* --------------------------------------------------------------------- */
        
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject*               py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* setProperty */
index 2936742..6a34d7b 100644 (file)
@@ -60,6 +60,7 @@ public:
        /* --------------------------------------------------------------------- */
 
 //     virtual PyObject* py_getattro(PyObject *attr);
+//     virtual PyObject* py_getattro_dict();
 
 };
 
index 3cd750f..02a2591 100644 (file)
@@ -278,12 +278,15 @@ int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef)
        return 0;
 }
 
-PyObject*
-SCA_ILogicBrick::py_getattro(PyObject *attr)
+PyObject* SCA_ILogicBrick::py_getattro(PyObject *attr)
 {
   py_getattro_up(CValue);
 }
 
+PyObject* SCA_ILogicBrick::py_getattro_dict() {
+       py_getattro_dict_up(CValue);
+}
+
 int SCA_ILogicBrick::py_setattro(PyObject *attr, PyObject *value)
 {
        py_setattro_up(CValue);
index e59d05e..f235374 100644 (file)
@@ -80,6 +80,7 @@ public:
        virtual bool            LessComparedTo(SCA_ILogicBrick* other);
        
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        static class SCA_LogicManager*  m_sCurrentLogicManager;
index 7580452..8e599e6 100644 (file)
@@ -418,3 +418,6 @@ PyObject* SCA_IObject::py_getattro(PyObject *attr) {
        py_getattro_up(CValue);
 }
 
+PyObject* SCA_IObject::py_getattro_dict() {
+       py_getattro_dict_up(CValue);
+}
index 44ed3c8..7f63c9f 100644 (file)
@@ -146,6 +146,7 @@ public:
        
        // here come the python forwarded methods
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
 
        virtual int GetGameObjectType() {return -1;}
        
index 68f5653..dde9709 100644 (file)
@@ -459,12 +459,15 @@ PyAttributeDef SCA_ISensor::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject*
-SCA_ISensor::py_getattro(PyObject *attr)
+PyObject* SCA_ISensor::py_getattro(PyObject *attr)
 {
        py_getattro_up(SCA_ILogicBrick);
 }
 
+PyObject* SCA_ISensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_ILogicBrick);
+}
+
 int SCA_ISensor::py_setattro(PyObject *attr, PyObject *value)
 {
        py_setattro_up(SCA_ILogicBrick);
index 6b1c8cc..e2ceec1 100644 (file)
@@ -137,6 +137,7 @@ public:
        /* Python functions: */
        
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        //Deprecated functions ----->
index 1c601ed..a8c6f87 100644 (file)
@@ -339,6 +339,10 @@ PyObject* SCA_JoystickSensor::py_getattro(PyObject *attr)
        py_getattro_up(SCA_ISensor);
 }
 
+PyObject* SCA_JoystickSensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_ISensor);
+}
+
 int SCA_JoystickSensor::py_setattro(PyObject *attr, PyObject *value) 
 {
        py_setattro_up(SCA_ISensor);
index cf3e7e7..20fff66 100644 (file)
@@ -123,6 +123,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* Joystick Index */
index c946156..96969dc 100644 (file)
@@ -664,12 +664,15 @@ PyAttributeDef SCA_KeyboardSensor::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject*
-SCA_KeyboardSensor::py_getattro(PyObject *attr)
+PyObject* SCA_KeyboardSensor::py_getattro(PyObject *attr)
 {
   py_getattro_up(SCA_ISensor);
 }
 
+PyObject* SCA_KeyboardSensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_ISensor);
+}
+
 int SCA_KeyboardSensor::py_setattro(PyObject *attr, PyObject *value)
 {
        py_setattro_up(SCA_ISensor);
index 073b3e6..1dd6ea2 100644 (file)
@@ -111,6 +111,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        //Deprecated functions ----->
index 4dbeb15..0bae676 100644 (file)
@@ -342,6 +342,10 @@ PyObject* SCA_MouseSensor::py_getattro(PyObject *attr)
        py_getattro_up(SCA_ISensor);
 }
 
+PyObject* SCA_MouseSensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_ISensor);
+}
+
 int SCA_MouseSensor::py_setattro(PyObject *attr, PyObject *value)
 {
        py_setattro_up(SCA_ISensor);
index 2d1c496..5282374 100644 (file)
@@ -110,6 +110,7 @@ class SCA_MouseSensor : public SCA_ISensor
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        //Deprecated functions ----->
index 703c9c1..dedf32d 100644 (file)
@@ -145,4 +145,8 @@ PyObject* SCA_NANDController::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IController);
 }
 
+PyObject* SCA_NANDController::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IController);
+}
+
 /* eof */
index 1160091..0ae0ff1 100644 (file)
@@ -49,6 +49,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
 
 };
 
index 06acae5..8cd575f 100644 (file)
@@ -145,4 +145,8 @@ PyObject* SCA_NORController::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IController);
 }
 
+PyObject* SCA_NORController::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IController);
+}
+
 /* eof */
index fc814e2..06cbb70 100644 (file)
@@ -49,6 +49,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject*               py_getattro_dict();
 
 };
 
index 319ff04..a12246e 100644 (file)
@@ -138,4 +138,8 @@ PyObject* SCA_ORController::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IController);
 }
 
+PyObject* SCA_ORController::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IController);
+}
+
 /* eof */
index fdc8148..66f772c 100644 (file)
@@ -50,6 +50,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
 };
 
 #endif //__KX_ORCONTROLLER
index c4db723..beb7a09 100644 (file)
@@ -279,6 +279,10 @@ PyObject* SCA_PropertyActuator::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* SCA_PropertyActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int SCA_PropertyActuator::py_setattro(PyObject *attr, PyObject *value) {
        py_setattro_up(SCA_IActuator);
 }
index bb841cf..a8df08d 100644 (file)
@@ -87,6 +87,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject*  py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        // python wrapped methods
index de8a9fc..c56dd3a 100644 (file)
@@ -356,6 +356,10 @@ PyObject* SCA_PropertySensor::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_ISensor);
 }
 
+PyObject* SCA_PropertySensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_ISensor);
+}
+
 int SCA_PropertySensor::py_setattro(PyObject *attr, PyObject *value) {
        py_setattro_up(SCA_ISensor);
 }
index e1e378a..7abf4d4 100644 (file)
@@ -90,6 +90,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* 1. getType */
index 3a72d9b..b9df198 100644 (file)
@@ -395,6 +395,10 @@ PyObject* SCA_RandomActuator::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* SCA_RandomActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int SCA_RandomActuator::py_setattro(PyObject *attr, PyObject *value)
 {
        py_setattro_up(SCA_IActuator);
index 8f58ed0..310e8a7 100644 (file)
@@ -97,6 +97,7 @@ class SCA_RandomActuator : public SCA_IActuator
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        static PyObject* pyattr_get_seed(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
index 5ead82d..494b7a3 100644 (file)
@@ -170,6 +170,10 @@ PyObject* SCA_RandomSensor::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_ISensor);
 }
 
+PyObject* SCA_RandomSensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_ISensor);
+}
+
 int SCA_RandomSensor::py_setattro(PyObject *attr, PyObject *value)
 {
        py_setattro_up(SCA_ISensor);
index 7646926..63a96dd 100644 (file)
@@ -61,6 +61,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* 1. setSeed                                                            */
index e9bb37e..145afa6 100644 (file)
@@ -149,4 +149,8 @@ PyObject* SCA_XNORController::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IController);
 }
 
+PyObject* SCA_XNORController::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IController);
+}
+
 /* eof */
index c992d5f..4aad576 100644 (file)
@@ -49,6 +49,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
 
 };
 
index 791a139..4dfba3a 100644 (file)
@@ -149,4 +149,8 @@ PyObject* SCA_XORController::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IController);
 }
 
+PyObject* SCA_XORController::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IController);
+}
+
 /* eof */
index 065b31f..feb9f2e 100644 (file)
@@ -49,6 +49,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
 
 };
 
index 88d9200..2b3612e 100644 (file)
@@ -734,6 +734,10 @@ PyObject* BL_Shader::py_getattro(PyObject *attr)
        py_getattro_up(PyObjectPlus);
 }
 
+PyObject* BL_Shader::py_getattro_dict() {
+       py_getattro_dict_up(PyObjectPlus);
+}
+
 
 PyMethodDef BL_Shader::Methods[] = 
 {
index 08cad50..7db40e7 100644 (file)
@@ -203,6 +203,7 @@ public:
 
        // Python interface
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual PyObject* py_repr(void) { return PyString_FromFormat("BL_Shader\n\tvertex shader:%s\n\n\tfragment shader%s\n\n", vertProg, fragProg); }
 
        // -----------------------------------
index 2483a6b..9c36a89 100644 (file)
@@ -157,6 +157,10 @@ PyObject* KX_NetworkMessageActuator::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_NetworkMessageActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_NetworkMessageActuator::py_setattro(PyObject *attr, PyObject *value) {
        py_setattro_up(SCA_IActuator);
 }
index 850f825..cf92fd4 100644 (file)
@@ -62,6 +62,7 @@ public:
        /* ------------------------------------------------------------ */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        // Deprecated ----->
index 7782567..b1b9c0e 100644 (file)
@@ -227,6 +227,10 @@ PyObject* KX_NetworkMessageSensor::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_ISensor);
 }
 
+PyObject* KX_NetworkMessageSensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_ISensor);
+}
+
 int KX_NetworkMessageSensor::py_setattro(PyObject *attr, PyObject *value) {
        return SCA_ISensor::py_setattro(attr, value);
 }
index ac0e880..3abba7c 100644 (file)
@@ -73,6 +73,7 @@ public:
        /* ------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        // Deprecated ----->
index 8493320..2edfe4b 100644 (file)
@@ -784,6 +784,10 @@ PyObject* KX_BlenderMaterial::py_getattro(PyObject *attr)
        py_getattro_up(PyObjectPlus);
 }
 
+PyObject* KX_BlenderMaterial::py_getattro_dict() {
+       py_getattro_dict_up(PyObjectPlus);
+}
+
 int KX_BlenderMaterial::py_setattro(PyObject *attr, PyObject *pyvalue)
 {
        return PyObjectPlus::py_setattro(attr, pyvalue);
index 48d4730..57cdde3 100644 (file)
@@ -83,6 +83,7 @@ public:
        
        // --------------------------------
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int       py_setattro(PyObject *attr, PyObject *pyvalue);
        virtual PyObject* py_repr(void) { return PyString_FromString(mMaterial->matname.ReadPtr()); }
 
index 121d451..6e318cd 100644 (file)
@@ -220,6 +220,10 @@ PyObject* KX_CDActuator::py_getattro(PyObject *attr)
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_CDActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_CDActuator::py_setattro(PyObject *attr, PyObject *value)
 {
        py_setattro_up(SCA_IActuator);
index b674755..2fd05ab 100644 (file)
@@ -82,6 +82,7 @@ public:
        /* -------------------------------------------------------------------- */
 
        virtual PyObject*  py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        // Deprecated ----->
index c857542..f84ce23 100644 (file)
@@ -544,6 +544,10 @@ PyObject* KX_Camera::py_getattro(PyObject *attr)
        py_getattro_up(KX_GameObject);
 }
 
+PyObject* KX_Camera::py_getattro_dict() {
+       py_getattro_dict_up(KX_GameObject);
+}
+
 int KX_Camera::py_setattro(PyObject *attr, PyObject *value)
 {      
        py_setattro_up(KX_GameObject);
index 4accd4b..6f818cb 100644 (file)
@@ -278,6 +278,7 @@ public:
        KX_PYMETHOD_DOC_NOARGS(KX_Camera, setOnTop);    
 
        virtual PyObject* py_getattro(PyObject *attr); /* lens, near, far, projection_matrix */
+       virtual PyObject* py_getattro_dict();
        virtual int       py_setattro(PyObject *attr, PyObject *pyvalue);
        
        static PyObject*        pyattr_get_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
index 355cdbb..2ef7abf 100644 (file)
@@ -425,6 +425,10 @@ PyObject* KX_CameraActuator::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_CameraActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_CameraActuator::py_setattro(PyObject *attr, PyObject* value) {
        py_setattro_up(SCA_IActuator);
 }
index 9298e1e..efa4e2f 100644 (file)
@@ -121,6 +121,7 @@ private :
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject* value);
 
        /* set object to look at */
index 1ce7fac..00fed43 100644 (file)
@@ -640,6 +640,10 @@ PyObject* KX_ConstraintActuator::py_getattro(PyObject *attr)
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_ConstraintActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_ConstraintActuator::py_setattro(PyObject *attr, PyObject* value)
 {
        py_setattro_up(SCA_IActuator);
index 98f6fcd..84512c0 100644 (file)
@@ -144,6 +144,7 @@ protected:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject* value);
 
        static int pyattr_check_direction(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
index 7c3abb4..c537c9a 100644 (file)
@@ -87,12 +87,16 @@ PyParentObject KX_ConstraintWrapper::Parents[] = {
        NULL
 };
 
-PyObject*      KX_ConstraintWrapper::py_getattro(PyObject *attr)
+//here you can search for existing data members (like mass,friction etc.)
+PyObject* KX_ConstraintWrapper::py_getattro(PyObject *attr)
 {
-       //here you can search for existing data members (like mass,friction etc.)
        py_getattro_up(PyObjectPlus);
 }
 
+PyObject* KX_ConstraintWrapper::py_getattro_dict() {
+       py_getattro_dict_up(PyObjectPlus);
+}
+
 int    KX_ConstraintWrapper::py_setattro(PyObject *attr,PyObject* pyobj)
 {
        int result = 1;
index 6e67d84..3270d57 100644 (file)
@@ -36,6 +36,7 @@ class KX_ConstraintWrapper : public PyObjectPlus
 {
        Py_Header;
        virtual PyObject*               py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int                     py_setattro(PyObject *attr, PyObject *value);
 public:
        KX_ConstraintWrapper(PHY_ConstraintType ctype,int constraintId,class PHY_IPhysicsEnvironment* physenv,PyTypeObject *T = &Type);
index 8b587c6..0a41139 100644 (file)
@@ -253,12 +253,15 @@ PyAttributeDef KX_GameActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject*
-KX_GameActuator::py_getattro(PyObject *attr)
+PyObject* KX_GameActuator::py_getattro(PyObject *attr)
 {
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_GameActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_GameActuator::py_setattro(PyObject *attr, PyObject *value)
 {
        py_setattro_up(SCA_IActuator);
index 570cb2e..b2b1d6e 100644 (file)
@@ -78,6 +78,7 @@ protected:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        // Deprecated functions ----->
index bea0fcf..1f4c9c2 100644 (file)
@@ -1153,8 +1153,6 @@ PyAttributeDef KX_GameObject::Attributes[] = {
        KX_PYATTRIBUTE_RW_FUNCTION("localScaling",      KX_GameObject, pyattr_get_localScaling, pyattr_set_localScaling),
        KX_PYATTRIBUTE_RO_FUNCTION("worldScaling",      KX_GameObject, pyattr_get_worldScaling),
        
-       KX_PYATTRIBUTE_RO_FUNCTION("__dict__",  KX_GameObject, pyattr_get_dir_dict),
-       
        /* Experemental, dont rely on these yet */
        KX_PYATTRIBUTE_RO_FUNCTION("sensors",           KX_GameObject, pyattr_get_sensors),
        KX_PYATTRIBUTE_RO_FUNCTION("controllers",       KX_GameObject, pyattr_get_controllers),
@@ -1703,37 +1701,6 @@ PyObject* KX_GameObject::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE
        return resultlist;
 }
 
-/* __dict__ only for the purpose of giving useful dir() results */
-PyObject* KX_GameObject::pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-       KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
-       PyObject *dict_str = PyString_FromString("__dict__");
-       PyObject *dict= py_getattr_dict(self->SCA_IObject::py_getattro(dict_str), Type.tp_dict);
-       Py_DECREF(dict_str);
-       
-       if(dict==NULL)
-               return NULL;
-       
-       /* Not super fast getting as a list then making into dict keys but its only for dir() */
-       PyObject *list= self->ConvertKeysToPython();
-       if(list)
-       {
-               int i;
-               for(i=0; i<PyList_Size(list); i++)
-                       PyDict_SetItem(dict, PyList_GET_ITEM(list, i), Py_None);
-       }
-       else
-               PyErr_Clear();
-       
-       Py_DECREF(list);
-       
-       /* Add m_attr_dict if we have it */
-       if(self->m_attr_dict)
-               PyDict_Update(dict, self->m_attr_dict);
-       
-       return dict;
-}
-
 /* We need these because the macros have a return in them */
 PyObject* KX_GameObject::py_getattro__internal(PyObject *attr)
 {
@@ -1772,6 +1739,35 @@ PyObject* KX_GameObject::py_getattro(PyObject *attr)
        return object;
 }
 
+PyObject* KX_GameObject::py_getattro_dict() {
+       //py_getattro_dict_up(SCA_IObject);
+       PyObject *dict= py_getattr_dict(SCA_IObject::py_getattro_dict(), Type.tp_dict);
+       if(dict==NULL)
+               return NULL;
+       
+       /* normally just return this but KX_GameObject has some more items */
+
+       
+       /* Not super fast getting as a list then making into dict keys but its only for dir() */
+       PyObject *list= ConvertKeysToPython();
+       if(list)
+       {
+               int i;
+               for(i=0; i<PyList_Size(list); i++)
+                       PyDict_SetItem(dict, PyList_GET_ITEM(list, i), Py_None);
+       }
+       else
+               PyErr_Clear();
+       
+       Py_DECREF(list);
+       
+       /* Add m_attr_dict if we have it */
+       if(m_attr_dict)
+               PyDict_Update(dict, m_attr_dict);
+       
+       return dict;
+}
+
 int KX_GameObject::py_setattro(PyObject *attr, PyObject *value)        // py_setattro method
 {
        int ret;
index ec02dc1..e81429d 100644 (file)
@@ -816,6 +816,7 @@ public:
         */
        
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);               // py_setattro method
        virtual int                             py_delattro(PyObject *attr);
        virtual PyObject* py_repr(void)
@@ -904,9 +905,6 @@ public:
        static int                      pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
        static PyObject*        pyattr_get_meshes(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
        
-       /* for dir(), python3 uses __dir__() */
-       static PyObject*        pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-       
        /* Experemental! */
        static PyObject*        pyattr_get_sensors(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
        static PyObject*        pyattr_get_controllers(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
index f04e3c7..df80085 100644 (file)
@@ -477,6 +477,10 @@ PyObject* KX_IpoActuator::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_IpoActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_IpoActuator::py_setattro(PyObject *attr, PyObject *value)       // py_setattro method
 {
        py_setattro_up(SCA_IActuator);
index 184ad55..fb3b0eb 100644 (file)
@@ -142,6 +142,7 @@ public:
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
        
        //KX_PYMETHOD_DOC
index 713838c..a1eb08e 100644 (file)
@@ -216,6 +216,10 @@ PyObject* KX_LightObject::py_getattro(PyObject *attr)
        py_getattro_up(KX_GameObject);
 }
 
+PyObject* KX_LightObject::py_getattro_dict() {
+       py_getattro_dict_up(KX_GameObject);
+}
+
 
 int KX_LightObject::py_setattro(PyObject *attr, PyObject *pyvalue)
 {
index 4559954..e5d48b6 100644 (file)
@@ -63,6 +63,7 @@ public:
        void Update();
        
        virtual PyObject* py_getattro(PyObject *attr); /* lens, near, far, projection_matrix */
+       virtual PyObject* py_getattro_dict();
        virtual int       py_setattro(PyObject *attr, PyObject *pyvalue);
 
        virtual bool IsLight(void) { return true; }
index 6be1da5..cefa2ba 100644 (file)
@@ -108,6 +108,10 @@ PyObject* KX_MeshProxy::py_getattro(PyObject *attr)
        py_getattro_up(SCA_IObject);
 }
 
+PyObject* KX_MeshProxy::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IObject);
+}
+
 int KX_MeshProxy::py_setattro(PyObject *attr, PyObject* value)
 {
        py_setattro_up(SCA_IObject);
index aeecefc..ce9e8fc 100644 (file)
@@ -58,6 +58,7 @@ public:
 
 // stuff for python integration
        virtual PyObject*  py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject* value);
 
        KX_PYMETHOD(KX_MeshProxy,GetNumMaterials);      // Deprecated
index 87b5c81..d141aa4 100644 (file)
@@ -387,6 +387,10 @@ PyObject* KX_MouseFocusSensor::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_MouseSensor);
 }
 
+PyObject* KX_MouseFocusSensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_MouseSensor);
+}
+
 
 const char KX_MouseFocusSensor::GetHitObject_doc[] = 
 "getHitObject()\n"
index 8de1f88..5a9618f 100644 (file)
@@ -89,7 +89,8 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
        /* --------------------------------------------------------------------- */
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
-       virtual PyObject*  py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
 
        KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRayTarget);
        KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRaySource);
index 0489b70..ce519e1 100644 (file)
@@ -334,6 +334,10 @@ PyObject* KX_NearSensor::py_getattro(PyObject *attr)
        py_getattro_up(KX_TouchSensor);
 }
 
+PyObject* KX_NearSensor::py_getattro_dict() {
+       py_getattro_dict_up(KX_TouchSensor);
+}
+
 int KX_NearSensor::py_setattro(PyObject*attr, PyObject* value)
 {
        py_setattro_up(KX_TouchSensor);
index 26c5feb..144f75f 100644 (file)
@@ -83,6 +83,7 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject* value);
 
        //No methods
index 861c575..c115a8f 100644 (file)
@@ -340,6 +340,10 @@ PyObject* KX_ObjectActuator::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IActuator);
 };
 
+PyObject* KX_ObjectActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 /* 1. set ------------------------------------------------------------------ */
 /* Removed! */
 
index a812942..ab5fbe4 100644 (file)
@@ -154,6 +154,7 @@ public:
        /* --------------------------------------------------------------------- */
        
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
 
        KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForce);
        KX_PYMETHOD_VARARGS(KX_ObjectActuator,SetForce);
index 0093cf5..79e8267 100644 (file)
@@ -211,6 +211,10 @@ PyObject* KX_ParentActuator::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_ParentActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_ParentActuator::py_setattro(PyObject *attr, PyObject* value) {
        py_setattro_up(SCA_IActuator);
 }
index f9f0b73..a9bf730 100644 (file)
@@ -77,6 +77,7 @@ class KX_ParentActuator : public SCA_IActuator
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject* value);
 
        /* These are used to get and set m_ob */
index fda639c..c0c15b5 100644 (file)
@@ -136,11 +136,14 @@ PyParentObject KX_PhysicsObjectWrapper::Parents[] = {
        NULL
 };
 
-PyObject*      KX_PhysicsObjectWrapper::py_getattro(PyObject *attr)
+PyObject* KX_PhysicsObjectWrapper::py_getattro(PyObject *attr)
 {
        py_getattro_up(PyObjectPlus);
 }
 
+PyObject* KX_PhysicsObjectWrapper::py_getattro_dict() {
+       py_getattro_dict_up(PyObjectPlus);
+}
 
 int    KX_PhysicsObjectWrapper::py_setattro(PyObject *attr,PyObject *pyobj)
 {
index 7e10dc3..1b59686 100644 (file)
@@ -37,6 +37,7 @@ class KX_PhysicsObjectWrapper : public PyObjectPlus
        Py_Header;
 
        virtual PyObject*               py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int                     py_setattro(PyObject *attr, PyObject *value);
 public:
        KX_PhysicsObjectWrapper(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsEnvironment* physenv,PyTypeObject *T = &Type);
index 2e5dd72..fefea23 100644 (file)
@@ -159,6 +159,10 @@ PyObject* KX_PolyProxy::py_getattro(PyObject *attr)
        py_getattro_up(SCA_IObject);
 }
 
+PyObject* KX_PolyProxy::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IObject);
+}
+
 KX_PolyProxy::KX_PolyProxy(const RAS_MeshObject*mesh, RAS_Polygon* polygon)
 :      m_polygon(polygon),
        m_mesh((RAS_MeshObject*)mesh)
index 275e65d..88a0685 100644 (file)
@@ -54,6 +54,7 @@ public:
 
 // stuff for python integration
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
 
        KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterialIndex)
        KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getNumVertex)
index 46d0448..2d5a5f9 100644 (file)
@@ -237,6 +237,10 @@ PyObject* KX_PolygonMaterial::py_getattro(PyObject *attr)
        py_getattro_up(PyObjectPlus);
 }
 
+PyObject* KX_PolygonMaterial::py_getattro_dict() {
+       py_getattro_dict_up(PyObjectPlus);
+}
+
 int KX_PolygonMaterial::py_setattro(PyObject *attr, PyObject *value)
 {
        py_setattro_up(PyObjectPlus);
index 9865a66..e581605 100644 (file)
@@ -117,6 +117,7 @@ public:
        KX_PYMETHOD_DOC(KX_PolygonMaterial, loadProgram);
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int       py_setattro(PyObject *attr, PyObject *pyvalue);
        virtual PyObject* py_repr(void) { return PyString_FromString(m_material ? ((ID *)m_material)->name+2 : ""); }
        
index 8277e7e..d1075f9 100644 (file)
@@ -304,6 +304,10 @@ PyObject* KX_RadarSensor::py_getattro(PyObject *attr)
        py_getattro_up(KX_NearSensor);
 }
 
+PyObject* KX_RadarSensor::py_getattro_dict() {
+       py_getattro_dict_up(KX_NearSensor);
+}
+
 int KX_RadarSensor::py_setattro(PyObject *attr, PyObject* value)
 {
        py_setattro_up(KX_NearSensor);
index c3a9416..8389a2a 100644 (file)
@@ -90,6 +90,7 @@ public:
        };
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject* value);
 
        //Deprecated ----->
index 06c04db..360aa1a 100644 (file)
@@ -449,6 +449,10 @@ PyObject* KX_RaySensor::py_getattro(PyObject *attr) {
        py_getattro_up(SCA_ISensor);
 }
 
+PyObject* KX_RaySensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_ISensor);
+}
+
 int KX_RaySensor::py_setattro(PyObject *attr, PyObject *value) {
        py_setattro_up(SCA_ISensor);
 }
index a5d7d15..558840e 100644 (file)
@@ -87,6 +87,7 @@ public:
 
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
        
        // Deprecated ----->
index 56d94a8..b5aa7a2 100644 (file)
@@ -260,6 +260,10 @@ PyObject* KX_SCA_AddObjectActuator::py_getattro(PyObject *attr)
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_SCA_AddObjectActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_SCA_AddObjectActuator::py_setattro(PyObject *attr, PyObject* value) 
 {
        py_setattro_up(SCA_IActuator);
index 4ece5a6..6746b7d 100644 (file)
@@ -111,6 +111,7 @@ public:
        Update();
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject* value);
 
                SCA_IObject*    
index 9c9cdcd..dd3250f 100644 (file)
@@ -97,6 +97,10 @@ PyObject* KX_SCA_DynamicActuator::py_getattro(PyObject *attr)
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_SCA_DynamicActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_SCA_DynamicActuator::py_setattro(PyObject *attr, PyObject* value)
 {
        py_setattro_up(SCA_IActuator);
index 9985512..4add707 100644 (file)
@@ -75,6 +75,7 @@ class KX_SCA_DynamicActuator : public SCA_IActuator
 
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* 1. setOperation */
index 3b42577..c0dc6ea 100644 (file)
@@ -136,4 +136,8 @@ PyObject* KX_SCA_EndObjectActuator::py_getattro(PyObject *attr)
   py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_SCA_EndObjectActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 /* eof */
index 2940246..70d72f1 100644 (file)
@@ -65,6 +65,7 @@ class KX_SCA_EndObjectActuator : public SCA_IActuator
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        
 }; /* end of class KX_EditObjectActuator : public SCA_PropertyActuator */
 
index 38f8d58..b7135a5 100644 (file)
@@ -99,6 +99,10 @@ PyObject* KX_SCA_ReplaceMeshActuator::py_getattro(PyObject *attr)
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_SCA_ReplaceMeshActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_SCA_ReplaceMeshActuator::py_setattro(PyObject *attr, PyObject* value) 
 {
        py_setattro_up(SCA_IActuator);
index 7a18df2..0e7f785 100644 (file)
@@ -72,6 +72,7 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator
        void    InstantReplaceMesh();
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject* value);
 
        static PyObject* pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
index aa7bd65..f91c467 100644 (file)
@@ -1630,19 +1630,6 @@ PyObject* KX_Scene::pyattr_get_active_camera(void *self_v, const KX_PYATTRIBUTE_
        return self->GetActiveCamera()->GetProxy();
 }
 
-/* __dict__ only for the purpose of giving useful dir() results */
-PyObject* KX_Scene::pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
-{
-       KX_Scene* self= static_cast<KX_Scene*>(self_v);
-       /* Useually done by py_getattro_up but in this case we want to include m_attr_dict dict */
-       PyObject *dict_str= PyString_FromString("__dict__");
-       PyObject *dict= py_getattr_dict(self->PyObjectPlus::py_getattro(dict_str), Type.tp_dict);
-       Py_DECREF(dict_str);
-       
-       PyDict_Update(dict, self->m_attr_dict);
-       return dict;
-}
-
 PyAttributeDef KX_Scene::Attributes[] = {
        KX_PYATTRIBUTE_RO_FUNCTION("name",                      KX_Scene, pyattr_get_name),
        KX_PYATTRIBUTE_RO_FUNCTION("objects",           KX_Scene, pyattr_get_objects),
@@ -1651,7 +1638,6 @@ PyAttributeDef KX_Scene::Attributes[] = {
        KX_PYATTRIBUTE_BOOL_RO("activity_culling",      KX_Scene, m_activity_culling),
        KX_PYATTRIBUTE_FLOAT_RW("activity_culling_radius", 0.5f, FLT_MAX, KX_Scene, m_activity_box_radius),
        KX_PYATTRIBUTE_BOOL_RO("dbvt_culling",          KX_Scene, m_dbvt_culling),
-       KX_PYATTRIBUTE_RO_FUNCTION("__dict__",          KX_Scene, pyattr_get_dir_dict),
        { NULL }        //Sentinel
 };
 
@@ -1685,6 +1671,18 @@ PyObject* KX_Scene::py_getattro(PyObject *attr)
        return object;
 }
 
+PyObject* KX_Scene::py_getattro_dict() {
+       //py_getattro_dict_up(PyObjectPlus);
+       
+       PyObject *dict= py_getattr_dict(PyObjectPlus::py_getattro_dict(), Type.tp_dict);
+       if(dict==NULL)
+               return NULL;
+       
+       /* normally just return this but KX_Scene has some more items */
+       
+       PyDict_Update(dict, m_attr_dict);
+       return dict;
+}
 
 int KX_Scene::py_setattro(PyObject *attr, PyObject *value)
 {
index a06c66e..83a4692 100644 (file)
@@ -593,12 +593,10 @@ public:
        static PyObject*        pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
        static PyObject*        pyattr_get_objects(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
        static PyObject*        pyattr_get_active_camera(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-       
-       /* for dir(), python3 uses __dir__() */
-       static PyObject*        pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
-       
 
        virtual PyObject* py_getattro(PyObject *attr); /* name, active_camera, gravity, suspended, viewport, framing, activity_culling, activity_culling_radius */
+       virtual PyObject* py_getattro_dict();
+       
        virtual int py_setattro(PyObject *attr, PyObject *pyvalue);
        virtual int py_delattro(PyObject *attr);
        virtual PyObject* py_repr(void) { return PyString_FromString(GetName().ReadPtr()); }
index f54d854..c525aeb 100644 (file)
@@ -281,6 +281,10 @@ PyObject* KX_SceneActuator::py_getattro(PyObject *attr)
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_SceneActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_SceneActuator::py_setattro(PyObject *attr, PyObject *value)
 {
        py_setattro_up(SCA_IActuator);
index 803c510..315e97e 100644 (file)
@@ -93,6 +93,7 @@ class KX_SceneActuator : public SCA_IActuator
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* 1. set                                                                */
index 412be49..4103da4 100644 (file)
@@ -340,6 +340,10 @@ PyObject* KX_SoundActuator::py_getattro(PyObject *attr)
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_SoundActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_SoundActuator::py_setattro(PyObject *attr, PyObject* value) {
        py_setattro_up(SCA_IActuator);
 }
index d5e678b..ad58087 100644 (file)
@@ -81,6 +81,7 @@ public:
        /* -------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject* value);
 
        KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, startSound);
index 976e7ea..16512dc 100644 (file)
@@ -156,7 +156,11 @@ PyAttributeDef KX_StateActuator::Attributes[] = {
 PyObject* KX_StateActuator::py_getattro(PyObject *attr)
 {
        py_getattro_up(SCA_IActuator);
-};
+}
+
+PyObject* KX_StateActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
 
 int KX_StateActuator::py_setattro(PyObject *attr, PyObject* value)
 {
index 4a64894..7e7056b 100644 (file)
@@ -76,6 +76,7 @@ class KX_StateActuator : public SCA_IActuator
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject* value);
        //KX_PYMETHOD_DOC
        KX_PYMETHOD_DOC_VARARGS(KX_StateActuator,SetOperation);
index 5a6e8e6..8995a0c 100644 (file)
@@ -296,6 +296,10 @@ PyObject* KX_TouchSensor::py_getattro(PyObject *attr)
        py_getattro_up(SCA_ISensor);
 }
 
+PyObject* KX_TouchSensor::py_getattro_dict() {
+       py_getattro_dict_up(SCA_ISensor);
+}
+
 int KX_TouchSensor::py_setattro(PyObject *attr, PyObject *value)
 {
        py_setattro_up(SCA_ISensor);
index 15ef653..4bcc313 100644 (file)
@@ -121,6 +121,7 @@ public:
        /* --------------------------------------------------------------------- */
        
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        //Deprecated ----->
index fbf43de..808bf0a 100644 (file)
@@ -509,6 +509,10 @@ PyObject* KX_TrackToActuator::py_getattro(PyObject *attr)
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_TrackToActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_TrackToActuator::py_setattro(PyObject *attr, PyObject* value)
 {
        py_setattro_up(SCA_IActuator);
index 99505f9..a17147c 100644 (file)
@@ -73,6 +73,7 @@ class KX_TrackToActuator : public SCA_IActuator
 
        /* Python part */
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject* value);
 
        /* These are used to get and set m_ob */
index 1a6fb19..5a0ec35 100644 (file)
@@ -303,6 +303,10 @@ PyObject*  KX_VehicleWrapper::py_getattro(PyObject *attr)
        py_getattro_up(PyObjectPlus);
 }
 
+PyObject* KX_VehicleWrapper::py_getattro_dict() {
+       py_getattro_dict_up(PyObjectPlus);
+}
+
 int    KX_VehicleWrapper::py_setattro(PyObject *attr,PyObject* pyobj)
 {
        /* TODO - strange setattr, needs updating */
index de7fe75..c2b5e3d 100644 (file)
@@ -13,6 +13,7 @@ class KX_VehicleWrapper : public PyObjectPlus
 {
        Py_Header;
        virtual PyObject*               py_getattro(PyObject *attr);
+       virtual PyObject*               py_getattro_dict();
        virtual int                     py_setattro(PyObject *attr, PyObject *value);
 
        std::vector<PHY_IMotionState*> m_motionStates;
index 88f6333..e5078bf 100644 (file)
@@ -159,6 +159,10 @@ KX_VertexProxy::py_getattro(PyObject *attr)
   py_getattro_up(SCA_IObject);
 }
 
+PyObject* KX_VertexProxy::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IObject);
+}
+
 int    KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
 {
   char *attr_str= PyString_AsString(attr);
index 67a15d9..50fe6b2 100644 (file)
@@ -55,6 +55,7 @@ public:
 
 // stuff for python integration
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int    py_setattro(PyObject *attr, PyObject *pyvalue);
 
        KX_PYMETHOD_NOARGS(KX_VertexProxy,GetXYZ);
index ba59d0d..9b18495 100644 (file)
@@ -143,6 +143,10 @@ PyObject* KX_VisibilityActuator::py_getattro(PyObject *attr)
        py_getattro_up(SCA_IActuator);
 }
 
+PyObject* KX_VisibilityActuator::py_getattro_dict() {
+       py_getattro_dict_up(SCA_IActuator);
+}
+
 int KX_VisibilityActuator::py_setattro(PyObject *attr, PyObject *value)
 {
        py_setattro_up(SCA_IActuator);
index 04633bc..45aba50 100644 (file)
@@ -70,6 +70,7 @@ class KX_VisibilityActuator : public SCA_IActuator
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual PyObject* py_getattro_dict();
        virtual int py_setattro(PyObject *attr, PyObject *value);
 
        // Deprecated ----->