From 18511c56d3cbfd0b368be61002960cc161cee526 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Apr 2009 16:00:32 +0000 Subject: 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. --- source/gameengine/Expressions/PyObjectPlus.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'source/gameengine/Expressions/PyObjectPlus.cpp') diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 3148dfc2b89..4526f8f649b 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -115,7 +115,7 @@ 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, Methods, NULL); /* no Attributes yet */ + return py_getattr_dict(NULL, Type.tp_dict); /* no Attributes yet */ } PyErr_SetString(PyExc_AttributeError, "attribute not found"); return NULL; @@ -767,25 +767,14 @@ PyObject *PyObjectPlus::Py_isA(PyObject *value) // Python wrapper for isA * Other then making dir() useful the value returned from __dict__() is not useful * since every value is a Py_None * */ -PyObject *py_getattr_dict(PyObject *pydict, PyMethodDef *meth, PyAttributeDef *attrdef) +PyObject *py_getattr_dict(PyObject *pydict, PyObject *tp_dict) { if(pydict==NULL) { /* incase calling __dict__ on the parent of this object raised an error */ PyErr_Clear(); pydict = PyDict_New(); } - if(meth) { - for (; meth->ml_name != NULL; meth++) { - PyDict_SetItemString(pydict, meth->ml_name, Py_None); - } - } - - if(attrdef) { - for (; attrdef->m_name != NULL; attrdef++) { - PyDict_SetItemString(pydict, attrdef->m_name, Py_None); - } - } - + PyDict_Update(pydict, tp_dict); return pydict; } -- cgit v1.2.3