Python BGE API
authorCampbell Barton <ideasman42@gmail.com>
Fri, 3 Apr 2009 14:51:06 +0000 (14:51 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 3 Apr 2009 14:51:06 +0000 (14:51 +0000)
- Initialize python types with PyType_Ready, which adds methods to the type dictionary.
- use Pythons get/setattro (uses a python string for the attribute rather then char*). Using basic C strings seems nice but internally python converts them to python strings and discards them for most functions that accept char arrays.
- Method lookups use the PyTypes dictionary (should be faster then Py_FindMethod)
- Renamed __getattr -> py_base_getattro, _getattr -> py_getattro, __repr -> py_base_repr, py_delattro, py_getattro_self etc.

From here is possible to put all the parent classes methods into each python types dictionary to avoid nested lookups (api has 4 levels of lookups in some places), tested this but its not ready yet.

Simple tests for getting a method within a loop show this to be between 0.5 and 3.2x faster then using Py_FindMethod()

128 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_PythonController.cpp
source/gameengine/GameLogic/SCA_PythonController.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_PythonInit.cpp
source/gameengine/Ketsji/KX_PythonInitTypes.cpp [new file with mode: 0644]
source/gameengine/Ketsji/KX_PythonInitTypes.h [new file with mode: 0644]
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 88f75ea..943bb68 100644 (file)
@@ -965,18 +965,21 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
 /* ------------------------------------------------------------------------- */
 
 PyTypeObject BL_ActionActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "BL_ActionActuator",
                sizeof(BL_ActionActuator),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -1032,17 +1035,20 @@ PyAttributeDef BL_ActionActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* BL_ActionActuator::_getattr(const char *attr) {
-       if (!strcmp(attr, "action"))
+PyObject* BL_ActionActuator::py_getattro(PyObject *attr) {
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "action"))
                return PyString_FromString(m_action->id.name+2);
-       PyObject* object = _getattr_self(Attributes, this, attr);
+
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int BL_ActionActuator::_setattr(const char *attr, PyObject* value) {
-       if (!strcmp(attr, "action"))
+int BL_ActionActuator::py_setattro(PyObject *attr, PyObject* value) {
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "action"))
        {
                if (!PyString_Check(value))
                {
@@ -1072,8 +1078,8 @@ int BL_ActionActuator::_setattr(const char *attr, PyObject* value) {
                m_action = action;
                return 0;
        }
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
\ No newline at end of file
index 6161048..7160dd4 100644 (file)
@@ -110,8 +110,8 @@ public:
 
        KX_PYMETHOD_DOC(BL_ActionActuator,setChannel);
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject* value);
+       virtual PyObject* py_getattro(PyObject* attr);
+       virtual int py_setattro(PyObject* attr, PyObject* value);
 
        /* attribute check */
        static int CheckFrame(void *self, const PyAttributeDef*)
index 74953a9..c53be46 100644 (file)
@@ -420,18 +420,21 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame)
 /* Integration hooks ------------------------------------------------------- */
 
 PyTypeObject BL_ShapeActionActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "BL_ShapeActionActuator",
                sizeof(BL_ShapeActionActuator),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
-               0, //&MyPyCompare,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -481,17 +484,19 @@ PyAttributeDef BL_ShapeActionActuator::Attributes[] = {
 };
 
 
