diff options
Diffstat (limited to 'source/gameengine')
128 files changed, 1384 insertions, 905 deletions
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 88f75eac1d5..943bb68f6f2 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -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 diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 6161048afb8..7160dd4dad0 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -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*) diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 74953a90bb3..c53be4653ca 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -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 */ diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index 7f2431bcfa5..ea25d66e050 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -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*) { diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index aa84cab0266..15eb8835b79 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -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); } diff --git a/source/gameengine/Expressions/ListValue.h b/source/gameengine/Expressions/ListValue.h index 104e3e63283..f936298a8c4 100644 --- a/source/gameengine/Expressions/ListValue.h +++ b/source/gameengine/Expressions/ListValue.h @@ -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); diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 417388be464..ed6932b414a 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -55,19 +55,22 @@ ------------------------------*/ 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. diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 345eb8c9c3f..77963c092eb 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -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 diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 36509763454..8b910b9038b 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -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; }; diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index 4678ab1f0c2..7a2816a9778 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -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 ); diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index 0b410728512..9d4dc1f33d6 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -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); } diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h index 9da0500afff..f69c680b774 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -38,7 +38,7 @@ public: virtual bool Update(); virtual CValue* GetReplica(); - virtual PyObject* _getattr(const char *attr); + virtual PyObject* py_getattro(PyObject *attr); }; #endif diff --git a/source/gameengine/GameLogic/SCA_ANDController.cpp b/source/gameengine/GameLogic/SCA_ANDController.cpp index de67037b64a..cb62e2b5a1d 100644 --- a/source/gameengine/GameLogic/SCA_ANDController.cpp +++ b/source/gameengine/GameLogic/SCA_ANDController.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_ANDController.h b/source/gameengine/GameLogic/SCA_ANDController.h index eba7e1b545a..fdb93d0fc42 100644 --- a/source/gameengine/GameLogic/SCA_ANDController.h +++ b/source/gameengine/GameLogic/SCA_ANDController.h @@ -48,7 +48,7 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - virtual PyObject* _getattr(const char *attr); + virtual PyObject* py_getattro(PyObject *attr); }; diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp index d5c3e1960fe..ed7aa66d04b 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h index 75ee08f42d6..9bc873e4ee1 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h @@ -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); diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp index e2125b8b08d..a7b0e5a14d2 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp +++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.h b/source/gameengine/GameLogic/SCA_AlwaysSensor.h index ebe6ba80208..87949babf59 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysSensor.h +++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.h @@ -52,7 +52,7 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - virtual PyObject* _getattr(const char *attr); + virtual PyObject* py_getattro(PyObject *attr); }; diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp index 733057017a7..5082caacfd5 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp +++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp @@ -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); } diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h index 491eee61da8..f9e3d619198 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.h +++ b/source/gameengine/GameLogic/SCA_DelaySensor.h @@ -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); diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.h b/source/gameengine/GameLogic/SCA_ExpressionController.h index 79c26eea1e7..2936742be19 100644 --- a/source/gameengine/GameLogic/SCA_ExpressionController.h +++ b/source/gameengine/GameLogic/SCA_ExpressionController.h @@ -59,7 +59,7 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ -// virtual PyObject* _getattr(const char *attr); +// virtual PyObject* py_getattro(PyObject *attr); }; diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index 3cefe638726..45ebd874ea5 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -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); } diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index 70d49941613..c098f9dfd8a 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -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; diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index 976665a3ccd..d1ce377316b 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -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); } diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h index d47353b1ac0..44ed3c8f3fe 100644 --- a/source/gameengine/GameLogic/SCA_IObject.h +++ b/source/gameengine/GameLogic/SCA_IObject.h @@ -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;} diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 0d7dffca17a..8a40c0c35f3 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 23f2c76c19f..ce7b66df1cd 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -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); diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 6b8779ee37a..0cfd6843c1b 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -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); } diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index 49d220c056d..ccdd2107b21 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -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); diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index bf470daa349..fc1b5be3540 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -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); } diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h index bc2f86327a5..c579b6a82f8 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 19365fbbb88..c5f6fdabbe8 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h index 30b43fe53cc..73410569cc2 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.h +++ b/source/gameengine/GameLogic/SCA_MouseSensor.h @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp index 2bc6a3ef1d6..bddd5f4d3ab 100644 --- a/source/gameengine/GameLogic/SCA_NANDController.cpp +++ b/source/gameengine/GameLogic/SCA_NANDController.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_NANDController.h b/source/gameengine/GameLogic/SCA_NANDController.h index d88504cfc0d..11600914a1a 100644 --- a/source/gameengine/GameLogic/SCA_NANDController.h +++ b/source/gameengine/GameLogic/SCA_NANDController.h @@ -48,7 +48,7 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - virtual PyObject* _getattr(const char *attr); + virtual PyObject* py_getattro(PyObject *attr); }; diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp index 98ba77df54c..3ee073523c3 100644 --- a/source/gameengine/GameLogic/SCA_NORController.cpp +++ b/source/gameengine/GameLogic/SCA_NORController.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_NORController.h b/source/gameengine/GameLogic/SCA_NORController.h index 45b639f3f3f..fc814e28d37 100644 --- a/source/gameengine/GameLogic/SCA_NORController.h +++ b/source/gameengine/GameLogic/SCA_NORController.h @@ -48,7 +48,7 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - virtual PyObject* _getattr(const char *attr); + virtual PyObject* py_getattro(PyObject *attr); }; diff --git a/source/gameengine/GameLogic/SCA_ORController.cpp b/source/gameengine/GameLogic/SCA_ORController.cpp index ba616402ac9..91d5e56d4f3 100644 --- a/source/gameengine/GameLogic/SCA_ORController.cpp +++ b/source/gameengine/GameLogic/SCA_ORController.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_ORController.h b/source/gameengine/GameLogic/SCA_ORController.h index 9a6e9e75022..fdc81486e74 100644 --- a/source/gameengine/GameLogic/SCA_ORController.h +++ b/source/gameengine/GameLogic/SCA_ORController.h @@ -49,7 +49,7 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - virtual PyObject* _getattr(const char *attr); + virtual PyObject* py_getattro(PyObject *attr); }; #endif //__KX_ORCONTROLLER diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index 28a3b6b822a..e1f303430ec 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h index 444d9285796..6a975716ed0 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.h +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h @@ -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); diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index ef3dbe7e049..659823f6fba 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h index 2594e3fca9d..076c1ae51ec 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.h +++ b/source/gameengine/GameLogic/SCA_PropertySensor.h @@ -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); diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 4ad3f135d31..2d200e0a238 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -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) diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index 4ec18f32c23..3348071c00f 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -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); diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index 78614f9ace3..a9a664b0686 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h index 0d404fa8a9f..96ca353257f 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.h +++ b/source/gameengine/GameLogic/SCA_RandomActuator.h @@ -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); diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index d88f8f500c0..84a9ef95e84 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h index d808db07536..39d072dd316 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.h +++ b/source/gameengine/GameLogic/SCA_RandomSensor.h @@ -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); diff --git a/source/gameengine/GameLogic/SCA_XNORController.cpp b/source/gameengine/GameLogic/SCA_XNORController.cpp index a9fe906f54e..10757e1c935 100644 --- a/source/gameengine/GameLogic/SCA_XNORController.cpp +++ b/source/gameengine/GameLogic/SCA_XNORController.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_XNORController.h b/source/gameengine/GameLogic/SCA_XNORController.h index a431a72c177..c992d5f1834 100644 --- a/source/gameengine/GameLogic/SCA_XNORController.h +++ b/source/gameengine/GameLogic/SCA_XNORController.h @@ -48,7 +48,7 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - virtual PyObject* _getattr(const char *attr); + virtual PyObject* py_getattro(PyObject *attr); }; diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp index b0053ca17fb..d2290fe207a 100644 --- a/source/gameengine/GameLogic/SCA_XORController.cpp +++ b/source/gameengine/GameLogic/SCA_XORController.cpp @@ -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 */ diff --git a/source/gameengine/GameLogic/SCA_XORController.h b/source/gameengine/GameLogic/SCA_XORController.h index 2fbc7866ecf..065b31fd901 100644 --- a/source/gameengine/GameLogic/SCA_XORController.h +++ b/source/gameengine/GameLogic/SCA_XORController.h @@ -48,7 +48,7 @@ public: /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ - virtual PyObject* _getattr(const char *attr); + virtual PyObject* py_getattro(PyObject *attr); }; diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 14f672bb68f..279721b4840 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -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 }; diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h index 76acd5513ef..490c0268a6d 100644 --- a/source/gameengine/Ketsji/BL_Shader.h +++ b/source/gameengine/Ketsji/BL_Shader.h @@ -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 ); diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp index 0a7e20b8650..a5fd8ebab6b 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp @@ -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 -----> diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h index d9a7f787333..850f825b8f3 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index d5434a34eb7..7922c341659 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -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) diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h index 79e8bc910d1..ac0e880d25c 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 668873883af..bd137196ac6 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -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); } diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 2cf623dbd85..2d9dc8fd022 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -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 ); diff --git a/source/gameengine/Ketsji/KX_CDActuator.cpp b/source/gameengine/Ketsji/KX_CDActuator.cpp index f86a5669225..57c9d30e92e 100644 --- a/source/gameengine/Ketsji/KX_CDActuator.cpp +++ b/source/gameengine/Ketsji/KX_CDActuator.cpp @@ -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); } diff --git a/source/gameengine/Ketsji/KX_CDActuator.h b/source/gameengine/Ketsji/KX_CDActuator.h index 08ca6a82db3..e7683297c7a 100644 --- a/source/gameengine/Ketsji/KX_CDActuator.h +++ b/source/gameengine/Ketsji/KX_CDActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index cb138efba89..19370d83322 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -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, diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h index b80be9a7fee..499db66ab14 100644 --- a/source/gameengine/Ketsji/KX_Camera.h +++ b/source/gameengine/Ketsji/KX_Camera.h @@ -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); }; diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 08afa2853c3..354143f1e69 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -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 ---------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index 3b08536fc21..5d7473a5bf0 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 31a566f34ad..feee851bb01 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -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 */ diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index 132b8a7328a..193400fbf2b 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp index 05e677b9fd3..edd6e991e9f 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp @@ -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; }; diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.h b/source/gameengine/Ketsji/KX_ConstraintWrapper.h index 36606d2d67b..6e67d842cb6 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.h +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.h @@ -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 (); diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp index 6800c75d807..a2a3d486420 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.cpp +++ b/source/gameengine/Ketsji/KX_GameActuator.cpp @@ -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); } diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h index ad638254c31..570cb2e68ef 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.h +++ b/source/gameengine/Ketsji/KX_GameActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 2bd4b2834d1..f0c5667479c 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -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) diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index bada19c4895..4b136e268db 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index 5d1d45879c9..adb9c284828 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -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 --------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h index fa8e58ae861..7e85a28eb96 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.h +++ b/source/gameengine/Ketsji/KX_IpoActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index f71dd69a7a3..6f9d8b0211b 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -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 }; diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h index 98dcc8ef873..4559954c8d7 100644 --- a/source/gameengine/Ketsji/KX_Light.h +++ b/source/gameengine/Ketsji/KX_Light.h @@ -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; } }; diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index f349a6b519a..f464cb798e8 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -46,18 +46,21 @@ #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); } diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h index 9e08937de07..0b9738153ff 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.h +++ b/source/gameengine/Ketsji/KX_MeshProxy.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 973dfce505b..72a0381e8dc 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -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); } diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h index 4979783032c..804f34e6076 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index 383d673b7ea..2debfd793c1 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -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); } diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h index ee03992e734..26c5feb4e67 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.h +++ b/source/gameengine/Ketsji/KX_NearSensor.h @@ -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 diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index ca2157f2bc0..a343eeb71cc 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -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 ------------------------------------------------------------------ */ diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index 0331c67617c..00c8fb700ae 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 4c0507cd0bf..1baf581f8a0 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -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 -----> */ diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h index 257c95c9260..f9f0b73b876 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.h +++ b/source/gameengine/Ketsji/KX_ParentActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp index 4c04a96eae2..3bef85e7f93 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp @@ -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; }; diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h index 95560698896..6dc10f030f0 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h @@ -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(); diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index 27fbe8b19f3..6f74c3ed3f9 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -39,18 +39,21 @@ #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) diff --git a/source/gameengine/Ketsji/KX_PolyProxy.h b/source/gameengine/Ketsji/KX_PolyProxy.h index 9b548f9490d..a549d9841cc 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.h +++ b/source/gameengine/Ketsji/KX_PolyProxy.h @@ -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) diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 9e979144c47..6b9a6201d5c 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -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)") diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h index a3ef4ca51ef..f3eb1979f34 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.h +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h @@ -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__ diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 7ddfbb0d5fe..f065eb29c44 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -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 index 00000000000..e2ff4ced122 --- /dev/null +++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp @@ -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 index 00000000000..b30f0334b6e --- /dev/null +++ b/source/gameengine/Ketsji/KX_PythonInitTypes.h @@ -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 diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 91ad60e8cee..77cde79b54d 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -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); } diff --git a/source/gameengine/Ketsji/KX_RadarSensor.h b/source/gameengine/Ketsji/KX_RadarSensor.h index 6dfe0c42f5d..c3a941696ce 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.h +++ b/source/gameengine/Ketsji/KX_RadarSensor.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index fdaf48218b3..cdcb5d74f30 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -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 diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h index e7901a0d10d..a5d7d15c60c 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.h +++ b/source/gameengine/Ketsji/KX_RaySensor.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index 33e74d4dc5a..1dd642e0966 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -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 */ diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index c8cc7113347..4ece5a6d83b 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -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( diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp index 7dd5301385c..ae21209fc4e 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp @@ -51,18 +51,21 @@ 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); } diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h index 082fcd72035..99855124bdb 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp index 6f0bd65ce43..0db9e1c4930 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp @@ -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 */ diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h index 12118743f0a..2940246f443 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h @@ -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 */ diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index c892af71159..0cac07b4585 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -53,22 +53,26 @@ 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) diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h index ba43975bd51..7a18df2356d 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 67f6c567549..94ea234f1bf 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -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, diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index d1da44c600e..df51fcec8f7 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -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()); } /** diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index 595d2cb4070..40a2ff2ef66 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -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) diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h index 83b0d63bcd2..f1904f95c2a 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.h +++ b/source/gameengine/Ketsji/KX_SceneActuator.h @@ -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 */ diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index f6c0283d49f..b8d660daa08 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -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); } diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h index 68d5b792729..3e4a4168434 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.h +++ b/source/gameengine/Ketsji/KX_SoundActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp index e48c4209923..31457230f60 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.cpp +++ b/source/gameengine/Ketsji/KX_StateActuator.cpp @@ -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); }; diff --git a/source/gameengine/Ketsji/KX_StateActuator.h b/source/gameengine/Ketsji/KX_StateActuator.h index 023b8993d7c..b6f1acf4a00 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.h +++ b/source/gameengine/Ketsji/KX_StateActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index b1c22a86f3d..49d3d20dc3d 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -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 */ diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index 18ce9406a9b..93fadef4abd 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -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 */ diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 575abc5d748..58e17785b81 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -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 */ diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index f81958dfb33..cc4049e19a8 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp index 4960228056a..6afea4d3227 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp @@ -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; }; diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.h b/source/gameengine/Ketsji/KX_VehicleWrapper.h index cad926ce85a..4e03183bf85 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.h +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.h @@ -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; diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index d7b5203795d..8c8291ef791 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -37,18 +37,21 @@ #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) diff --git a/source/gameengine/Ketsji/KX_VertexProxy.h b/source/gameengine/Ketsji/KX_VertexProxy.h index 28196075904..26772fc7d60 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.h +++ b/source/gameengine/Ketsji/KX_VertexProxy.h @@ -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); diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index 10e8c827394..35edd84f994 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -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); } diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.h b/source/gameengine/Ketsji/KX_VisibilityActuator.h index 2e2a5957777..fca37500915 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.h +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.h @@ -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); |