Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-04-21 03:17:52 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-21 03:17:52 +0400
commit217bbb7800679899302ddb058f9ceea1d00c7ce1 (patch)
tree05cef2f2d94dc0af0cbf027c233f5d35ff782eee /source/gameengine/Expressions/PyObjectPlus.cpp
parent2d0d06f642b661b084657c05ebb0c664f998a937 (diff)
BGE Python API
Separate getting a normal attribute and getting __dict__, was having to do too a check for __dict__ on each class (multiple times per getattro call from python) when its not used that often.
Diffstat (limited to 'source/gameengine/Expressions/PyObjectPlus.cpp')
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp
index 6cfa14ddc80..c4daaff2dd1 100644
--- a/source/gameengine/Expressions/PyObjectPlus.cpp
+++ b/source/gameengine/Expressions/PyObjectPlus.cpp
@@ -143,7 +143,13 @@ PyObject *PyObjectPlus::py_base_getattro(PyObject * self, PyObject *attr)
PyErr_SetString(PyExc_RuntimeError, BGE_PROXY_ERROR_MSG);
return NULL;
}
- return self_plus->py_getattro(attr);
+
+ PyObject *ret= self_plus->py_getattro(attr);
+
+ if(ret==NULL && (strcmp(PyString_AsString(attr), "__dict__")==0))
+ ret= self_plus->py_getattro_dict();
+
+ return ret;
}
/* This should be the entry in Type since it takes the C++ class from PyObjectPlus_Proxy */
@@ -177,9 +183,6 @@ PyObject *PyObjectPlus::py_getattro(PyObject* attr)
{
PyObject *descr = PyDict_GetItem(Type.tp_dict, attr); \
if (descr == NULL) {
- if (strcmp(PyString_AsString(attr), "__dict__")==0) {
- return py_getattr_dict(NULL, Type.tp_dict); /* no Attributes yet */
- }
PyErr_Format(PyExc_AttributeError, "attribute \"%s\" not found", PyString_AsString(attr));
return NULL;
} else {
@@ -196,6 +199,10 @@ PyObject *PyObjectPlus::py_getattro(PyObject* attr)
}
}
+PyObject* PyObjectPlus::py_getattro_dict() {
+ return py_getattr_dict(NULL, Type.tp_dict);
+}
+
int PyObjectPlus::py_delattro(PyObject* attr)
{
PyErr_SetString(PyExc_AttributeError, "attribute cant be deleted");