diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-21 03:17:52 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-21 03:17:52 +0400 |
commit | 217bbb7800679899302ddb058f9ceea1d00c7ce1 (patch) | |
tree | 05cef2f2d94dc0af0cbf027c233f5d35ff782eee /source/gameengine/Expressions/PyObjectPlus.h | |
parent | 2d0d06f642b661b084657c05ebb0c664f998a937 (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.h')
-rw-r--r-- | source/gameengine/Expressions/PyObjectPlus.h | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 370717a919b..b0ddfa04e32 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -130,16 +130,12 @@ typedef struct { } \ } else { \ PyErr_Clear(); \ - PyObject *rvalue= Parent::py_getattro(attr); \ - \ - if (strcmp(PyString_AsString(attr), "__dict__")==0) { \ - return py_getattr_dict(rvalue, Type.tp_dict); \ - } \ - \ - return rvalue; \ + return Parent::py_getattro(attr); \ } \ return NULL; +#define py_getattro_dict_up(Parent) \ + return py_getattr_dict(Parent::py_getattro_dict(), Type.tp_dict); /* * nonzero values are an error for setattr @@ -434,6 +430,7 @@ public: /* These are all virtual python methods that are defined in each class * Our own fake subclassing calls these on each class, then calls the parent */ virtual PyObject* py_getattro(PyObject *attr); + virtual PyObject* py_getattro_dict(); virtual int py_delattro(PyObject *attr); virtual int py_setattro(PyObject *attr, PyObject *value); virtual PyObject* py_repr(void); |