diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-07 20:00:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-07 20:00:32 +0400 |
commit | 18511c56d3cbfd0b368be61002960cc161cee526 (patch) | |
tree | 0809a4749ae64c1e34133a179b0bdd02a98c6f0c /source/gameengine/Expressions/PyObjectPlus.h | |
parent | 1534eca60f181dc4e4299f6bdf73a66bbdf87970 (diff) |
BGE Python API (small changes)
- Make BGE's ListValue types convert to python lists for printing since the CValue GetText() function didnt work well- printing lists as [,,,,,] for scene objects and mesh materials for eg.
- Check attributes are descriptor types before casting.
- py_getattr_dict use the Type dict rather then Method and Attribute array.
Diffstat (limited to 'source/gameengine/Expressions/PyObjectPlus.h')
-rw-r--r-- | source/gameengine/Expressions/PyObjectPlus.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 41bf72964ce..d549be6ef60 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -105,15 +105,18 @@ static inline void Py_Fatal(const char *M) { if(descr) { \ if (PyCObject_Check(descr)) { \ return py_get_attrdef((void *)this, (const PyAttributeDef*)PyCObject_AsVoidPtr(descr)); \ - } else { \ + } else if (descr->ob_type->tp_descr_get) { \ return PyCFunction_New(((PyMethodDescrObject *)descr)->d_method, (PyObject *)this); \ + } else { \ + fprintf(stderr, "unknown attribute type"); \ + return descr; \ } \ } else { \ PyErr_Clear(); \ PyObject *rvalue= Parent::py_getattro(attr); \ \ if (strcmp(PyString_AsString(attr), "__dict__")==0) { \ - return py_getattr_dict(rvalue, Methods, Attributes); \ + return py_getattr_dict(rvalue, Type.tp_dict); \ } \ \ return rvalue; \ @@ -434,7 +437,7 @@ public: } }; -PyObject *py_getattr_dict(PyObject *pydict, PyMethodDef *meth, PyAttributeDef *attrdef); +PyObject *py_getattr_dict(PyObject *pydict, PyObject *tp_dict); #endif // _adr_py_lib_h_ |