diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-18 00:06:06 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-18 00:06:06 +0400 |
commit | df8cf26404c7e922751643b1095e38f1ab430811 (patch) | |
tree | b4258cc6c90913c379f5cdd05edebd8785230647 /source/gameengine/Expressions/PyObjectPlus.cpp | |
parent | 90c6cf77f10961de756f6ff06329d3fa65ce3da4 (diff) |
Added m_zombie to the base python class (PyObjectPlus), when this is set all the subclasses will raise an error on access to their members.
Other small changes...
- KX_Camera and KX_Light didnt have get/setitem access in their PyType definition.
- CList.from_id() error checking for a long was checking for -1 against an unsigned value (own fault)
- CValue::SpecialRelease was incrementing an int for no reason.
- renamed m_attrlist to m_attr_dict since its a PyDict type.
- removed custom getattro/setattro functions for KX_Scene and KX_GameObject, use py_base_getattro, py_base_setattro for all subclasses of PyObjectPlus.
- lowercase windows.h in VideoBase.cpp for cross compiling.
Diffstat (limited to 'source/gameengine/Expressions/PyObjectPlus.cpp')
-rw-r--r-- | source/gameengine/Expressions/PyObjectPlus.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 33335ebef3e..0db2e8991fc 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -88,6 +88,7 @@ PyObjectPlus::PyObjectPlus(PyTypeObject *T) // constructor MT_assert(T != NULL); this->ob_type = T; _Py_NewReference(this); + SetZombie(false); }; /*------------------------------ @@ -99,9 +100,15 @@ PyMethodDef PyObjectPlus::Methods[] = { }; PyAttributeDef PyObjectPlus::Attributes[] = { + KX_PYATTRIBUTE_RO_FUNCTION("isValid", PyObjectPlus, pyattr_get_is_valid), {NULL} //Sentinel }; +PyObject* PyObjectPlus::pyattr_get_is_valid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + Py_RETURN_TRUE; +} + /*------------------------------ * PyObjectPlus Parents -- Every class, even the abstract one should have parents ------------------------------*/ @@ -117,10 +124,19 @@ PyObject *PyObjectPlus::py_getattro(PyObject* attr) if (strcmp(PyString_AsString(attr), "__dict__")==0) { return py_getattr_dict(NULL, Type.tp_dict); /* no Attributes yet */ } - PyErr_SetString(PyExc_AttributeError, "attribute not found"); + PyErr_Format(PyExc_AttributeError, "attribute \"%s\" not found", PyString_AsString(attr)); return NULL; } else { - return PyCFunction_New(((PyMethodDescrObject *)descr)->d_method, (PyObject *)this); \ + /* Copied from py_getattro_up */ + if (PyCObject_Check(descr)) { + return py_get_attrdef((void *)this, (const PyAttributeDef*)PyCObject_AsVoidPtr(descr)); + } else if (descr->ob_type->tp_descr_get) { + return PyCFunction_New(((PyMethodDescrObject *)descr)->d_method, (PyObject *)this); + } else { + fprintf(stderr, "Unknown attribute type (PyObjectPlus::py_getattro)"); + return descr; + } + /* end py_getattro_up copy */ } //if (streq(attr, "type")) // return Py_BuildValue("s", (*(GetParents()))->tp_name); |