-PyObject* BL_ShapeActionActuator::_getattr(const char *attr) {
-       if (!strcmp(attr, "action"))
+PyObject* BL_ShapeActionActuator::py_getattro(PyObject* attr) {
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "action"))
                return PyString_FromString(m_action->id.name+2);
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int BL_ShapeActionActuator::_setattr(const char *attr, PyObject* value) {
-       if (!strcmp(attr, "action"))
+int BL_ShapeActionActuator::py_setattro(PyObject *attr, PyObject* value) {
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "action"))
        {
                if (!PyString_Check(value))
                {
@@ -521,10 +526,10 @@ int BL_ShapeActionActuator::_setattr(const char *attr, PyObject* value) {
                m_action = action;
                return 0;
        }
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 /*     setStart                                                              */
index 7f2431b..ea25d66 100644 (file)
@@ -103,8 +103,8 @@ public:
        KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetType);
        KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetType);
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject* value);
+       virtual PyObject* py_getattro(PyObject* attr);
+       virtual int py_setattro(PyObject* attr, PyObject* value);
 
        static int CheckBlendTime(void *self, const PyAttributeDef*)
        {
index aa84cab..15eb883 100644 (file)
@@ -193,7 +193,7 @@ static  PyMappingMethods instance_as_mapping = {
 
 
 PyTypeObject CListValue::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,                              /*ob_size*/
        "CListValue",                   /*tp_name*/
        sizeof(CListValue),             /*tp_basicsize*/
@@ -201,16 +201,19 @@ PyTypeObject CListValue::Type = {
        /* methods */
        PyDestructor,                   /*tp_dealloc*/
        0,                              /*tp_print*/
-       __getattr,                      /*tp_getattr*/
-       __setattr,                      /*tp_setattr*/
+       0,                      /*tp_getattr*/
+       0,                      /*tp_setattr*/
        0,                              /*tp_compare*/
-       __repr,                         /*tp_repr*/
+       py_base_repr,                           /*tp_repr*/
        0,                              /*tp_as_number*/
        &listvalue_as_sequence, /*tp_as_sequence*/
        &instance_as_mapping,           /*tp_as_mapping*/
        0,                              /*tp_hash*/
        0,                              /*tp_call */
-       0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -238,8 +241,8 @@ PyAttributeDef CListValue::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* CListValue::_getattr(const char *attr) {
-       _getattr_up(CValue);
+PyObject* CListValue::py_getattro(PyObject* attr) {
+       py_getattro_up(CValue);
 }
 
 
index 104e3e6..f936298 100644 (file)
@@ -59,7 +59,7 @@ public:
 
        bool CheckEqual(CValue* first,CValue* second);
 
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject* attr);
 
        KX_PYMETHOD_O(CListValue,append);
        KX_PYMETHOD_NOARGS(CListValue,reverse);
index 417388b..ed6932b 100644 (file)
 ------------------------------*/
 
 PyTypeObject PyObjectPlus::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,                              /*ob_size*/
        "PyObjectPlus",                 /*tp_name*/
        sizeof(PyObjectPlus),           /*tp_basicsize*/
        0,                              /*tp_itemsize*/
        /* methods */
-       PyDestructor,                   /*tp_dealloc*/
-       0,                              /*tp_print*/
-       __getattr,                      /*tp_getattr*/
-       __setattr,                      /*tp_setattr*/
-       0,                              /*tp_compare*/
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       PyDestructor,
+       0,
+       0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -103,37 +106,41 @@ PyParentObject PyObjectPlus::Parents[] = {&PyObjectPlus::Type, NULL};
 /*------------------------------
  * PyObjectPlus attributes     -- attributes
 ------------------------------*/
-PyObject *PyObjectPlus::_getattr(const char *attr)
+PyObject *PyObjectPlus::py_getattro(PyObject* attr)
 {
-       if (!strcmp(attr, "__doc__") && GetType()->tp_doc)
-               return PyString_FromString(GetType()->tp_doc);
-
+       PyObject *descr = PyDict_GetItem(Type.tp_dict, attr); \
+       if (descr == NULL) {
+               PyErr_SetString(PyExc_AttributeError, "attribute not found");
+               return NULL;
+       } else {
+               return PyCFunction_New(((PyMethodDescrObject *)descr)->d_method, (PyObject *)this); \
+       }
   //if (streq(attr, "type"))
   //  return Py_BuildValue("s", (*(GetParents()))->tp_name);
-
-  return Py_FindMethod(Methods, this, attr);
 }
 
-int PyObjectPlus::_delattr(const char *attr)
+int PyObjectPlus::py_delattro(PyObject* attr)
 {
        PyErr_SetString(PyExc_AttributeError, "attribute cant be deleted");
        return 1;
 }
 
-int PyObjectPlus::_setattr(const char *attr, PyObject *value)
+int PyObjectPlus::py_setattro(PyObject *attr, PyObject* value)
 {
-       //return PyObject::_setattr(attr,value);
+       //return PyObject::py_setattro(attr,value);
        //cerr << "Unknown attribute" << endl;
        PyErr_SetString(PyExc_AttributeError, "attribute cant be set");
        return 1;
 }
 
-PyObject *PyObjectPlus::_getattr_self(const PyAttributeDef attrlist[], void *self, const char *attr)
+PyObject *PyObjectPlus::py_getattro_self(const PyAttributeDef attrlist[], void *self, PyObject *attr)
 {
+       char *attr_str= PyString_AsString(attr);
+
        const PyAttributeDef *attrdef;
        for (attrdef=attrlist; attrdef->m_name != NULL; attrdef++)
        {
-               if (!strcmp(attr, attrdef->m_name))
+               if (!strcmp(attr_str, attrdef->m_name))
                {
                        if (attrdef->m_type == KX_PYATTRIBUTE_TYPE_DUMMY)
                        {
@@ -242,16 +249,17 @@ PyObject *PyObjectPlus::_getattr_self(const PyAttributeDef attrlist[], void *sel
        return NULL;
 }
 
-int PyObjectPlus::_setattr_self(const PyAttributeDef attrlist[], void *self, const char *attr, PyObject *value)
+int PyObjectPlus::py_setattro_self(const PyAttributeDef attrlist[], void *self, PyObject *attr, PyObject *value)
 {
        const PyAttributeDef *attrdef;
        void *undoBuffer = NULL;
        void *sourceBuffer = NULL;
        size_t bufferSize = 0;
+       char *attr_str= PyString_AsString(attr);
 
        for (attrdef=attrlist; attrdef->m_name != NULL; attrdef++)
        {
-               if (!strcmp(attr, attrdef->m_name))
+               if (!strcmp(attr_str, attrdef->m_name))
                {
                        if (attrdef->m_access == KX_PYATTRIBUTE_RO ||
                                attrdef->m_type == KX_PYATTRIBUTE_TYPE_DUMMY)
@@ -684,7 +692,7 @@ int PyObjectPlus::_setattr_self(const PyAttributeDef attrlist[], void *self, con
 /*------------------------------
  * PyObjectPlus repr           -- representations
 ------------------------------*/
-PyObject *PyObjectPlus::_repr(void)
+PyObject *PyObjectPlus::py_repr(void)
 {
        PyErr_SetString(PyExc_SystemError, "Representation not overridden by object.");  
        return NULL;
@@ -726,7 +734,7 @@ PyObject *PyObjectPlus::Py_isA(PyObject *value)             // Python wrapper for isA
     Py_RETURN_FALSE;
 }
 
-/* Utility function called by the macro _getattr_up()
+/* Utility function called by the macro py_getattro_up()
  * for getting ob.__dict__() values from our PyObject
  * this is used by python for doing dir() on an object, so its good
  * if we return a list of attributes and methods.
index 345eb8c..77963c0 100644 (file)
@@ -72,6 +72,8 @@ typedef int Py_ssize_t;
 #define PY_METHODCHAR const char *
 #endif
 
+#include "descrobject.h"
+
 static inline void Py_Fatal(const char *M) {
        fprintf(stderr, "%s\n", M);
        exit(-1);
@@ -90,21 +92,27 @@ static inline void Py_Fatal(const char *M) {
 
 
 
-                                                               // This defines the _getattr_up macro
+                                                               // This defines the py_getattro_up macro
                                                                // which allows attribute and method calls
                                                                // to be properly passed up the hierarchy.
-#define _getattr_up(Parent) \
-       PyObject *rvalue = Py_FindMethod(Methods, this, attr); \
+
+#define py_getattro_up(Parent) \
+       PyObject *rvalue; \
+       PyObject *descr = PyDict_GetItem(Type.tp_dict, attr); \
         \
-       if (rvalue == NULL) { \
+       if (descr == NULL) { \
                PyErr_Clear(); \
-               rvalue = Parent::_getattr(attr); \
+               rvalue = Parent::py_getattro(attr); \
+       } else { \
+               rvalue= PyCFunction_New(((PyMethodDescrObject *)descr)->d_method, (PyObject *)this); \
        } \
-       if (strcmp(attr, "__dict__")==0) {\
+       \
+       if (strcmp(PyString_AsString(attr), "__dict__")==0) {\
                rvalue = _getattr_dict(rvalue, Methods, Attributes); \
        } \
        return rvalue; \
 
+
 /**
  * These macros are helpfull when embedding Python routines. The second
  * macro is one that also requires a documentation string
@@ -361,29 +369,29 @@ public:
 //               Py_DECREF(this);
 //       };                            // decref method
        
-       virtual PyObject *_getattr(const char *attr);                   // _getattr method
-       static  PyObject *__getattr(PyObject * PyObj, char *attr)       // This should be the entry in Type. 
+       virtual PyObject *py_getattro(PyObject *attr);                  // py_getattro method
+       static  PyObject *py_base_getattro(PyObject * PyObj, PyObject *attr)    // This should be the entry in Type. 
        {
-               return ((PyObjectPlus*) PyObj)->_getattr(attr); 
+               return ((PyObjectPlus*) PyObj)->py_getattro(attr); 
        }
-       static PyObject *_getattr_self(const PyAttributeDef attrlist[], void *self, const char *attr);
-       static int _setattr_self(const PyAttributeDef attrlist[], void *self, const char *attr, PyObject *value);
+       static PyObject *py_getattro_self(const PyAttributeDef attrlist[], void *self, PyObject *attr);
+       static int py_setattro_self(const PyAttributeDef attrlist[], void *self, PyObject *attr, PyObject *value);
        
-       virtual int _delattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);                // _setattr method
-       static  int __setattr(PyObject *PyObj,                  // This should be the entry in Type. 
-                               char *attr, 
+       virtual int py_delattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);               // py_setattro method
+       static  int py_base_setattro(PyObject *PyObj,                   // This should be the entry in Type. 
+                               PyObject *attr, 
                                PyObject *value)
        { 
-               if (!value)
-                       return ((PyObjectPlus*) PyObj)->_delattr(attr);
-               return ((PyObjectPlus*) PyObj)->_setattr(attr, value);  
+               if (value==NULL)
+                       return ((PyObjectPlus*) PyObj)->py_delattro(attr);
+               return ((PyObjectPlus*) PyObj)->py_setattro(attr, value);  
        }
        
-       virtual PyObject *_repr(void);                          // _repr method
-       static  PyObject *__repr(PyObject *PyObj)                       // This should be the entry in Type.
+       virtual PyObject *py_repr(void);                                // py_repr method
+       static  PyObject *py_base_repr(PyObject *PyObj)                 // This should be the entry in Type.
        {
-               return ((PyObjectPlus*) PyObj)->_repr();  
+               return ((PyObjectPlus*) PyObj)->py_repr();  
        }
        
                                                                        // isA methods
index 3650976..8b910b9 100644 (file)
@@ -139,19 +139,22 @@ static PyNumberMethods cvalue_as_number = {
 
 
 PyTypeObject CValue::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "CValue",
        sizeof(CValue),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
+       0,
+       0,
        &MyPyCompare,
-       __repr,
+       py_base_repr,
        &cvalue_as_number,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -695,9 +698,10 @@ PyAttributeDef CValue::Attributes[] = {
 };
 
 
-PyObject*      CValue::_getattr(const char *attr)
+PyObject*      CValue::py_getattro(PyObject *attr)
 {
-       CValue* resultattr = GetProperty(attr);
+       char *attr_str= PyString_AsString(attr);
+       CValue* resultattr = GetProperty(attr_str);
        if (resultattr)
        {
                PyObject* pyconvert = resultattr->ConvertValueToPython();
@@ -707,7 +711,7 @@ PyObject*   CValue::_getattr(const char *attr)
                else
                        return resultattr; // also check if it's already in pythoninterpreter!
        }
-       _getattr_up(PyObjectPlus);
+       py_getattro_up(PyObjectPlus);
 }
 
 CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
@@ -769,26 +773,28 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
 
 }
 
-int    CValue::_delattr(const char *attr)
+int    CValue::py_delattro(PyObject *attr)
 {
-       if (RemoveProperty(STR_String(attr)))
+       char *attr_str= PyString_AsString(attr);
+       if (RemoveProperty(STR_String(attr_str)))
                return 0;
        
-       PyErr_Format(PyExc_AttributeError, "attribute \"%s\" dosnt exist", attr);
+       PyErr_Format(PyExc_AttributeError, "attribute \"%s\" dosnt exist", attr_str);
        return 1;
 }
 
-int    CValue::_setattr(const char *attr, PyObject* pyobj)
+int    CValue::py_setattro(PyObject *attr, PyObject* pyobj)
 {
        CValue* vallie = ConvertPythonToValue(pyobj);
        if (vallie)
        {
-               CValue* oldprop = GetProperty(attr);
+               char *attr_str= PyString_AsString(attr);
+               CValue* oldprop = GetProperty(attr_str);
                
                if (oldprop)
                        oldprop->SetValue(vallie);
                else
-                       SetProperty(attr, vallie);
+                       SetProperty(attr_str, vallie);
                
                vallie->Release();
        } else
@@ -796,7 +802,7 @@ int CValue::_setattr(const char *attr, PyObject* pyobj)
                return 1; /* ConvertPythonToValue sets the error message */
        }
        
-       //PyObjectPlus::_setattr(attr,value);
+       //PyObjectPlus::py_setattro(attr,value);
        return 0;
 };
 
index 4678ab1..7a2816a 100644 (file)
@@ -217,14 +217,14 @@ public:
 
        CValue(PyTypeObject *T = &Type);
        //static PyObject*      PyMake(PyObject*,PyObject*);
-       virtual PyObject *_repr(void)
+       virtual PyObject *py_repr(void)
        {
                return Py_BuildValue("s",(const char*)GetText());
        }
 
 
 
-       virtual PyObject*                       _getattr(const char *attr);
+       virtual PyObject*                       py_getattro(PyObject *attr);
 
        void    SpecialRelease()
        {
@@ -251,8 +251,8 @@ public:
        virtual CValue* ConvertPythonToValue(PyObject* pyobj);
 
 
-       virtual int                             _delattr(const char *attr);
-       virtual int                             _setattr(const char *attr, PyObject* value);
+       virtual int                             py_delattro(PyObject *attr);
+       virtual int                             py_setattro(PyObject *attr, PyObject* value);
        
        virtual PyObject* ConvertKeysToPython( void );
        
index 0b41072..9d4dc1f 100644 (file)
@@ -80,18 +80,21 @@ bool SCA_2DFilterActuator::Update()
 
 
 PyTypeObject SCA_2DFilterActuator::Type = {
-        PyObject_HEAD_INIT(&PyType_Type)
+        PyObject_HEAD_INIT(NULL)
         0,
         "SCA_2DFilterActuator",
         sizeof(SCA_2DFilterActuator),
         0,
-        PyDestructor,
-        0,
-        __getattr,
-        __setattr,
-        0, 
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               PyDestructor,
+               0,
+               0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -114,6 +117,6 @@ PyAttributeDef SCA_2DFilterActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* SCA_2DFilterActuator::_getattr(const char *attr) {
-    _getattr_up(SCA_IActuator);
+PyObject* SCA_2DFilterActuator::py_getattro(PyObject *attr) {
+    py_getattro_up(SCA_IActuator);
 }
index 9da0500..f69c680 100644 (file)
@@ -38,7 +38,7 @@ public:
     virtual bool Update();
 
     virtual CValue* GetReplica();
-    virtual PyObject* _getattr(const char *attr);
+    virtual PyObject* py_getattro(PyObject *attr);
 
 };
 #endif
index de67037..cb62e2b 100644 (file)
@@ -107,18 +107,21 @@ CValue* SCA_ANDController::GetReplica()
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_ANDController::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_ANDController",
        sizeof(SCA_ANDController),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -138,8 +141,8 @@ PyAttributeDef SCA_ANDController::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* SCA_ANDController::_getattr(const char *attr) {
-       _getattr_up(SCA_IController);
+PyObject* SCA_ANDController::py_getattro(PyObject *attr) {
+       py_getattro_up(SCA_IController);
 }
 
 /* eof */
index eba7e1b..fdb93d0 100644 (file)
@@ -48,7 +48,7 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
 
 };
 
index d5c3e19..ed7aa66 100644 (file)
@@ -122,18 +122,21 @@ void SCA_ActuatorSensor::Update()
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_ActuatorSensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_ActuatorSensor",
        sizeof(SCA_ActuatorSensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -158,11 +161,11 @@ PyAttributeDef SCA_ActuatorSensor::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* SCA_ActuatorSensor::_getattr(const char *attr) {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+PyObject* SCA_ActuatorSensor::py_getattro(PyObject *attr) {
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_ISensor); /* implicit return! */
+       py_getattro_up(SCA_ISensor); /* implicit return! */
 }
 
 int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*)
@@ -177,11 +180,11 @@ int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*)
        return 1;
 }
 
-int SCA_ActuatorSensor::_setattr(const char *attr, PyObject *value) {
-       int ret = _setattr_self(Attributes, this, attr, value);
+int SCA_ActuatorSensor::py_setattro(PyObject *attr, PyObject *value) {
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_ISensor::_setattr(attr, value);
+       return SCA_ISensor::py_setattro(attr, value);
 }
 
 /* 3. getActuator */
index 75ee08f..9bc873e 100644 (file)
@@ -61,8 +61,8 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* 3. setProperty */
        KX_PYMETHOD_DOC(SCA_ActuatorSensor,SetActuator);
index e2125b8..a7b0e5a 100644 (file)
@@ -105,18 +105,21 @@ bool SCA_AlwaysSensor::Evaluate(CValue* event)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_AlwaysSensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_AlwaysSensor",
        sizeof(SCA_AlwaysSensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
-       0, //&MyPyCompare,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -136,8 +139,8 @@ PyAttributeDef SCA_AlwaysSensor::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* SCA_AlwaysSensor::_getattr(const char *attr) {
-       _getattr_up(SCA_ISensor);
+PyObject* SCA_AlwaysSensor::py_getattro(PyObject *attr) {
+       py_getattro_up(SCA_ISensor);
 }
 
 /* eof */
index ebe6ba8..87949ba 100644 (file)
@@ -52,7 +52,7 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
        
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
 
        
 };
index 7330570..5082caa 100644 (file)
@@ -131,18 +131,21 @@ bool SCA_DelaySensor::Evaluate(CValue* event)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_DelaySensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_DelaySensor",
        sizeof(SCA_DelaySensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
-       0, //&MyPyCompare,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -175,18 +178,18 @@ PyAttributeDef SCA_DelaySensor::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* SCA_DelaySensor::_getattr(const char *attr) {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+PyObject* SCA_DelaySensor::py_getattro(PyObject *attr) {
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_ISensor);
+       py_getattro_up(SCA_ISensor);
 }
 
-int SCA_DelaySensor::_setattr(const char *attr, PyObject *value) {
-       int ret = _setattr_self(Attributes, this, attr, value);
+int SCA_DelaySensor::py_setattro(PyObject *attr, PyObject *value) {
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_ISensor::_setattr(attr, value);
+       return SCA_ISensor::py_setattro(attr, value);
 }
 
 
index 491eee6..f9e3d61 100644 (file)
@@ -60,8 +60,8 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
        
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* setProperty */
        KX_PYMETHOD_DOC(SCA_DelaySensor,SetDelay);
index 79c26ee..2936742 100644 (file)
@@ -59,7 +59,7 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-//     virtual PyObject* _getattr(const char *attr);
+//     virtual PyObject* py_getattro(PyObject *attr);
 
 };
 
index 3cefe63..45ebd87 100644 (file)
@@ -217,18 +217,21 @@ CValue* SCA_ILogicBrick::GetEvent()
 /* python stuff */
 
 PyTypeObject SCA_ILogicBrick::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_ILogicBrick",
        sizeof(SCA_ILogicBrick),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
-       0, //&MyPyCompare,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -275,20 +278,20 @@ int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef)
 }
 
 PyObject*
-SCA_ILogicBrick::_getattr(const char *attr)
+SCA_ILogicBrick::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-  _getattr_up(CValue);
+  py_getattro_up(CValue);
 }
 
-int SCA_ILogicBrick::_setattr(const char *attr, PyObject *value)
+int SCA_ILogicBrick::py_setattro(PyObject *attr, PyObject *value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return CValue::_setattr(attr, value);
+       return CValue::py_setattro(attr, value);
 }
 
 
index 70d4994..c098f9d 100644 (file)
@@ -79,8 +79,8 @@ public:
 
        virtual bool            LessComparedTo(SCA_ILogicBrick* other);
        
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        static class SCA_LogicManager*  m_sCurrentLogicManager;
 
index 976665a..d1ce377 100644 (file)
@@ -375,18 +375,21 @@ void SCA_IObject::SetState(unsigned int state)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_IObject::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_IObject",
        sizeof(SCA_IObject),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
-       0, //&MyPyCompare,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -411,7 +414,7 @@ PyAttributeDef SCA_IObject::Attributes[] = {
 };
 
 
-PyObject* SCA_IObject::_getattr(const char *attr) {
-       _getattr_up(CValue);
+PyObject* SCA_IObject::py_getattro(PyObject *attr) {
+       py_getattro_up(CValue);
 }
 
index d47353b..44ed3c8 100644 (file)
@@ -145,7 +145,7 @@ public:
 //     const class MT_Point3&  ConvertPythonPylist(PyObject* pylist);
        
        // here come the python forwarded methods
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
 
        virtual int GetGameObjectType() {return -1;}
        
index 0d7dffc..8a40c0c 100644 (file)
@@ -393,18 +393,21 @@ KX_PYMETHODDEF_DOC_NOARGS(SCA_ISensor, reset,
 /* ----------------------------------------------- */
 
 PyTypeObject SCA_ISensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_ISensor",
        sizeof(SCA_ISensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -451,38 +454,40 @@ PyAttributeDef SCA_ISensor::Attributes[] = {
        KX_PYATTRIBUTE_INT_RW("frequency",0,100000,true,SCA_ISensor,m_pulse_frequency),
        KX_PYATTRIBUTE_BOOL_RW("invert",SCA_ISensor,m_invert),
        KX_PYATTRIBUTE_BOOL_RW("level",SCA_ISensor,m_level),
-       // make these properties read-only in _setaddr, must still implement them in _getattr
+       // make these properties read-only in _setaddr, must still implement them in py_getattro
        KX_PYATTRIBUTE_DUMMY("triggered"),
        KX_PYATTRIBUTE_DUMMY("positive"),
        { NULL }        //Sentinel
 };
 
 PyObject*
-SCA_ISensor::_getattr(const char *attr)
+SCA_ISensor::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       if (!strcmp(attr, "triggered"))
+       
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "triggered"))
        {
                int retval = 0;
                if (SCA_PythonController::m_sCurrentController)
                        retval = SCA_PythonController::m_sCurrentController->IsTriggered(this);
                return PyInt_FromLong(retval);
        }
-       if (!strcmp(attr, "positive"))
+       if (!strcmp(attr_str, "positive"))
        {       
                int retval = IsPositiveTrigger();
                return PyInt_FromLong(retval);
        }
-       _getattr_up(SCA_ILogicBrick);
+       py_getattro_up(SCA_ILogicBrick);
 }
 
-int SCA_ISensor::_setattr(const char *attr, PyObject *value)
+int SCA_ISensor::py_setattro(PyObject *attr, PyObject *value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_ILogicBrick::_setattr(attr, value);
+       return SCA_ILogicBrick::py_setattro(attr, value);
 }
 /* eof */
index 23f2c76..ce7b66d 100644 (file)
@@ -136,8 +136,8 @@ public:
 
        /* Python functions: */
        
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        //Deprecated functions ----->
        KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsPositive);
index 6b8779e..0cfd684 100644 (file)
@@ -275,18 +275,21 @@ bool SCA_JoystickSensor::isValid(SCA_JoystickSensor::KX_JOYSENSORMODE m)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_JoystickSensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "SCA_JoystickSensor",
                sizeof(SCA_JoystickSensor),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
-               0, //&MyPyCompare,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -330,8 +333,8 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = {
        KX_PYATTRIBUTE_INT_RW("button",0,100,false,SCA_JoystickSensor,m_button),
        KX_PYATTRIBUTE_INT_LIST_RW_CHECK("axis",0,3,true,SCA_JoystickSensor,m_axis,2,CheckAxis),
        KX_PYATTRIBUTE_INT_LIST_RW_CHECK("hat",0,12,true,SCA_JoystickSensor,m_hat,2,CheckHat),
-       // dummy attributes will just be read-only in _setattr
-       // you still need to defined them in _getattr
+       // dummy attributes will just be read-only in py_setattro
+       // you still need to defined them in py_getattro
        KX_PYATTRIBUTE_DUMMY("axisPosition"),
        KX_PYATTRIBUTE_DUMMY("numAxis"),
        KX_PYATTRIBUTE_DUMMY("numButtons"),
@@ -340,38 +343,40 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* SCA_JoystickSensor::_getattr(const char *attr) {
+PyObject* SCA_JoystickSensor::py_getattro(PyObject *attr) {
        SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
-       if (!strcmp(attr, "axisPosition")) {
+       char *attr_str= PyString_AsString(attr);
+       
+       if (!strcmp(attr_str, "axisPosition")) {
                if(joy)
                        return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21());
                else
                        return Py_BuildValue("[iiii]", 0, 0, 0, 0);
        }
-       if (!strcmp(attr, "numAxis")) {
+       if (!strcmp(attr_str, "numAxis")) {
                return PyInt_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
        }
-       if (!strcmp(attr, "numButtons")) {
+       if (!strcmp(attr_str, "numButtons")) {
                return PyInt_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
        }
-       if (!strcmp(attr, "numHats")) {
+       if (!strcmp(attr_str, "numHats")) {
                return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 );
        }
-       if (!strcmp(attr, "connected")) {
+       if (!strcmp(attr_str, "connected")) {
                return PyBool_FromLong( joy ? joy->Connected() : 0 );
        }
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_ISensor);
+       py_getattro_up(SCA_ISensor);
 }
 
-int SCA_JoystickSensor::_setattr(const char *attr, PyObject *value) 
+int SCA_JoystickSensor::py_setattro(PyObject *attr, PyObject *value) 
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_ISensor::_setattr(attr, value);
+       return SCA_ISensor::py_setattro(attr, value);
 }
 
 
index 49d220c..ccdd210 100644 (file)
@@ -121,8 +121,8 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* Joystick Index */
        KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetIndex);
index bf470da..fc1b5be 100644 (file)
@@ -778,18 +778,21 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus,
 /* ------------------------------------------------------------------------- */
 
 PyTypeObject SCA_KeyboardSensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_KeyboardSensor",
        sizeof(SCA_KeyboardSensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
-       0, //&MyPyCompare,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -828,18 +831,18 @@ PyAttributeDef SCA_KeyboardSensor::Attributes[] = {
 };
 
 PyObject*
-SCA_KeyboardSensor::_getattr(const char *attr)
+SCA_KeyboardSensor::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-  _getattr_up(SCA_ISensor);
+  py_getattro_up(SCA_ISensor);
 }
 
-int SCA_KeyboardSensor::_setattr(const char *attr, PyObject *value)
+int SCA_KeyboardSensor::py_setattro(PyObject *attr, PyObject *value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_ISensor::_setattr(attr, value);
+       return SCA_ISensor::py_setattro(attr, value);
 }
index bc2f863..c579b6a 100644 (file)
@@ -126,8 +126,8 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        //Deprecated functions ----->
        /** 1. GetKey : check which key this sensor looks at */
index 19365fb..c5f6fda 100644 (file)
@@ -102,7 +102,7 @@ int SCA_MouseSensor::UpdateHotkey(void *self, const PyAttributeDef*)
        default:
                ; /* ignore, no hotkey */
        }
-       // return value is used in _setattr(), 
+       // return value is used in py_setattro(), 
        // 0=attribute checked ok (see Attributes array definition)
        return 0;
 }
@@ -300,18 +300,21 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
 /* ------------------------------------------------------------------------- */
 
 PyTypeObject SCA_MouseSensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_MouseSensor",
        sizeof(SCA_MouseSensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -338,20 +341,20 @@ PyAttributeDef SCA_MouseSensor::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* SCA_MouseSensor::_getattr(const char *attr) 
+PyObject* SCA_MouseSensor::py_getattro(PyObject *attr) 
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_ISensor);
+       py_getattro_up(SCA_ISensor);
 }
 
-int SCA_MouseSensor::_setattr(const char *attr, PyObject *value)
+int SCA_MouseSensor::py_setattro(PyObject *attr, PyObject *value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_ISensor::_setattr(attr, value);
+       return SCA_ISensor::py_setattro(attr, value);
 }
 
 /* eof */
index 30b43fe..7341056 100644 (file)
@@ -109,8 +109,8 @@ class SCA_MouseSensor : public SCA_ISensor
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        //Deprecated functions ----->
        /* read x-coordinate */
index 2bc6a3e..bddd5f4 100644 (file)
@@ -107,18 +107,21 @@ CValue* SCA_NANDController::GetReplica()
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_NANDController::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_NANDController",
        sizeof(SCA_NANDController),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -138,8 +141,8 @@ PyAttributeDef SCA_NANDController::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* SCA_NANDController::_getattr(const char *attr) {
-       _getattr_up(SCA_IController);
+PyObject* SCA_NANDController::py_getattro(PyObject *attr) {
+       py_getattro_up(SCA_IController);
 }
 
 /* eof */
index d88504c..1160091 100644 (file)
@@ -48,7 +48,7 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
 
 };
 
index 98ba77d..3ee0735 100644 (file)
@@ -107,18 +107,21 @@ CValue* SCA_NORController::GetReplica()
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_NORController::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_NORController",
        sizeof(SCA_NORController),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -138,8 +141,8 @@ PyAttributeDef SCA_NORController::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* SCA_NORController::_getattr(const char *attr) {
-       _getattr_up(SCA_IController);
+PyObject* SCA_NORController::py_getattro(PyObject *attr) {
+       py_getattro_up(SCA_IController);
 }
 
 /* eof */
index 45b639f..fc814e2 100644 (file)
@@ -48,7 +48,7 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
 
 };
 
index ba61640..91d5e56 100644 (file)
@@ -99,18 +99,21 @@ void SCA_ORController::Trigger(SCA_LogicManager* logicmgr)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_ORController::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_ORController",
        sizeof(SCA_ORController),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
-       0, //&MyPyCompare,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -131,8 +134,8 @@ PyAttributeDef SCA_ORController::Attributes[] = {
 };
 
 
-PyObject* SCA_ORController::_getattr(const char *attr) {
-       _getattr_up(SCA_IController);
+PyObject* SCA_ORController::py_getattro(PyObject *attr) {
+       py_getattro_up(SCA_IController);
 }
 
 /* eof */
index 9a6e9e7..fdc8148 100644 (file)
@@ -49,7 +49,7 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
 };
 
 #endif //__KX_ORCONTROLLER
index 28a3b6b..e1f3034 100644 (file)
@@ -218,18 +218,21 @@ void SCA_PropertyActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_PropertyActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_PropertyActuator",
        sizeof(SCA_PropertyActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -257,18 +260,18 @@ PyAttributeDef SCA_PropertyActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* SCA_PropertyActuator::_getattr(const char *attr) {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+PyObject* SCA_PropertyActuator::py_getattro(PyObject *attr) {
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int SCA_PropertyActuator::_setattr(const char *attr, PyObject *value) {
-       int ret = _setattr_self(Attributes, this, attr, value);
+int SCA_PropertyActuator::py_setattro(PyObject *attr, PyObject *value) {
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 /* 1. setProperty                                                        */
index 444d928..6a97571 100644 (file)
@@ -85,8 +85,8 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject*  _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject*  py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        // python wrapped methods
        KX_PYMETHOD_DOC(SCA_PropertyActuator,SetProperty);
index ef3dbe7..659823f 100644 (file)
@@ -306,18 +306,21 @@ int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_PropertySensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_PropertySensor",
        sizeof(SCA_PropertySensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -349,18 +352,18 @@ PyAttributeDef SCA_PropertySensor::Attributes[] = {
 };
 
 
-PyObject* SCA_PropertySensor::_getattr(const char *attr) {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+PyObject* SCA_PropertySensor::py_getattro(PyObject *attr) {
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_ISensor); /* implicit return! */
+       py_getattro_up(SCA_ISensor); /* implicit return! */
 }
 
-int SCA_PropertySensor::_setattr(const char *attr, PyObject *value) {
-       int ret = _setattr_self(Attributes, this, attr, value);
+int SCA_PropertySensor::py_setattro(PyObject *attr, PyObject *value) {
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_ISensor::_setattr(attr, value);
+       return SCA_ISensor::py_setattro(attr, value);
 }
 
 /* 1. getType */
index 2594e3f..076c1ae 100644 (file)
@@ -89,8 +89,8 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* 1. getType */
        KX_PYMETHOD_DOC(SCA_PropertySensor,GetType);
index 4ad3f13..2d200e0 100644 (file)
@@ -224,18 +224,21 @@ const char* SCA_PythonController::sPyAddActiveActuator__doc__= "addActiveActuato
 const char SCA_PythonController::GetActuators_doc[] = "getActuator";
 
 PyTypeObject SCA_PythonController::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "SCA_PythonController",
                sizeof(SCA_PythonController),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
-               0, //&MyPyCompare,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -369,24 +372,26 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
 
 
 
-PyObject* SCA_PythonController::_getattr(const char *attr)
+PyObject* SCA_PythonController::py_getattro(PyObject *attr)
 {
-       if (!strcmp(attr,"state")) {
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str,"state")) {
                return PyInt_FromLong(m_statemask);
        }
-       if (!strcmp(attr,"script")) {
+       if (!strcmp(attr_str,"script")) {
                return PyString_FromString(m_scriptText);
        }
-       _getattr_up(SCA_IController);
+       py_getattro_up(SCA_IController);
 }
 
-int SCA_PythonController::_setattr(const char *attr, PyObject *value)
+int SCA_PythonController::py_setattro(PyObject *attr, PyObject *value)
 {
-       if (!strcmp(attr,"state")) {
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str,"state")) {
                PyErr_SetString(PyExc_AttributeError, "state is read only");
                return 1;
        }
-       if (!strcmp(attr,"script")) {
+       if (!strcmp(attr_str,"script")) {
                char *scriptArg = PyString_AsString(value);
                
                if (scriptArg==NULL) {
@@ -400,7 +405,7 @@ int SCA_PythonController::_setattr(const char *attr, PyObject *value)
                
                return 1;
        }
-       return SCA_IController::_setattr(attr, value);
+       return SCA_IController::py_setattro(attr, value);
 }
 
 PyObject* SCA_PythonController::PyActivate(PyObject* self, PyObject *value)
index 4ec18f3..3348071 100644 (file)
@@ -78,8 +78,8 @@ class SCA_PythonController : public SCA_IController
        static PyObject* sPyAddActiveActuator(PyObject* self, 
                                                                                  PyObject* args);
        static SCA_IActuator* LinkedActuatorFromPy(PyObject *value);
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
                
        KX_PYMETHOD_O(SCA_PythonController,Activate);
index 78614f9..a9a664b 100644 (file)
@@ -312,18 +312,21 @@ void SCA_RandomActuator::enforceConstraints() {
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_RandomActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_RandomActuator",
        sizeof(SCA_RandomActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -366,22 +369,25 @@ PyAttributeDef SCA_RandomActuator::Attributes[] = {
        { NULL }        //Sentinel
 };     
 
-PyObject* SCA_RandomActuator::_getattr(const char *attr) {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+PyObject* SCA_RandomActuator::py_getattro(PyObject *attr) {
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       if (!strcmp(attr, "seed")) {
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "seed")) {
                return PyInt_FromLong(m_base->GetSeed());
        }
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int SCA_RandomActuator::_setattr(const char *attr, PyObject *value)
+int SCA_RandomActuator::py_setattro(PyObject *attr, PyObject *value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       if (!strcmp(attr, "seed")) {
+       
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "seed")) {
                if (PyInt_Check(value)) {
                        int ival = PyInt_AsLong(value);
                        m_base->SetSeed(ival);
@@ -391,7 +397,7 @@ int SCA_RandomActuator::_setattr(const char *attr, PyObject *value)
                        return 1;
                }
        }
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 /* 1. setSeed                                                            */
index 0d404fa..96ca353 100644 (file)
@@ -96,8 +96,8 @@ class SCA_RandomActuator : public SCA_IActuator
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* 1. setSeed                                                            */
        KX_PYMETHOD_DOC(SCA_RandomActuator,SetSeed);
index d88f8f5..84a9ef9 100644 (file)
@@ -127,18 +127,21 @@ bool SCA_RandomSensor::Evaluate(CValue* event)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_RandomSensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_RandomSensor",
        sizeof(SCA_RandomSensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -162,22 +165,25 @@ PyAttributeDef SCA_RandomSensor::Attributes[] = {
        {NULL} //Sentinel
 };
 
-PyObject* SCA_RandomSensor::_getattr(const char *attr) {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+PyObject* SCA_RandomSensor::py_getattro(PyObject *attr) {
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       if (!strcmp(attr,"seed")) {
+       
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str,"seed")) {
                return PyInt_FromLong(m_basegenerator->GetSeed());
        }
-       _getattr_up(SCA_ISensor);
+       py_getattro_up(SCA_ISensor);
 }
 
-int SCA_RandomSensor::_setattr(const char *attr, PyObject *value)
+int SCA_RandomSensor::py_setattro(PyObject *attr, PyObject *value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       if (!strcmp(attr,"seed")) {
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str,"seed")) {
                if (PyInt_Check(value)) {
                        int ival = PyInt_AsLong(value);
                        m_basegenerator->SetSeed(ival);
@@ -187,7 +193,7 @@ int SCA_RandomSensor::_setattr(const char *attr, PyObject *value)
                        return 1;
                }
        }
-       return SCA_ISensor::_setattr(attr, value);
+       return SCA_ISensor::py_setattro(attr, value);
 }
 
 /* 1. setSeed                                                            */
index d808db0..39d072d 100644 (file)
@@ -60,8 +60,8 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* 1. setSeed                                                            */
        KX_PYMETHOD_DOC(SCA_RandomSensor,SetSeed);
index a9fe906..10757e1 100644 (file)
@@ -111,18 +111,21 @@ CValue* SCA_XNORController::GetReplica()
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_XNORController::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_XNORController",
        sizeof(SCA_XNORController),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -142,8 +145,8 @@ PyAttributeDef SCA_XNORController::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* SCA_XNORController::_getattr(const char *attr) {
-       _getattr_up(SCA_IController);
+PyObject* SCA_XNORController::py_getattro(PyObject *attr) {
+       py_getattro_up(SCA_IController);
 }
 
 /* eof */
index a431a72..c992d5f 100644 (file)
@@ -48,7 +48,7 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
 
 };
 
index b0053ca..d2290fe 100644 (file)
@@ -111,18 +111,21 @@ CValue* SCA_XORController::GetReplica()
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject SCA_XORController::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "SCA_XORController",
        sizeof(SCA_XORController),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -142,8 +145,8 @@ PyAttributeDef SCA_XORController::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* SCA_XORController::_getattr(const char *attr) {
-       _getattr_up(SCA_IController);
+PyObject* SCA_XORController::py_getattro(PyObject *attr) {
+       py_getattro_up(SCA_IController);
 }
 
 /* eof */
index 2fbc786..065b31f 100644 (file)
@@ -48,7 +48,7 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
 
 };
 
index 14f672b..279721b 100644 (file)
@@ -729,9 +729,9 @@ void BL_Shader::SetUniform(int uniform, const int* val, int len)
 }
 
 
-PyObject* BL_Shader::_getattr(const char *attr)
+PyObject* BL_Shader::py_getattro(PyObject *attr)
 {
-       _getattr_up(PyObjectPlus);
+       py_getattro_up(PyObjectPlus);
 }
 
 
@@ -772,25 +772,28 @@ PyAttributeDef BL_Shader::Attributes[] = {
 };
 
 PyTypeObject BL_Shader::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "BL_Shader",
                sizeof(BL_Shader),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
 
 PyParentObject BL_Shader::Parents[] = {
-       &PyObjectPlus::Type,
        &BL_Shader::Type,
+       &PyObjectPlus::Type,
        NULL
 };
 
index 76acd55..490c026 100644 (file)
@@ -202,7 +202,7 @@ public:
        void SetUniform(int uniform, const int val);
 
        // Python interface
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
 
        // -----------------------------------
        KX_PYMETHOD_DOC( BL_Shader, setSource );
index 0a7e20b..a5fd8eb 100644 (file)
@@ -105,18 +105,21 @@ CValue* KX_NetworkMessageActuator::GetReplica()
 
 /* Integration hooks -------------------------------------------------- */
 PyTypeObject KX_NetworkMessageActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_NetworkMessageActuator",
        sizeof(KX_NetworkMessageActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -150,18 +153,18 @@ PyAttributeDef KX_NetworkMessageActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_NetworkMessageActuator::_getattr(const char *attr) {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+PyObject* KX_NetworkMessageActuator::py_getattro(PyObject *attr) {
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int KX_NetworkMessageActuator::_setattr(const char *attr, PyObject *value) {
-       int ret = _setattr_self(Attributes, this, attr, value);
+int KX_NetworkMessageActuator::py_setattro(PyObject *attr, PyObject *value) {
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 // Deprecated ----->
index d9a7f78..850f825 100644 (file)
@@ -61,8 +61,8 @@ public:
        /* Python interface ------------------------------------------- */
        /* ------------------------------------------------------------ */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        // Deprecated ----->
        KX_PYMETHOD(KX_NetworkMessageActuator, SetToPropName);
index d5434a3..7922c34 100644 (file)
@@ -168,18 +168,21 @@ bool KX_NetworkMessageSensor::IsPositiveTrigger()
 
 /* Integration hooks --------------------------------------------------- */
 PyTypeObject KX_NetworkMessageSensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_NetworkMessageSensor",
        sizeof(KX_NetworkMessageSensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -220,18 +223,18 @@ PyAttributeDef KX_NetworkMessageSensor::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_NetworkMessageSensor::_getattr(const char *attr) {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+PyObject* KX_NetworkMessageSensor::py_getattro(PyObject *attr) {
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_ISensor);
+       py_getattro_up(SCA_ISensor);
 }
 
-int KX_NetworkMessageSensor::_setattr(const char *attr, PyObject *value) {
-       int ret = _setattr_self(Attributes, this, attr, value);
+int KX_NetworkMessageSensor::py_setattro(PyObject *attr, PyObject *value) {
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_ISensor::_setattr(attr, value);
+       return SCA_ISensor::py_setattro(attr, value);
 }
 
 PyObject* KX_NetworkMessageSensor::pyattr_get_bodies(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
index 79e8bc9..ac0e880 100644 (file)
@@ -72,8 +72,8 @@ public:
        /* Python interface -------------------------------------------- */
        /* ------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        // Deprecated ----->
        KX_PYMETHOD_DOC_O(KX_NetworkMessageSensor, SetSubjectFilterText);
index 6688738..bd13719 100644 (file)
@@ -753,37 +753,40 @@ PyAttributeDef KX_BlenderMaterial::Attributes[] = {
 };
 
 PyTypeObject KX_BlenderMaterial::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_BlenderMaterial",
                sizeof(KX_BlenderMaterial),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
 
 PyParentObject KX_BlenderMaterial::Parents[] = {
-       &PyObjectPlus::Type,
        &KX_BlenderMaterial::Type,
+       &PyObjectPlus::Type,
        NULL
 };
 
 
-PyObject* KX_BlenderMaterial::_getattr(const char *attr)
+PyObject* KX_BlenderMaterial::py_getattro(PyObject *attr)
 {
-       _getattr_up(PyObjectPlus);
+       py_getattro_up(PyObjectPlus);
 }
 
-int KX_BlenderMaterial::_setattr(const char *attr, PyObject *pyvalue)
+int KX_BlenderMaterial::py_setattro(PyObject *attr, PyObject *pyvalue)
 {
-       return PyObjectPlus::_setattr(attr, pyvalue);
+       return PyObjectPlus::py_setattro(attr, pyvalue);
 }
 
 
index 2cf623d..2d9dc8f 100644 (file)
@@ -82,8 +82,8 @@ public:
        );
        
        // --------------------------------
-       virtual PyObject* _getattr(const char *attr);
-       virtual int       _setattr(const char *attr, PyObject *pyvalue);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int       py_setattro(PyObject *attr, PyObject *pyvalue);
 
        KX_PYMETHOD_DOC( KX_BlenderMaterial, getShader );
        KX_PYMETHOD_DOC( KX_BlenderMaterial, getMaterialIndex );
index f86a566..57c9d30 100644 (file)
@@ -158,18 +158,21 @@ bool KX_CDActuator::Update()
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_CDActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_SoundActuator",
                sizeof(KX_CDActuator),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -212,20 +215,20 @@ int KX_CDActuator::pyattr_setGain(void *self, const struct KX_PYATTRIBUTE_DEF *a
        return 0;
 }
 
-PyObject* KX_CDActuator::_getattr(const char *attr)
+PyObject* KX_CDActuator::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int KX_CDActuator::_setattr(const char *attr, PyObject *value)
+int KX_CDActuator::py_setattro(PyObject *attr, PyObject *value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 
index 08ca6a8..e768329 100644 (file)
@@ -81,8 +81,8 @@ public:
        /* Python interface --------------------------------------------------- */
        /* -------------------------------------------------------------------- */
 
-       virtual PyObject*  _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject*  py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        // Deprecated ----->
        KX_PYMETHOD(KX_CDActuator,SetGain);
index cb138ef..19370d8 100644 (file)
@@ -488,18 +488,21 @@ PyAttributeDef KX_Camera::Attributes[] = {
 };
 
 PyTypeObject KX_Camera::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_Camera",
                sizeof(KX_Camera),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -511,48 +514,51 @@ PyParentObject KX_Camera::Parents[] = {
                NULL
 };
 
-PyObject* KX_Camera::_getattr(const char *attr)
+PyObject* KX_Camera::py_getattro(PyObject *attr)
 {
-       if (!strcmp(attr, "INSIDE"))
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "INSIDE"))
                return PyInt_FromLong(INSIDE); /* new ref */
-       if (!strcmp(attr, "OUTSIDE"))
+       if (!strcmp(attr_str, "OUTSIDE"))
                return PyInt_FromLong(OUTSIDE); /* new ref */
-       if (!strcmp(attr, "INTERSECT"))
+       if (!strcmp(attr_str, "INTERSECT"))
                return PyInt_FromLong(INTERSECT); /* new ref */
        
-       if (!strcmp(attr, "lens"))
+       if (!strcmp(attr_str, "lens"))
                return PyFloat_FromDouble(GetLens()); /* new ref */
-       if (!strcmp(attr, "near"))
+       if (!strcmp(attr_str, "near"))
                return PyFloat_FromDouble(GetCameraNear()); /* new ref */
-       if (!strcmp(attr, "far"))
+       if (!strcmp(attr_str, "far"))
                return PyFloat_FromDouble(GetCameraFar()); /* new ref */
-       if (!strcmp(attr, "frustum_culling"))
+       if (!strcmp(attr_str, "frustum_culling"))
                return PyInt_FromLong(m_frustum_culling); /* new ref */
-       if (!strcmp(attr, "perspective"))
+       if (!strcmp(attr_str, "perspective"))
                return PyInt_FromLong(m_camdata.m_perspective); /* new ref */
-       if (!strcmp(attr, "projection_matrix"))
+       if (!strcmp(attr_str, "projection_matrix"))
                return PyObjectFrom(GetProjectionMatrix()); /* new ref */
-       if (!strcmp(attr, "modelview_matrix"))
+       if (!strcmp(attr_str, "modelview_matrix"))
                return PyObjectFrom(GetModelviewMatrix()); /* new ref */
-       if (!strcmp(attr, "camera_to_world"))
+       if (!strcmp(attr_str, "camera_to_world"))
                return PyObjectFrom(GetCameraToWorld()); /* new ref */
-       if (!strcmp(attr, "world_to_camera"))
+       if (!strcmp(attr_str, "world_to_camera"))
                return PyObjectFrom(GetWorldToCamera()); /* new ref */
        
-       _getattr_up(KX_GameObject);
+       py_getattro_up(KX_GameObject);
 }
 
-int KX_Camera::_setattr(const char *attr, PyObject *pyvalue)
+int KX_Camera::py_setattro(PyObject *attr, PyObject *pyvalue)
 {
+       char *attr_str= PyString_AsString(attr);
+       
        if (PyInt_Check(pyvalue))
        {
-               if (!strcmp(attr, "frustum_culling"))
+               if (!strcmp(attr_str, "frustum_culling"))
                {
                        m_frustum_culling = PyInt_AsLong(pyvalue);
                        return 0;
                }
                
-               if (!strcmp(attr, "perspective"))
+               if (!strcmp(attr_str, "perspective"))
                {
                        m_camdata.m_perspective = PyInt_AsLong(pyvalue);
                        return 0;
@@ -561,19 +567,19 @@ int KX_Camera::_setattr(const char *attr, PyObject *pyvalue)
        
        if (PyFloat_Check(pyvalue))
        {
-               if (!strcmp(attr, "lens"))
+               if (!strcmp(attr_str, "lens"))
                {
                        m_camdata.m_lens = PyFloat_AsDouble(pyvalue);
                        m_set_projection_matrix = false;
                        return 0;
                }
-               if (!strcmp(attr, "near"))
+               if (!strcmp(attr_str, "near"))
                {
                        m_camdata.m_clipstart = PyFloat_AsDouble(pyvalue);
                        m_set_projection_matrix = false;
                        return 0;
                }
-               if (!strcmp(attr, "far"))
+               if (!strcmp(attr_str, "far"))
                {
                        m_camdata.m_clipend = PyFloat_AsDouble(pyvalue);
                        m_set_projection_matrix = false;
@@ -583,7 +589,7 @@ int KX_Camera::_setattr(const char *attr, PyObject *pyvalue)
        
        if (PyObject_IsMT_Matrix(pyvalue, 4))
        {
-               if (!strcmp(attr, "projection_matrix"))
+               if (!strcmp(attr_str, "projection_matrix"))
                {
                        MT_Matrix4x4 mat;
                        if (PyMatTo(pyvalue, mat))
@@ -594,7 +600,7 @@ int KX_Camera::_setattr(const char *attr, PyObject *pyvalue)
                        return 1;
                }
        }
-       return KX_GameObject::_setattr(attr, pyvalue);
+       return KX_GameObject::py_setattro(attr, pyvalue);
 }
 
 KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, sphereInsideFrustum,
index b80be9a..499db66 100644 (file)
@@ -265,8 +265,8 @@ public:
        KX_PYMETHOD_DOC_VARARGS(KX_Camera, setViewport);        
        KX_PYMETHOD_DOC_NOARGS(KX_Camera, setOnTop);    
 
-       virtual PyObject* _getattr(const char *attr); /* lens, near, far, projection_matrix */
-       virtual int       _setattr(const char *attr, PyObject *pyvalue);
+       virtual PyObject* py_getattro(PyObject *attr); /* lens, near, far, projection_matrix */
+       virtual int       py_setattro(PyObject *attr, PyObject *pyvalue);
 
 };
 
index 08afa28..354143f 100644 (file)
@@ -371,18 +371,21 @@ bool KX_CameraActuator::string2axischoice(const char *axisString)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_CameraActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_CameraActuator",
        sizeof(KX_CameraActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -414,27 +417,28 @@ PyAttributeDef KX_CameraActuator::Attributes[] = {
        KX_PYATTRIBUTE_FLOAT_RW("max",-MAXFLOAT,MAXFLOAT,KX_CameraActuator,m_maxHeight),
        KX_PYATTRIBUTE_FLOAT_RW("height",-MAXFLOAT,MAXFLOAT,KX_CameraActuator,m_height),
        KX_PYATTRIBUTE_BOOL_RW("xy",KX_CameraActuator,m_x),
+       KX_PYATTRIBUTE_DUMMY("object"),
        {NULL}
 };
 
-PyObject* KX_CameraActuator::_getattr(const char *attr) {
+PyObject* KX_CameraActuator::py_getattro(PyObject *attr) {
        PyObject* object;
-       
-       if (!strcmp(attr, "object")) {
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "object")) {
                if (!m_ob)      Py_RETURN_NONE;
                else            return m_ob->AddRef();
        }
        
-       object = _getattr_self(Attributes, this, attr);
+       object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int KX_CameraActuator::_setattr(const char *attr, PyObject* value) {
+int KX_CameraActuator::py_setattro(PyObject *attr, PyObject* value) {
        int ret;
-       
-       if (!strcmp(attr, "object")) {
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "object")) {
                KX_GameObject *gameobj;
                
                if (!ConvertPythonToGameObject(value, &gameobj, true))
@@ -451,10 +455,10 @@ int KX_CameraActuator::_setattr(const char *attr, PyObject* value) {
                return 0;
        }
        
-       ret = _setattr_self(Attributes, this, attr, value);
+       ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 /* get obj  ---------------------------------------------------------- */
index 3b08536..5d7473a 100644 (file)
@@ -120,8 +120,8 @@ private :
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject* value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject* value);
 
        /* set object to look at */
        KX_PYMETHOD_DOC_O(KX_CameraActuator,SetObject);
index 31a566f..feee851 100644 (file)
@@ -560,18 +560,21 @@ bool KX_ConstraintActuator::IsValidMode(KX_ConstraintActuator::KX_CONSTRAINTTYPE
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_ConstraintActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_ConstraintActuator",
        sizeof(KX_ConstraintActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -613,8 +616,8 @@ PyAttributeDef KX_ConstraintActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_ConstraintActuator::_getattr(const char *attr) {
-       _getattr_up(SCA_IActuator);
+PyObject* KX_ConstraintActuator::py_getattro(PyObject *attr) {
+       py_getattro_up(SCA_IActuator);
 }
 
 /* 2. setDamp                                                                */
index 132b8a7..193400f 100644 (file)
@@ -142,7 +142,7 @@ protected:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
 
        KX_PYMETHOD_DOC(KX_ConstraintActuator,SetDamp);
        KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetDamp);
index 05e677b..edd6e99 100644 (file)
@@ -69,18 +69,21 @@ PyObject* KX_ConstraintWrapper::PyGetConstraintId(PyObject* self,
 
 //python specific stuff
 PyTypeObject KX_ConstraintWrapper::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_ConstraintWrapper",
                sizeof(KX_ConstraintWrapper),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -89,13 +92,13 @@ PyParentObject KX_ConstraintWrapper::Parents[] = {
        NULL
 };
 
-PyObject*      KX_ConstraintWrapper::_getattr(const char *attr)
+PyObject*      KX_ConstraintWrapper::py_getattro(PyObject *attr)
 {
        //here you can search for existing data members (like mass,friction etc.)
-       _getattr_up(PyObjectPlus);
+       py_getattro_up(PyObjectPlus);
 }
 
-int    KX_ConstraintWrapper::_setattr(const char *attr,PyObject* pyobj)
+int    KX_ConstraintWrapper::py_setattro(PyObject *attr,PyObject* pyobj)
 {
        int result = 1;
 
@@ -117,7 +120,7 @@ int KX_ConstraintWrapper::_setattr(const char *attr,PyObject* pyobj)
                result = 0;
        }
        if (result)
-               result = PyObjectPlus::_setattr(attr,pyobj);
+               result = PyObjectPlus::py_setattro(attr,pyobj);
        return result;
 };
 
index 36606d2..6e67d84 100644 (file)
@@ -35,8 +35,8 @@
 class  KX_ConstraintWrapper : public PyObjectPlus
 {
        Py_Header;
-       virtual PyObject*               _getattr(const char *attr);
-       virtual int                     _setattr(const char *attr, PyObject *value);
+       virtual PyObject*               py_getattro(PyObject *attr);
+       virtual int                     py_setattro(PyObject *attr, PyObject *value);
 public:
        KX_ConstraintWrapper(PHY_ConstraintType ctype,int constraintId,class PHY_IPhysicsEnvironment* physenv,PyTypeObject *T = &Type);
        virtual ~KX_ConstraintWrapper ();
index 6800c75..a2a3d48 100644 (file)
@@ -208,18 +208,21 @@ bool KX_GameActuator::Update()
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_GameActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_GameActuator",
                sizeof(KX_GameActuator),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -251,20 +254,20 @@ PyAttributeDef KX_GameActuator::Attributes[] = {
 };
 
 PyObject*
-KX_GameActuator::_getattr(const char *attr)
+KX_GameActuator::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int KX_GameActuator::_setattr(const char *attr, PyObject *value)
+int KX_GameActuator::py_setattro(PyObject *attr, PyObject *value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 
index ad63825..570cb2e 100644 (file)
@@ -77,8 +77,8 @@ protected:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        // Deprecated functions ----->
        KX_PYMETHOD_DOC(KX_GameActuator,GetFile);
index 2bd4b28..f0c5667 100644 (file)
@@ -1180,21 +1180,21 @@ PyMappingMethods KX_GameObject::Mapping = {
 
 
 PyTypeObject KX_GameObject::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_GameObject",
                sizeof(KX_GameObject),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
                0,
                0,
-               &Mapping,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -1420,7 +1420,9 @@ int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attr
 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= _getattr_dict(self->SCA_IObject::_getattr("__dict__"), KX_GameObject::Methods, KX_GameObject::Attributes);
+       PyObject *dict_str = PyString_FromString("__dict__");
+       PyObject *dict= _getattr_dict(self->SCA_IObject::py_getattro(dict_str), KX_GameObject::Methods, KX_GameObject::Attributes);
+       Py_DECREF(dict_str);
        
        if(dict==NULL)
                return NULL;
@@ -1441,22 +1443,22 @@ PyObject* KX_GameObject::pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_
        return dict;
 }
 
-PyObject* KX_GameObject::_getattr(const char *attr)
+PyObject* KX_GameObject::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
        
-       _getattr_up(SCA_IObject);
+       py_getattro_up(SCA_IObject);
 }
 
-int KX_GameObject::_setattr(const char *attr, PyObject *value) // _setattr method
+int KX_GameObject::py_setattro(PyObject *attr, PyObject *value)        // py_setattro method
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
        
-       return SCA_IObject::_setattr(attr, value);
+       return SCA_IObject::py_setattro(attr, value);
 }
 
 PyObject* KX_GameObject::PyApplyForce(PyObject* self, PyObject* args)
index bada19c..4b136e2 100644 (file)
@@ -756,9 +756,9 @@ public:
         * @section Python interface functions.
         */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);                // _setattr method
-       virtual PyObject* _repr(void) { return PyString_FromString(GetName().ReadPtr()); }
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);               // py_setattro method
+       virtual PyObject* py_repr(void) { return PyString_FromString(GetName().ReadPtr()); }
        
        KX_PYMETHOD_NOARGS(KX_GameObject,GetPosition);
        KX_PYMETHOD_O(KX_GameObject,SetPosition);
index 5d1d458..adb9c28 100644 (file)
@@ -413,18 +413,21 @@ int KX_IpoActuator::string2mode(char* modename) {
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_IpoActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_IpoActuator",
        sizeof(KX_IpoActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -470,25 +473,21 @@ PyAttributeDef KX_IpoActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_IpoActuator::_getattr(const char *attr) {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+PyObject* KX_IpoActuator::py_getattro(PyObject *attr) {
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
        
-       if (!strcmp(attr, "__dict__")) { /* python 3.0 uses .__dir__()*/
-               return _getattr_dict(SCA_IActuator::_getattr(attr), Methods, Attributes);
-       }
-       
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int KX_IpoActuator::_setattr(const char *attr, PyObject *value)        // _setattr method
+int KX_IpoActuator::py_setattro(PyObject *attr, PyObject *value)       // py_setattro method
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
        
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 /* set --------------------------------------------------------------------- */
index fa8e58a..7e85a28 100644 (file)
@@ -141,8 +141,8 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
        
        //KX_PYMETHOD_DOC
        KX_PYMETHOD_DOC(KX_IpoActuator,Set);
index f71dd69..6f9d8b0 100644 (file)
@@ -173,59 +173,62 @@ void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras)
        GPU_lamp_shadow_buffer_unbind(lamp);
 }
 
-PyObject* KX_LightObject::_getattr(const char *attr)
+PyObject* KX_LightObject::py_getattro(PyObject *attr)
 {
-       if (!strcmp(attr, "layer"))
+       char *attr_str= PyString_AsString(attr);
+       
+       if (!strcmp(attr_str, "layer"))
                return PyInt_FromLong(m_lightobj.m_layer);
        
-       if (!strcmp(attr, "energy"))
+       if (!strcmp(attr_str, "energy"))
                return PyFloat_FromDouble(m_lightobj.m_energy);
        
-       if (!strcmp(attr, "distance"))
+       if (!strcmp(attr_str, "distance"))
                return PyFloat_FromDouble(m_lightobj.m_distance);
        
-       if (!strcmp(attr, "colour") || !strcmp(attr, "color"))
+       if (!strcmp(attr_str, "colour") || !strcmp(attr_str, "color"))
                return Py_BuildValue("[fff]", m_lightobj.m_red, m_lightobj.m_green, m_lightobj.m_blue);
                
-       if (!strcmp(attr, "lin_attenuation"))
+       if (!strcmp(attr_str, "lin_attenuation"))
                return PyFloat_FromDouble(m_lightobj.m_att1);
        
-       if (!strcmp(attr, "quad_attenuation"))
+       if (!strcmp(attr_str, "quad_attenuation"))
                return PyFloat_FromDouble(m_lightobj.m_att2);
        
-       if (!strcmp(attr, "spotsize"))
+       if (!strcmp(attr_str, "spotsize"))
                return PyFloat_FromDouble(m_lightobj.m_spotsize);
        
-       if (!strcmp(attr, "spotblend"))
+       if (!strcmp(attr_str, "spotblend"))
                return PyFloat_FromDouble(m_lightobj.m_spotblend);
                
-       if (!strcmp(attr, "SPOT"))
+       if (!strcmp(attr_str, "SPOT"))
                return PyInt_FromLong(RAS_LightObject::LIGHT_SPOT);
                
-       if (!strcmp(attr, "SUN"))
+       if (!strcmp(attr_str, "SUN"))
                return PyInt_FromLong(RAS_LightObject::LIGHT_SUN);
        
-       if (!strcmp(attr, "NORMAL"))
+       if (!strcmp(attr_str, "NORMAL"))
                return PyInt_FromLong(RAS_LightObject::LIGHT_NORMAL);
        
-       if (!strcmp(attr, "type"))
+       if (!strcmp(attr_str, "type"))
                return PyInt_FromLong(m_lightobj.m_type);
                
-       _getattr_up(KX_GameObject);
+       py_getattro_up(KX_GameObject);
 }
 
-int       KX_LightObject::_setattr(const char *attr, PyObject *pyvalue)
-{      
+int       KX_LightObject::py_setattro(PyObject *attr, PyObject *pyvalue)
+{
+       char *attr_str= PyString_AsString(attr);
        if (PyInt_Check(pyvalue))
        {
                int value = PyInt_AsLong(pyvalue);
-               if (!strcmp(attr, "layer"))
+               if (!strcmp(attr_str, "layer"))
                {
                        m_lightobj.m_layer = value;
                        return 0;
                }
                
-               if (!strcmp(attr, "type"))
+               if (!strcmp(attr_str, "type"))
                {
                        if (value >= RAS_LightObject::LIGHT_SPOT && value <= RAS_LightObject::LIGHT_NORMAL)
                                m_lightobj.m_type = (RAS_LightObject::LightType) value;
@@ -236,37 +239,37 @@ int       KX_LightObject::_setattr(const char *attr, PyObject *pyvalue)
        if (PyFloat_Check(pyvalue))
        {
                float value = PyFloat_AsDouble(pyvalue);
-               if (!strcmp(attr, "energy"))
+               if (!strcmp(attr_str, "energy"))
                {
                        m_lightobj.m_energy = value;
                        return 0;
                }
        
-               if (!strcmp(attr, "distance"))
+               if (!strcmp(attr_str, "distance"))
                {
                        m_lightobj.m_distance = value;
                        return 0;
                }
                
-               if (!strcmp(attr, "lin_attenuation"))
+               if (!strcmp(attr_str, "lin_attenuation"))
                {
                        m_lightobj.m_att1 = value;
                        return 0;
                }
                
-               if (!strcmp(attr, "quad_attenuation"))
+               if (!strcmp(attr_str, "quad_attenuation"))
                {
                        m_lightobj.m_att2 = value;
                        return 0;
                }
                
-               if (!strcmp(attr, "spotsize"))
+               if (!strcmp(attr_str, "spotsize"))
                {
                        m_lightobj.m_spotsize = value;
                        return 0;
                }
                
-               if (!strcmp(attr, "spotblend"))
+               if (!strcmp(attr_str, "spotblend"))
                {
                        m_lightobj.m_spotblend = value;
                        return 0;
@@ -275,7 +278,7 @@ int       KX_LightObject::_setattr(const char *attr, PyObject *pyvalue)
 
        if (PySequence_Check(pyvalue))
        {
-               if (!strcmp(attr, "colour") || !strcmp(attr, "color"))
+               if (!strcmp(attr_str, "colour") || !strcmp(attr_str, "color"))
                {
                        MT_Vector3 color;
                        if (PyVecTo(pyvalue, color))
@@ -289,13 +292,13 @@ int       KX_LightObject::_setattr(const char *attr, PyObject *pyvalue)
                }
        }
        
-       if (!strcmp(attr, "SPOT") || !strcmp(attr, "SUN") || !strcmp(attr, "NORMAL"))
+       if (!strcmp(attr_str, "SPOT") || !strcmp(attr_str, "SUN") || !strcmp(attr_str, "NORMAL"))
        {
-               PyErr_Format(PyExc_RuntimeError, "Attribute %s is read only.", attr);
+               PyErr_Format(PyExc_RuntimeError, "Attribute %s is read only.", attr_str);
                return 1;
        }
        
-       return KX_GameObject::_setattr(attr, pyvalue);
+       return KX_GameObject::py_setattro(attr, pyvalue);
 }
 
 PyMethodDef KX_LightObject::Methods[] = {
@@ -308,18 +311,21 @@ PyAttributeDef KX_LightObject::Attributes[] = {
 
 
 PyTypeObject KX_LightObject::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_LightObject",
                sizeof(KX_LightObject),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
index 98dcc8e..4559954 100644 (file)
@@ -62,8 +62,8 @@ public:
        void UnbindShadowBuffer(class RAS_IRasterizer *ras);
        void Update();
        
-       virtual PyObject* _getattr(const char *attr); /* lens, near, far, projection_matrix */
-       virtual int       _setattr(const char *attr, PyObject *pyvalue);
+       virtual PyObject* py_getattro(PyObject *attr); /* lens, near, far, projection_matrix */
+       virtual int       py_setattro(PyObject *attr, PyObject *pyvalue);
 
        virtual bool IsLight(void) { return true; }
 };
index f349a6b..f464cb7 100644 (file)
 #include "PyObjectPlus.h" 
 
 PyTypeObject KX_MeshProxy::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_MeshProxy",
        sizeof(KX_MeshProxy),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -94,9 +97,11 @@ void KX_MeshProxy::SetMeshModified(bool v)
 
 
 PyObject*
-KX_MeshProxy::_getattr(const char *attr)
+KX_MeshProxy::py_getattro(PyObject *attr)
 {
-       if (!strcmp(attr, "materials"))
+       char *attr_str= PyString_AsString(attr);
+       
+       if (!strcmp(attr_str, "materials"))
        {
                PyObject *materials = PyList_New(0);
                list<RAS_MeshMaterial>::iterator mit = m_meshobj->GetFirstMaterial();
@@ -115,7 +120,7 @@ KX_MeshProxy::_getattr(const char *attr)
                }
                return materials;
        }
-       _getattr_up(SCA_IObject);
+       py_getattro_up(SCA_IObject);
 }
 
 
index 9e08937..0b97381 100644 (file)
@@ -54,7 +54,7 @@ public:
        virtual CValue*         GetReplica();
 
 // stuff for python integration
-       virtual PyObject*  _getattr(const char *attr);
+       virtual PyObject*  py_getattro(PyObject *attr);
        KX_PYMETHOD(KX_MeshProxy,GetNumMaterials);
        KX_PYMETHOD(KX_MeshProxy,GetMaterialName);
        KX_PYMETHOD(KX_MeshProxy,GetTextureName);
index 973dfce..72a0381 100644 (file)
@@ -293,18 +293,21 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_MouseFocusSensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_MouseFocusSensor",
        sizeof(KX_MouseFocusSensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -333,8 +336,8 @@ PyAttributeDef KX_MouseFocusSensor::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_MouseFocusSensor::_getattr(const char *attr) {
-       _getattr_up(SCA_MouseSensor);
+PyObject* KX_MouseFocusSensor::py_getattro(PyObject *attr) {
+       py_getattro_up(SCA_MouseSensor);
 }
 
 
index 4979783..804f34e 100644 (file)
@@ -87,7 +87,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
        /* --------------------------------------------------------------------- */
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
-       virtual PyObject*  _getattr(const char *attr);
+       virtual PyObject*  py_getattro(PyObject *attr);
 
        KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRayTarget);
        KX_PYMETHOD_DOC_NOARGS(KX_MouseFocusSensor,GetRaySource);
index 383d673..2debfd7 100644 (file)
@@ -287,18 +287,21 @@ bool      KX_NearSensor::NewHandleCollision(void* obj1,void* obj2,const PHY_CollData
 /* ------------------------------------------------------------------------- */
 
 PyTypeObject KX_NearSensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_NearSensor",
        sizeof(KX_NearSensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -327,20 +330,20 @@ PyAttributeDef KX_NearSensor::Attributes[] = {
 };
 
 
-PyObject* KX_NearSensor::_getattr(const char *attr)
+PyObject* KX_NearSensor::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
 
-       _getattr_up(KX_TouchSensor);
+       py_getattro_up(KX_TouchSensor);
 }
 
-int KX_NearSensor::_setattr(const char *attr, PyObject* value)
+int KX_NearSensor::py_setattro(PyObject*attr, PyObject* value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
 
-       return KX_TouchSensor::_setattr(attr, value);
+       return KX_TouchSensor::py_setattro(attr, value);
 }
index ee03992..26c5feb 100644 (file)
@@ -82,8 +82,8 @@ public:
        /* --------------------------------------------------------------------- */
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject* value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject* value);
 
        //No methods
 
index ca2157f..a343eeb 100644 (file)
@@ -277,18 +277,21 @@ bool KX_ObjectActuator::isValid(KX_ObjectActuator::KX_OBJECT_ACT_VEC_TYPE type)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_ObjectActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_ObjectActuator",
        sizeof(KX_ObjectActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -333,8 +336,8 @@ PyAttributeDef KX_ObjectActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_ObjectActuator::_getattr(const char *attr) {
-       _getattr_up(SCA_IActuator);
+PyObject* KX_ObjectActuator::py_getattro(PyObject *attr) {
+       py_getattro_up(SCA_IActuator);
 };
 
 /* 1. set ------------------------------------------------------------------ */
index 0331c67..00c8fb7 100644 (file)
@@ -153,7 +153,7 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
        
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
 
        KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForce);
        KX_PYMETHOD(KX_ObjectActuator,SetForce);
index 4c0507c..1baf581 100644 (file)
@@ -139,18 +139,21 @@ bool KX_ParentActuator::Update()
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_ParentActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_ParentActuator",
        sizeof(KX_ParentActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -204,20 +207,20 @@ int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE
 }
 
 
-PyObject* KX_ParentActuator::_getattr(const char *attr) {      
+PyObject* KX_ParentActuator::py_getattro(PyObject *attr) {     
        
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int KX_ParentActuator::_setattr(const char *attr, PyObject* value) {
+int KX_ParentActuator::py_setattro(PyObject *attr, PyObject* value) {
        
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 /* Deprecated -----> */
index 257c95c..f9f0b73 100644 (file)
@@ -76,8 +76,8 @@ class KX_ParentActuator : public SCA_IActuator
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject* value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject* value);
 
        /* These are used to get and set m_ob */
        static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
index 4c04a96..3bef85e 100644 (file)
@@ -115,22 +115,27 @@ PyObject* KX_PhysicsObjectWrapper::PySetActive(PyObject* self,
 }
 
 
-
+PyAttributeDef KX_PhysicsObjectWrapper::Attributes[] = {
+       { NULL }        //Sentinel
+};
 
 //python specific stuff
 PyTypeObject KX_PhysicsObjectWrapper::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_PhysicsObjectWrapper",
                sizeof(KX_PhysicsObjectWrapper),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -139,13 +144,13 @@ PyParentObject KX_PhysicsObjectWrapper::Parents[] = {
        NULL
 };
 
-PyObject*      KX_PhysicsObjectWrapper::_getattr(const char *attr)
+PyObject*      KX_PhysicsObjectWrapper::py_getattro(PyObject *attr)
 {
-       _getattr_up(PyObjectPlus);
+       py_getattro_up(PyObjectPlus);
 }
 
 
-int    KX_PhysicsObjectWrapper::_setattr(const char *attr,PyObject *pyobj)
+int    KX_PhysicsObjectWrapper::py_setattro(PyObject *attr,PyObject *pyobj)
 {
        int result = 1;
 
@@ -158,7 +163,7 @@ int KX_PhysicsObjectWrapper::_setattr(const char *attr,PyObject *pyobj)
                result = 0;
        }
        if (result)
-               result = PyObjectPlus::_setattr(attr,pyobj);
+               result = PyObjectPlus::py_setattro(attr,pyobj);
                
        return result;
 };
index 9556069..6dc10f0 100644 (file)
@@ -36,8 +36,8 @@ class KX_PhysicsObjectWrapper : public PyObjectPlus
 {
        Py_Header;
 
-       virtual PyObject*               _getattr(const char *attr);
-       virtual int                     _setattr(const char *attr, PyObject *value);
+       virtual PyObject*               py_getattro(PyObject *attr);
+       virtual int                     py_setattro(PyObject *attr, PyObject *value);
 public:
        KX_PhysicsObjectWrapper(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsEnvironment* physenv,PyTypeObject *T = &Type);
        virtual ~KX_PhysicsObjectWrapper();
index 27fbe8b..6f74c3e 100644 (file)
 #include "KX_PyMath.h"
 
 PyTypeObject KX_PolyProxy::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_PolyProxy",
        sizeof(KX_PolyProxy),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -78,17 +81,18 @@ PyAttributeDef KX_PolyProxy::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_PolyProxy::_getattr(const char *attr)
+PyObject* KX_PolyProxy::py_getattro(PyObject *attr)
 {
-       if (!strcmp(attr, "matname"))
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "matname"))
        {
                return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
        }
-       if (!strcmp(attr, "texture"))
+       if (!strcmp(attr_str, "texture"))
        {
                return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
        }
-       if (!strcmp(attr, "material"))
+       if (!strcmp(attr_str, "material"))
        {
                RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial();
                if(polymat->GetFlag() & RAS_BLENDERMAT)
@@ -104,7 +108,7 @@ PyObject* KX_PolyProxy::_getattr(const char *attr)
                        return mat;
                }
        }
-       if (!strcmp(attr, "matid"))
+       if (!strcmp(attr_str, "matid"))
        {
                // we'll have to scan through the material bucket of the mes and compare with 
                // the one of the polygon
@@ -119,31 +123,31 @@ PyObject* KX_PolyProxy::_getattr(const char *attr)
                }
                return PyInt_FromLong(matid);
        }
-       if (!strcmp(attr, "v1"))
+       if (!strcmp(attr_str, "v1"))
        {
                return PyInt_FromLong(m_polygon->GetVertexOffset(0));
        }
-       if (!strcmp(attr, "v2"))
+       if (!strcmp(attr_str, "v2"))
        {
                return PyInt_FromLong(m_polygon->GetVertexOffset(1));
        }
-       if (!strcmp(attr, "v3"))
+       if (!strcmp(attr_str, "v3"))
        {
                return PyInt_FromLong(m_polygon->GetVertexOffset(2));
        }
-       if (!strcmp(attr, "v4"))
+       if (!strcmp(attr_str, "v4"))
        {
                return PyInt_FromLong(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffset(3):0));
        }
-       if (!strcmp(attr, "visible"))
+       if (!strcmp(attr_str, "visible"))
        {
                return PyInt_FromLong(m_polygon->IsVisible());
        }
-       if (!strcmp(attr, "collide"))
+       if (!strcmp(attr_str, "collide"))
        {
                return PyInt_FromLong(m_polygon->IsCollider());
        }
-       _getattr_up(SCA_IObject);
+       py_getattro_up(SCA_IObject);
 }
 
 KX_PolyProxy::KX_PolyProxy(const RAS_MeshObject*mesh, RAS_Polygon* polygon)
index 9b548f9..a549d98 100644 (file)
@@ -53,7 +53,7 @@ public:
 
 
 // stuff for python integration
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
 
        KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterialIndex)
        KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getNumVertex)
index 9e97914..6b9a620 100644 (file)
@@ -185,38 +185,42 @@ PyAttributeDef KX_PolygonMaterial::Attributes[] = {
 };
 
 PyTypeObject KX_PolygonMaterial::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_PolygonMaterial",
                sizeof(KX_PolygonMaterial),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
 PyParentObject KX_PolygonMaterial::Parents[] = {
-       &PyObjectPlus::Type,
        &KX_PolygonMaterial::Type,
+       &PyObjectPlus::Type,
        NULL
 };
 
-PyObject* KX_PolygonMaterial::_getattr(const char *attr)
+PyObject* KX_PolygonMaterial::py_getattro(PyObject *attr)
 {
-       if (!strcmp(attr, "texture"))
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "texture"))
                return PyString_FromString(m_texturename.ReadPtr());
-       if (!strcmp(attr, "material"))
+       if (!strcmp(attr_str, "material"))
                return PyString_FromString(m_materialname.ReadPtr());
                
-       if (!strcmp(attr, "tface"))
+       if (!strcmp(attr_str, "tface"))
                return PyCObject_FromVoidPtr(m_tface, NULL);
                
-       if (!strcmp(attr, "gl_texture"))
+       if (!strcmp(attr_str, "gl_texture"))
        {
                Image *ima = m_tface->tpage;
                int bind = 0;
@@ -226,49 +230,50 @@ PyObject* KX_PolygonMaterial::_getattr(const char *attr)
                return PyInt_FromLong(bind);
        }
        
-       if (!strcmp(attr, "tile"))
+       if (!strcmp(attr_str, "tile"))
                return PyInt_FromLong(m_tile);
-       if (!strcmp(attr, "tilexrep"))
+       if (!strcmp(attr_str, "tilexrep"))
                return PyInt_FromLong(m_tilexrep);
-       if (!strcmp(attr, "tileyrep"))
+       if (!strcmp(attr_str, "tileyrep"))
                return PyInt_FromLong(m_tileyrep);
        
-       if (!strcmp(attr, "drawingmode"))
+       if (!strcmp(attr_str, "drawingmode"))
                return PyInt_FromLong(m_drawingmode);
-       if (!strcmp(attr, "transparent"))
+       if (!strcmp(attr_str, "transparent"))
                return PyInt_FromLong(m_alpha);
-       if (!strcmp(attr, "zsort"))
+       if (!strcmp(attr_str, "zsort"))
                return PyInt_FromLong(m_zsort);
-       if (!strcmp(attr, "lightlayer"))
+       if (!strcmp(attr_str, "lightlayer"))
                return PyInt_FromLong(m_lightlayer);
-       if (!strcmp(attr, "triangle"))
+       if (!strcmp(attr_str, "triangle"))
                // deprecated, triangle/quads shouldn't have been a material property
                return 0;
                
-       if (!strcmp(attr, "diffuse"))
+       if (!strcmp(attr_str, "diffuse"))
                return PyObjectFrom(m_diffuse);
-       if (!strcmp(attr, "shininess"))
+       if (!strcmp(attr_str, "shininess"))
                return PyFloat_FromDouble(m_shininess);
-       if (!strcmp(attr, "specular"))
+       if (!strcmp(attr_str, "specular"))
                return PyObjectFrom(m_specular);
-       if (!strcmp(attr, "specularity"))
+       if (!strcmp(attr_str, "specularity"))
                return PyFloat_FromDouble(m_specularity);
        
-       _getattr_up(PyObjectPlus);
+       py_getattro_up(PyObjectPlus);
 }
 
-int KX_PolygonMaterial::_setattr(const char *attr, PyObject *pyvalue)
+int KX_PolygonMaterial::py_setattro(PyObject *attr, PyObject *pyvalue)
 {
+       char *attr_str= PyString_AsString(attr);
        if (PyFloat_Check(pyvalue))
        {
                float value = PyFloat_AsDouble(pyvalue);
-               if (!strcmp(attr, "shininess"))
+               if (!strcmp(attr_str, "shininess"))
                {
                        m_shininess = value;
                        return 0;
                }
                
-               if (!strcmp(attr, "specularity"))
+               if (!strcmp(attr_str, "specularity"))
                {
                        m_specularity = value;
                        return 0;
@@ -278,50 +283,50 @@ int KX_PolygonMaterial::_setattr(const char *attr, PyObject *pyvalue)
        if (PyInt_Check(pyvalue))
        {
                int value = PyInt_AsLong(pyvalue);
-               if (!strcmp(attr, "tile"))
+               if (!strcmp(attr_str, "tile"))
                {
                        m_tile = value;
                        return 0;
                }
                
-               if (!strcmp(attr, "tilexrep"))
+               if (!strcmp(attr_str, "tilexrep"))
                {
                        m_tilexrep = value;
                        return 0;
                }
                
-               if (!strcmp(attr, "tileyrep"))
+               if (!strcmp(attr_str, "tileyrep"))
                {
                        m_tileyrep = value;
                        return 0;
                }
                
-               if (!strcmp(attr, "drawingmode"))
+               if (!strcmp(attr_str, "drawingmode"))
                {
                        m_drawingmode = value;
                        return 0;
                }
                
-               if (!strcmp(attr, "transparent"))
+               if (!strcmp(attr_str, "transparent"))
                {
                        m_alpha = value;
                        return 0;
                }
                
-               if (!strcmp(attr, "zsort"))
+               if (!strcmp(attr_str, "zsort"))
                {
                        m_zsort = value;
                        return 0;
                }
                
-               if (!strcmp(attr, "lightlayer"))
+               if (!strcmp(attr_str, "lightlayer"))
                {
                        m_lightlayer = value;
                        return 0;
                }
                
                // This probably won't work...
-               if (!strcmp(attr, "triangle"))
+               if (!strcmp(attr_str, "triangle"))
                {
                        // deprecated, triangle/quads shouldn't have been a material property
                        return 0;
@@ -335,13 +340,13 @@ int KX_PolygonMaterial::_setattr(const char *attr, PyObject *pyvalue)
                        MT_Vector3 value;
                        if (PyVecTo(pyvalue, value))
                        {
-                               if (!strcmp(attr, "diffuse"))
+                               if (!strcmp(attr_str, "diffuse"))
                                {
                                        m_diffuse = value;
                                        return 0;
                                }
                                
-                               if (!strcmp(attr, "specular"))
+                               if (!strcmp(attr_str, "specular"))
                                {
                                        m_specular = value;
                                        return 0;
@@ -350,7 +355,7 @@ int KX_PolygonMaterial::_setattr(const char *attr, PyObject *pyvalue)
                }
        }
 
-       return PyObjectPlus::_setattr(attr, pyvalue);
+       return PyObjectPlus::py_setattro(attr, pyvalue);
 }
 
 KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setCustomMaterial, "setCustomMaterial(material)")
index a3ef4ca..f3eb197 100644 (file)
@@ -115,8 +115,8 @@ public:
        KX_PYMETHOD_DOC(KX_PolygonMaterial, setCustomMaterial);
        KX_PYMETHOD_DOC(KX_PolygonMaterial, loadProgram);
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int       _setattr(const char *attr, PyObject *pyvalue);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int       py_setattro(PyObject *attr, PyObject *pyvalue);
 };
 
 #endif // __KX_POLYGONMATERIAL_H__
index 7ddfbb0..f065eb2 100644 (file)
@@ -71,7 +71,9 @@
 
 #include "KX_PyMath.h"
 
-#include "PyObjectPlus.h" 
+#include "PyObjectPlus.h"
+
+#include "KX_PythonInitTypes.h" 
 
 extern "C" {
        #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use.
@@ -1257,6 +1259,7 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur
        //importBlenderModules()
        
        setSandbox(level);
+       initPyTypes();
 
        PyObject* moduleobj = PyImport_AddModule("__main__");
        return PyModule_GetDict(moduleobj);
@@ -1278,6 +1281,7 @@ PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLev
        Py_FrozenFlag=1;
 
        setSandbox(level);
+       initPyTypes();
 
        PyObject* moduleobj = PyImport_AddModule("__main__");
        return PyModule_GetDict(moduleobj);
diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
new file mode 100644 (file)
index 0000000..e2ff4ce
--- /dev/null
@@ -0,0 +1,204 @@
+/**
+ * $Id: PyObjectPlus.h 19511 2009-04-03 02:16:56Z campbellbarton $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+
+
+#ifndef _adr_py_init_types_h_                          // only process once,
+#define _adr_py_init_types_h_                          // even if multiply included
+
+/* Only for Class::Parents */
+#include "BL_BlenderShader.h"
+#include "BL_ShapeActionActuator.h"
+#include "KX_BlenderMaterial.h"
+#include "KX_CDActuator.h"
+#include "KX_CameraActuator.h"
+#include "KX_ConstraintActuator.h"
+#include "KX_ConstraintWrapper.h"
+#include "KX_GameActuator.h"
+#include "KX_Light.h"
+#include "KX_MeshProxy.h"
+#include "KX_MouseFocusSensor.h"
+#include "KX_NetworkMessageActuator.h"
+#include "KX_NetworkMessageSensor.h"
+#include "KX_ObjectActuator.h"
+#include "KX_ParentActuator.h"
+#include "KX_PhysicsObjectWrapper.h"
+#include "KX_PolyProxy.h"
+#include "KX_PolygonMaterial.h"
+#include "KX_SCA_AddObjectActuator.h"
+#include "KX_SCA_EndObjectActuator.h"
+#include "KX_SCA_ReplaceMeshActuator.h"
+#include "KX_SceneActuator.h"
+#include "KX_StateActuator.h"
+#include "KX_TrackToActuator.h"
+#include "KX_VehicleWrapper.h"
+#include "KX_VertexProxy.h"
+#include "SCA_2DFilterActuator.h"
+#include "SCA_ANDController.h"
+#include "SCA_ActuatorSensor.h"
+#include "SCA_AlwaysSensor.h"
+#include "SCA_DelaySensor.h"
+#include "SCA_JoystickSensor.h"
+#include "SCA_KeyboardSensor.h"
+#include "SCA_MouseSensor.h"
+#include "SCA_NANDController.h"
+#include "SCA_NORController.h"
+#include "SCA_ORController.h"
+#include "SCA_RandomSensor.h"
+#include "SCA_XNORController.h"
+#include "SCA_XORController.h"
+#include "KX_IpoActuator.h"
+#include "KX_NearSensor.h"
+#include "KX_RadarSensor.h"
+#include "KX_RaySensor.h"
+#include "KX_SCA_DynamicActuator.h"
+#include "KX_SoundActuator.h"
+#include "KX_TouchSensor.h"
+#include "SCA_PropertySensor.h"
+#include "SCA_PythonController.h"
+#include "SCA_RandomActuator.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((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((PyObject *)parents[i], stderr, 0);
+               fprintf(stderr, "\n");
+               PyObject_Print(parents[i]->tp_dict, stderr, 0);
+               fprintf(stderr, "\n\n");
+#endif
+
+       }
+}
+
+
+
+
+void initPyTypes(void)
+{
+       
+/*
+       initPyObjectPlusType(BL_ActionActuator::Parents);
+       .....
+*/
+
+       /* For now just do PyType_Ready */
+
+       PyType_Ready(&BL_ActionActuator::Type);
+       PyType_Ready(&BL_Shader::Type);
+       PyType_Ready(&BL_ShapeActionActuator::Type);
+       PyType_Ready(&CListValue::Type);
+       PyType_Ready(&CValue::Type);
+       PyType_Ready(&KX_BlenderMaterial::Type);
+       PyType_Ready(&KX_CDActuator::Type);
+       PyType_Ready(&KX_Camera::Type);
+       PyType_Ready(&KX_CameraActuator::Type);
+       PyType_Ready(&KX_ConstraintActuator::Type);
+       PyType_Ready(&KX_ConstraintWrapper::Type);
+       PyType_Ready(&KX_GameActuator::Type);
+       PyType_Ready(&KX_GameObject::Type);
+       PyType_Ready(&KX_IpoActuator::Type);
+       PyType_Ready(&KX_LightObject::Type);
+       PyType_Ready(&KX_MeshProxy::Type);
+       PyType_Ready(&KX_MouseFocusSensor::Type);
+       PyType_Ready(&KX_NearSensor::Type);
+       PyType_Ready(&KX_NetworkMessageActuator::Type);
+       PyType_Ready(&KX_NetworkMessageSensor::Type);
+       PyType_Ready(&KX_ObjectActuator::Type);
+       PyType_Ready(&KX_ParentActuator::Type);
+       PyType_Ready(&KX_PhysicsObjectWrapper::Type);
+       PyType_Ready(&KX_PolyProxy::Type);
+       PyType_Ready(&KX_PolygonMaterial::Type);
+       PyType_Ready(&KX_RadarSensor::Type);
+       PyType_Ready(&KX_RaySensor::Type);
+       PyType_Ready(&KX_SCA_AddObjectActuator::Type);
+       PyType_Ready(&KX_SCA_DynamicActuator::Type);
+       PyType_Ready(&KX_SCA_EndObjectActuator::Type);
+       PyType_Ready(&KX_SCA_ReplaceMeshActuator::Type);
+       PyType_Ready(&KX_Scene::Type);
+       PyType_Ready(&KX_SceneActuator::Type);
+       PyType_Ready(&KX_SoundActuator::Type);
+       PyType_Ready(&KX_StateActuator::Type);
+       PyType_Ready(&KX_TouchSensor::Type);
+       PyType_Ready(&KX_TrackToActuator::Type);
+       PyType_Ready(&KX_VehicleWrapper::Type);
+       PyType_Ready(&KX_VertexProxy::Type);
+       PyType_Ready(&PyObjectPlus::Type);
+       PyType_Ready(&SCA_2DFilterActuator::Type);
+       PyType_Ready(&SCA_ANDController::Type);
+       PyType_Ready(&SCA_ActuatorSensor::Type);
+       PyType_Ready(&SCA_AlwaysSensor::Type);
+       PyType_Ready(&SCA_DelaySensor::Type);
+       PyType_Ready(&SCA_ILogicBrick::Type);
+       PyType_Ready(&SCA_IObject::Type);
+       PyType_Ready(&SCA_ISensor::Type);
+       PyType_Ready(&SCA_JoystickSensor::Type);
+       PyType_Ready(&SCA_KeyboardSensor::Type);
+       PyType_Ready(&SCA_MouseSensor::Type);
+       PyType_Ready(&SCA_NANDController::Type);
+       PyType_Ready(&SCA_NORController::Type);
+       PyType_Ready(&SCA_ORController::Type);
+       PyType_Ready(&SCA_PropertyActuator::Type);
+       PyType_Ready(&SCA_PropertySensor::Type);
+       PyType_Ready(&SCA_PythonController::Type);
+       PyType_Ready(&SCA_RandomActuator::Type);
+       PyType_Ready(&SCA_RandomSensor::Type);
+       PyType_Ready(&SCA_XNORController::Type);
+       PyType_Ready(&SCA_XORController::Type);
+}
+
+#endif
\ No newline at end of file
diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.h b/source/gameengine/Ketsji/KX_PythonInitTypes.h
new file mode 100644 (file)
index 0000000..b30f033
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * $Id: PyObjectPlus.h 19511 2009-04-03 02:16:56Z campbellbarton $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef _adr_py_init_types_h_                          // only process once,
+#define _adr_py_init_types_h_                          // even if multiply included
+
+void initPyTypes(void);
+
+#endif
index 91ad60e..77cde79 100644 (file)
@@ -250,18 +250,21 @@ PyObject* KX_RadarSensor::PyGetConeHeight(PyObject* self) {
 /* Python Integration Hooks                                                  */
 /* ------------------------------------------------------------------------- */
 PyTypeObject KX_RadarSensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_RadarSensor",
        sizeof(KX_RadarSensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -295,20 +298,20 @@ PyAttributeDef KX_RadarSensor::Attributes[] = {
        {NULL} //Sentinel
 };
 
-PyObject* KX_RadarSensor::_getattr(const char *attr)
+PyObject* KX_RadarSensor::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
 
-       _getattr_up(KX_NearSensor);
+       py_getattro_up(KX_NearSensor);
 }
 
-int KX_RadarSensor::_setattr(const char *attr, PyObject* value)
+int KX_RadarSensor::py_setattro(PyObject *attr, PyObject* value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
 
-       return KX_NearSensor::_setattr(attr, value);
+       return KX_NearSensor::py_setattro(attr, value);
 }
index 6dfe0c4..c3a9416 100644 (file)
@@ -89,8 +89,8 @@ public:
                KX_RADAR_AXIS_NEG_Z
        };
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject* value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject* value);
 
        //Deprecated ----->
        KX_PYMETHOD_DOC_NOARGS(KX_RadarSensor,GetConeOrigin);
index fdaf482..cdcb5d7 100644 (file)
@@ -321,18 +321,21 @@ bool KX_RaySensor::Evaluate(CValue* event)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_RaySensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_RaySensor",
        sizeof(KX_RaySensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 
 };
@@ -442,18 +445,18 @@ PyObject* KX_RaySensor::PyGetHitNormal(PyObject* self)
 
 
 
-PyObject* KX_RaySensor::_getattr(const char *attr) {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+PyObject* KX_RaySensor::py_getattro(PyObject *attr) {
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_ISensor);
+       py_getattro_up(SCA_ISensor);
 }
 
-int KX_RaySensor::_setattr(const char *attr, PyObject *value) {
-       int ret = _setattr_self(Attributes, this, attr, value);
+int KX_RaySensor::py_setattro(PyObject *attr, PyObject *value) {
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_ISensor::_setattr(attr, value);
+       return SCA_ISensor::py_setattro(attr, value);
 }
 
 // <----- Deprecated
\ No newline at end of file
index e7901a0..a5d7d15 100644 (file)
@@ -86,8 +86,8 @@ public:
        };
 
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
        
        // Deprecated ----->
        KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetHitObject);
index 33e74d4..1dd642e 100644 (file)
@@ -167,22 +167,26 @@ void KX_SCA_AddObjectActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_SCA_AddObjectActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_SCA_AddObjectActuator",
        sizeof(KX_SCA_AddObjectActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
 PyParentObject KX_SCA_AddObjectActuator::Parents[] = {
+       &KX_SCA_AddObjectActuator::Type,
        &SCA_IActuator::Type,
        &SCA_ILogicBrick::Type,
        &CValue::Type,
@@ -251,20 +255,20 @@ PyObject* KX_SCA_AddObjectActuator::pyattr_get_objectLastCreated(void *self, con
 }
 
 
-PyObject* KX_SCA_AddObjectActuator::_getattr(const char *attr)
+PyObject* KX_SCA_AddObjectActuator::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int KX_SCA_AddObjectActuator::_setattr(const char *attr, PyObject* value) 
+int KX_SCA_AddObjectActuator::py_setattro(PyObject *attr, PyObject* value) 
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 /* 1. setObject */
index c8cc711..4ece5a6 100644 (file)
@@ -110,8 +110,8 @@ public:
        virtual bool 
        Update();
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject* value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject* value);
 
                SCA_IObject*    
        GetLastCreatedObject(
index 7dd5301..ae21209 100644 (file)
        PyTypeObject 
 
 KX_SCA_DynamicActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_SCA_DynamicActuator",
        sizeof(KX_SCA_DynamicActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -89,20 +92,20 @@ PyAttributeDef KX_SCA_DynamicActuator::Attributes[] = {
 };
 
 
-PyObject* KX_SCA_DynamicActuator::_getattr(const char *attr)
+PyObject* KX_SCA_DynamicActuator::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int KX_SCA_DynamicActuator::_setattr(const char *attr, PyObject* value)
+int KX_SCA_DynamicActuator::py_setattro(PyObject *attr, PyObject* value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 
index 082fcd7..9985512 100644 (file)
@@ -74,8 +74,8 @@ class KX_SCA_DynamicActuator : public SCA_IActuator
        };
 
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* 1. setOperation */
        KX_PYMETHOD_DOC(KX_SCA_DynamicActuator,setOperation);
index 6f0bd65..0db9e1c 100644 (file)
@@ -94,18 +94,21 @@ CValue* KX_SCA_EndObjectActuator::GetReplica()
 /* ------------------------------------------------------------------------- */
 
 PyTypeObject KX_SCA_EndObjectActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_SCA_EndObjectActuator",
        sizeof(KX_SCA_EndObjectActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -128,9 +131,9 @@ PyAttributeDef KX_SCA_EndObjectActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_SCA_EndObjectActuator::_getattr(const char *attr)
+PyObject* KX_SCA_EndObjectActuator::py_getattro(PyObject *attr)
 {
-  _getattr_up(SCA_IActuator);
+  py_getattro_up(SCA_IActuator);
 }
 
 /* eof */
index 1211874..2940246 100644 (file)
@@ -64,7 +64,7 @@ class KX_SCA_EndObjectActuator : public SCA_IActuator
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
        
 }; /* end of class KX_EditObjectActuator : public SCA_PropertyActuator */
 
index c892af7..0cac07b 100644 (file)
        PyTypeObject 
 
 KX_SCA_ReplaceMeshActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_SCA_ReplaceMeshActuator",
        sizeof(KX_SCA_ReplaceMeshActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
 PyParentObject KX_SCA_ReplaceMeshActuator::Parents[] = {
+       &KX_SCA_ReplaceMeshActuator::Type,
        &SCA_IActuator::Type,
        &SCA_ILogicBrick::Type,
        &CValue::Type,
@@ -90,20 +94,20 @@ PyAttributeDef KX_SCA_ReplaceMeshActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_SCA_ReplaceMeshActuator::_getattr(const char *attr)
+PyObject* KX_SCA_ReplaceMeshActuator::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int KX_SCA_ReplaceMeshActuator::_setattr(const char *attr, PyObject* value) 
+int KX_SCA_ReplaceMeshActuator::py_setattro(PyObject *attr, PyObject* value) 
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 PyObject* KX_SCA_ReplaceMeshActuator::pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
index ba43975..7a18df2 100644 (file)
@@ -71,8 +71,8 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator
 
        void    InstantReplaceMesh();
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject* value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject* value);
 
        static PyObject* pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
        static int pyattr_set_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
index 67f6c56..94ea234 100644 (file)
@@ -1517,18 +1517,21 @@ double KX_Scene::getSuspendedDelta()
 //Python
 
 PyTypeObject KX_Scene::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_Scene",
                sizeof(KX_Scene),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -1569,8 +1572,10 @@ PyObject* KX_Scene::pyattr_get_active_camera(void *self_v, const KX_PYATTRIBUTE_
 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 _getattr_up but in this case we want to include m_attrlist dict */
-       PyObject *dict= _getattr_dict(self->PyObjectPlus::_getattr("__dict__"), KX_Scene::Methods, KX_Scene::Attributes);
+       /* Useually done by py_getattro_up but in this case we want to include m_attrlist dict */
+       PyObject *dict_str= PyString_FromString("__dict__");
+       PyObject *dict= _getattr_dict(self->PyObjectPlus::py_getattro(dict_str), KX_Scene::Methods, KX_Scene::Attributes);
+       Py_DECREF(dict_str);
        
        PyDict_Update(dict, self->m_attrlist);
        return dict;
@@ -1587,34 +1592,34 @@ PyAttributeDef KX_Scene::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_Scene::_getattr(const char *attr)
+PyObject* KX_Scene::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
        
-       object = PyDict_GetItemString(m_attrlist, attr);
+       object = PyDict_GetItem(m_attrlist, attr);
        if (object)
        {
                Py_INCREF(object);
                return object;
        }
        
-       _getattr_up(PyObjectPlus);
+       py_getattro_up(PyObjectPlus);
 }
 
-int KX_Scene::_delattr(const char *attr)
+int KX_Scene::py_delattro(PyObject *attr)
 {
-       PyDict_DelItemString(m_attrlist, attr);
+       PyDict_DelItem(m_attrlist, attr);
        return 0;
 }
 
-int KX_Scene::_setattr(const char *attr, PyObject *pyvalue)
+int KX_Scene::py_setattro(PyObject *attr, PyObject *pyvalue)
 {
-       if (!PyDict_SetItemString(m_attrlist, attr, pyvalue))
+       if (!PyDict_SetItem(m_attrlist, attr, pyvalue))
                return 0;
 
-       return PyObjectPlus::_setattr(attr, pyvalue);
+       return PyObjectPlus::py_setattro(attr, pyvalue);
 }
 
 KX_PYMETHODDEF_DOC_NOARGS(KX_Scene, getLightList,
index d1da44c..df51fce 100644 (file)
@@ -574,10 +574,10 @@ public:
        static PyObject*        pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
        
 
-       virtual PyObject* _getattr(const char *attr); /* name, active_camera, gravity, suspended, viewport, framing, activity_culling, activity_culling_radius */
-       virtual int _setattr(const char *attr, PyObject *pyvalue);
-       virtual int _delattr(const char *attr);
-       virtual PyObject* _repr(void) { return PyString_FromString(GetName().ReadPtr()); }
+       virtual PyObject* py_getattro(PyObject *attr); /* name, active_camera, gravity, suspended, viewport, framing, activity_culling, activity_culling_radius */
+       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 595d2cb..40a2ff2 100644 (file)
@@ -226,18 +226,21 @@ KX_Scene* KX_SceneActuator::FindScene(char * sceneName)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_SceneActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_SceneActuator",
                sizeof(KX_SceneActuator),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -273,20 +276,20 @@ PyAttributeDef KX_SceneActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_SceneActuator::_getattr(const char *attr)
+PyObject* KX_SceneActuator::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int KX_SceneActuator::_setattr(const char *attr, PyObject *value)
+int KX_SceneActuator::py_setattro(PyObject *attr, PyObject *value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 PyObject* KX_SceneActuator::pyattr_get_camera(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
index 83b0d63..f1904f9 100644 (file)
@@ -92,8 +92,8 @@ class KX_SceneActuator : public SCA_IActuator
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        /* 1. set                                                                */
        /* Removed */
index f6c0283..b8d660d 100644 (file)
@@ -233,18 +233,21 @@ void KX_SoundActuator::setSoundObject(class SND_SoundObject* soundobject)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_SoundActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_SoundActuator",
                sizeof(KX_SoundActuator),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
@@ -286,9 +289,9 @@ PyAttributeDef KX_SoundActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_SoundActuator::_getattr(const char *attr)
+PyObject* KX_SoundActuator::py_getattro(PyObject *attr)
 {
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
 
index 68d5b79..3e4a416 100644 (file)
@@ -80,7 +80,7 @@ public:
        /* Python interface --------------------------------------------------- */
        /* -------------------------------------------------------------------- */
 
-       virtual PyObject*  _getattr(const char *attr);
+       virtual PyObject*  py_getattro(PyObject *attr);
 
        KX_PYMETHOD(KX_SoundActuator,SetFilename);
        KX_PYMETHOD(KX_SoundActuator,GetFilename);
index e48c420..3145723 100644 (file)
@@ -109,18 +109,21 @@ KX_StateActuator::Update()
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_StateActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_StateActuator",
        sizeof(KX_StateActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -146,9 +149,9 @@ PyAttributeDef KX_StateActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_StateActuator::_getattr(const char *attr)
+PyObject* KX_StateActuator::py_getattro(PyObject *attr)
 {
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 };
 
 
index 023b899..b6f1acf 100644 (file)
@@ -73,7 +73,7 @@ class KX_StateActuator : public SCA_IActuator
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
+       virtual PyObject* py_getattro(PyObject *attr);
        //KX_PYMETHOD_DOC
        KX_PYMETHOD_DOC(KX_StateActuator,SetOperation);
        KX_PYMETHOD_DOC(KX_StateActuator,SetMask);
index b1c22a8..49d3d20 100644 (file)
@@ -242,18 +242,21 @@ bool      KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll
 /* ------------------------------------------------------------------------- */
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_TouchSensor::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_TouchSensor",
        sizeof(KX_TouchSensor),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -288,29 +291,31 @@ PyAttributeDef KX_TouchSensor::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_TouchSensor::_getattr(const char *attr)
+PyObject* KX_TouchSensor::py_getattro(PyObject *attr)
 {      
-       if (!strcmp(attr, "objectHit")) {
+       PyObject* object= py_getattro_self(Attributes, this, attr);
+       if (object != NULL)
+               return object;
+       
+       char *attr_str= PyString_AsString(attr);
+       if (!strcmp(attr_str, "objectHit")) {
                if (m_hitObject)        return m_hitObject->AddRef();
                else                            Py_RETURN_NONE;
        }
-       if (!strcmp(attr, "objectHitList")) {
+       if (!strcmp(attr_str, "objectHitList")) {
                return m_colliders->AddRef();
        }
-
-       PyObject* object= _getattr_self(Attributes, this, attr);
-       if (object != NULL)
-               return object;
-       _getattr_up(SCA_ISensor);
+       
+       py_getattro_up(SCA_ISensor);
 }
 
-int KX_TouchSensor::_setattr(const char *attr, PyObject *value)
+int KX_TouchSensor::py_setattro(PyObject *attr, PyObject *value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
        
-       return SCA_ISensor::_setattr(attr, value);
+       return SCA_ISensor::py_setattro(attr, value);
 }
 
 /* Python API */
index 18ce940..93fadef 100644 (file)
@@ -120,8 +120,8 @@ public:
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
        
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        //Deprecated ----->
        /* 1. setProperty */
index 575abc5..58e1778 100644 (file)
@@ -425,18 +425,21 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_TrackToActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_TrackToActuator",
        sizeof(KX_TrackToActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -501,20 +504,20 @@ int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUT
 }
 
 
-PyObject* KX_TrackToActuator::_getattr(const char *attr)
+PyObject* KX_TrackToActuator::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int KX_TrackToActuator::_setattr(const char *attr, PyObject* value)
+int KX_TrackToActuator::py_setattro(PyObject *attr, PyObject* value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 /* 1. setObject */
index f81958d..cc4049e 100644 (file)
@@ -72,8 +72,8 @@ class KX_TrackToActuator : public SCA_IActuator
        virtual bool Update(double curtime, bool frame);
 
        /* Python part */
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject* value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject* value);
 
        /* These are used to get and set m_ob */
        static PyObject* pyattr_get_object(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
index 4960228..6afea4d 100644 (file)
@@ -299,33 +299,37 @@ PyObject* KX_VehicleWrapper::PyGetConstraintType(PyObject* self,
 
 //python specific stuff
 PyTypeObject KX_VehicleWrapper::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
                0,
                "KX_VehicleWrapper",
                sizeof(KX_VehicleWrapper),
                0,
                PyDestructor,
                0,
-               __getattr,
-               __setattr,
                0,
-               __repr,
-               0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+               0,
+               0,
+               py_base_repr,
+               0,0,0,0,0,0,
+               py_base_getattro,
+               py_base_setattro,
+               0,0,0,0,0,0,0,0,0,
                Methods
 };
 
 PyParentObject KX_VehicleWrapper::Parents[] = {
        &KX_VehicleWrapper::Type,
+       &PyObjectPlus::Type,
        NULL
 };
 
-PyObject*      KX_VehicleWrapper::_getattr(const char *attr)
+PyObject*      KX_VehicleWrapper::py_getattro(PyObject *attr)
 {
        //here you can search for existing data members (like mass,friction etc.)
-       _getattr_up(PyObjectPlus);
+       py_getattro_up(PyObjectPlus);
 }
 
-int    KX_VehicleWrapper::_setattr(const char *attr,PyObject* pyobj)
+int    KX_VehicleWrapper::py_setattro(PyObject *attr,PyObject* pyobj)
 {
        
        PyTypeObject* type = pyobj->ob_type;
@@ -349,7 +353,7 @@ int KX_VehicleWrapper::_setattr(const char *attr,PyObject* pyobj)
                result = 0;
        }
        if (result)
-               result = PyObjectPlus::_setattr(attr,pyobj);
+               result = PyObjectPlus::py_setattro(attr,pyobj);
        return result;
 };
 
index cad926c..4e03183 100644 (file)
@@ -12,8 +12,8 @@ class PHY_IMotionState;
 class  KX_VehicleWrapper : public PyObjectPlus
 {
        Py_Header;
-       virtual PyObject*               _getattr(const char *attr);
-       virtual int                     _setattr(const char *attr, PyObject *value);
+       virtual PyObject*               py_getattro(PyObject *attr);
+       virtual int                     py_setattro(PyObject *attr, PyObject *value);
 
        std::vector<PHY_IMotionState*> m_motionStates;
 
index d7b5203..8c8291e 100644 (file)
 #include "KX_PyMath.h"
 
 PyTypeObject KX_VertexProxy::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_VertexProxy",
        sizeof(KX_VertexProxy),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 };
 
@@ -80,43 +83,43 @@ PyAttributeDef KX_VertexProxy::Attributes[] = {
 };
 
 PyObject*
-KX_VertexProxy::_getattr(const char *attr)
+KX_VertexProxy::py_getattro(PyObject *attr)
 {
-  
-  if (attr[1]=='\0') { // Group single letters
+  char *attr_str= PyString_AsString(attr);
+  if (attr_str[1]=='\0') { // Group single letters
     // pos
-    if (attr[0]=='x')
+    if (attr_str[0]=='x')
        return PyFloat_FromDouble(m_vertex->getXYZ()[0]);
-    if (attr[0]=='y')
+    if (attr_str[0]=='y')
        return PyFloat_FromDouble(m_vertex->getXYZ()[1]);
-    if (attr[0]=='z')
+    if (attr_str[0]=='z')
        return PyFloat_FromDouble(m_vertex->getXYZ()[2]);
 
     // Col
-    if (attr[0]=='r')
+    if (attr_str[0]=='r')
        return PyFloat_FromDouble(m_vertex->getRGBA()[0]/255.0);
-    if (attr[0]=='g')
+    if (attr_str[0]=='g')
        return PyFloat_FromDouble(m_vertex->getRGBA()[1]/255.0);
-    if (attr[0]=='b')
+    if (attr_str[0]=='b')
        return PyFloat_FromDouble(m_vertex->getRGBA()[2]/255.0);
-    if (attr[0]=='a')
+    if (attr_str[0]=='a')
        return PyFloat_FromDouble(m_vertex->getRGBA()[3]/255.0);
 
     // UV
-    if (attr[0]=='u')
+    if (attr_str[0]=='u')
        return PyFloat_FromDouble(m_vertex->getUV1()[0]);
-    if (attr[0]=='v')
+    if (attr_str[0]=='v')
        return PyFloat_FromDouble(m_vertex->getUV1()[1]);
   }
   
   
-  if (!strcmp(attr, "XYZ"))
+  if (!strcmp(attr_str, "XYZ"))
        return PyObjectFrom(MT_Vector3(m_vertex->getXYZ()));
 
-  if (!strcmp(attr, "UV"))
+  if (!strcmp(attr_str, "UV"))
        return PyObjectFrom(MT_Point2(m_vertex->getUV1()));
 
-  if (!strcmp(attr, "color") || !strcmp(attr, "colour"))
+  if (!strcmp(attr_str, "color") || !strcmp(attr_str, "colour"))
   {
        const unsigned char *colp = m_vertex->getRGBA();
        MT_Vector4 color(colp[0], colp[1], colp[2], colp[3]);
@@ -124,19 +127,20 @@ KX_VertexProxy::_getattr(const char *attr)
        return PyObjectFrom(color);
   }
   
-  if (!strcmp(attr, "normal"))
+  if (!strcmp(attr_str, "normal"))
   {
        return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
   }
   
-  _getattr_up(SCA_IObject);
+  py_getattro_up(SCA_IObject);
 }
 
-int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
+int    KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
 {
+  char *attr_str= PyString_AsString(attr);
   if (PySequence_Check(pyvalue))
   {
-       if (!strcmp(attr, "XYZ"))
+       if (!strcmp(attr_str, "XYZ"))
        {
                MT_Point3 vec;
                if (PyVecTo(pyvalue, vec))
@@ -148,7 +152,7 @@ int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
                return 1;
        }
        
-       if (!strcmp(attr, "UV"))
+       if (!strcmp(attr_str, "UV"))
        {
                MT_Point2 vec;
                if (PyVecTo(pyvalue, vec))
@@ -160,7 +164,7 @@ int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
                return 1;
        }
        
-       if (!strcmp(attr, "color") || !strcmp(attr, "colour"))
+       if (!strcmp(attr_str, "color") || !strcmp(attr_str, "colour"))
        {
                MT_Vector4 vec;
                if (PyVecTo(pyvalue, vec))
@@ -172,7 +176,7 @@ int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
                return 1;
        }
        
-       if (!strcmp(attr, "normal"))
+       if (!strcmp(attr_str, "normal"))
        {
                MT_Vector3 vec;
                if (PyVecTo(pyvalue, vec))
@@ -190,7 +194,7 @@ int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
        float val = PyFloat_AsDouble(pyvalue);
        // pos
        MT_Point3 pos(m_vertex->getXYZ());
-       if (!strcmp(attr, "x"))
+       if (!strcmp(attr_str, "x"))
        {
                pos.x() = val;
                m_vertex->SetXYZ(pos);
@@ -198,7 +202,7 @@ int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
                return 0;
        }
        
-       if (!strcmp(attr, "y"))
+       if (!strcmp(attr_str, "y"))
        {
                pos.y() = val;
                m_vertex->SetXYZ(pos);
@@ -206,7 +210,7 @@ int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
                return 0;
        }
        
-       if (!strcmp(attr, "z"))
+       if (!strcmp(attr_str, "z"))
        {
                pos.z() = val;
                m_vertex->SetXYZ(pos);
@@ -216,7 +220,7 @@ int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
        
        // uv
        MT_Point2 uv = m_vertex->getUV1();
-       if (!strcmp(attr, "u"))
+       if (!strcmp(attr_str, "u"))
        {
                uv[0] = val;
                m_vertex->SetUV(uv);
@@ -224,7 +228,7 @@ int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
                return 0;
        }
 
-       if (!strcmp(attr, "v"))
+       if (!strcmp(attr_str, "v"))
        {
                uv[1] = val;
                m_vertex->SetUV(uv);
@@ -234,7 +238,7 @@ int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
 
        // uv
        MT_Point2 uv2 = m_vertex->getUV2();
-       if (!strcmp(attr, "u2"))
+       if (!strcmp(attr_str, "u2"))
        {
                uv[0] = val;
                m_vertex->SetUV2(uv);
@@ -242,7 +246,7 @@ int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
                return 0;
        }
 
-       if (!strcmp(attr, "v2"))
+       if (!strcmp(attr_str, "v2"))
        {
                uv[1] = val;
                m_vertex->SetUV2(uv);
@@ -254,28 +258,28 @@ int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
        unsigned int icol = *((const unsigned int *)m_vertex->getRGBA());
        unsigned char *cp = (unsigned char*) &icol;
        val *= 255.0;
-       if (!strcmp(attr, "r"))
+       if (!strcmp(attr_str, "r"))
        {
                cp[0] = (unsigned char) val;
                m_vertex->SetRGBA(icol);
                m_mesh->SetMeshModified(true);
                return 0;
        }
-       if (!strcmp(attr, "g"))
+       if (!strcmp(attr_str, "g"))
        {
                cp[1] = (unsigned char) val;
                m_vertex->SetRGBA(icol);
                m_mesh->SetMeshModified(true);
                return 0;
        }
-       if (!strcmp(attr, "b"))
+       if (!strcmp(attr_str, "b"))
        {
                cp[2] = (unsigned char) val;
                m_vertex->SetRGBA(icol);
                m_mesh->SetMeshModified(true);
                return 0;
        }
-       if (!strcmp(attr, "a"))
+       if (!strcmp(attr_str, "a"))
        {
                cp[3] = (unsigned char) val;
                m_vertex->SetRGBA(icol);
@@ -284,7 +288,7 @@ int    KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue)
        }
   }
   
-  return SCA_IObject::_setattr(attr, pyvalue);
+  return SCA_IObject::py_setattro(attr, pyvalue);
 }
 
 KX_VertexProxy::KX_VertexProxy(KX_MeshProxy*mesh, RAS_TexVert* vertex)
index 2819607..26772fc 100644 (file)
@@ -54,8 +54,8 @@ public:
 
 
 // stuff for python integration
-       virtual PyObject* _getattr(const char *attr);
-       virtual int    _setattr(const char *attr, PyObject *pyvalue);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int    py_setattro(PyObject *attr, PyObject *pyvalue);
 
        KX_PYMETHOD_NOARGS(KX_VertexProxy,GetXYZ);
        KX_PYMETHOD_O(KX_VertexProxy,SetXYZ);
index 10e8c82..35edd84 100644 (file)
@@ -91,18 +91,21 @@ KX_VisibilityActuator::Update()
 
 /* Integration hooks ------------------------------------------------------- */
 PyTypeObject KX_VisibilityActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
+       PyObject_HEAD_INIT(NULL)
        0,
        "KX_VisibilityActuator",
        sizeof(KX_VisibilityActuator),
        0,
        PyDestructor,
        0,
-       __getattr,
-       __setattr,
        0,
-       __repr,
-       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+       0,
+       0,
+       py_base_repr,
+       0,0,0,0,0,0,
+       py_base_getattro,
+       py_base_setattro,
+       0,0,0,0,0,0,0,0,0,
        Methods
 
 };
@@ -131,20 +134,20 @@ PyAttributeDef KX_VisibilityActuator::Attributes[] = {
        { NULL }        //Sentinel
 };
 
-PyObject* KX_VisibilityActuator::_getattr(const char *attr)
+PyObject* KX_VisibilityActuator::py_getattro(PyObject *attr)
 {
-       PyObject* object = _getattr_self(Attributes, this, attr);
+       PyObject* object = py_getattro_self(Attributes, this, attr);
        if (object != NULL)
                return object;
-       _getattr_up(SCA_IActuator);
+       py_getattro_up(SCA_IActuator);
 }
 
-int KX_VisibilityActuator::_setattr(const char *attr, PyObject *value)
+int KX_VisibilityActuator::py_setattro(PyObject *attr, PyObject *value)
 {
-       int ret = _setattr_self(Attributes, this, attr, value);
+       int ret = py_setattro_self(Attributes, this, attr, value);
        if (ret >= 0)
                return ret;
-       return SCA_IActuator::_setattr(attr, value);
+       return SCA_IActuator::py_setattro(attr, value);
 }
 
 
index 2e2a595..fca3750 100644 (file)
@@ -67,8 +67,8 @@ class KX_VisibilityActuator : public SCA_IActuator
        /* Python interface ---------------------------------------------------- */
        /* --------------------------------------------------------------------- */
 
-       virtual PyObject* _getattr(const char *attr);
-       virtual int _setattr(const char *attr, PyObject *value);
+       virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject *value);
 
        // Deprecated ----->
        KX_PYMETHOD_DOC(KX_VisibilityActuator,SetVisible);