From 5b306b7541bfc60342b70bcc55456d5c453a294a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 12 Apr 2009 09:56:30 +0000 Subject: BGE Python API added defines PY_SET_ATTR_FAIL, PY_SET_ATTR_MISSING and PY_SET_ATTR_SUCCESS This is useful when objects that have user defined attributes (GameObject and Scene) When calling setattr on the parent, a return value of PY_SET_ATTR_FAIL means the attribute exists but failed to be set, so don't set the custom attribute. --- source/gameengine/Expressions/PyObjectPlus.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/gameengine/Expressions/PyObjectPlus.cpp') diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 4526f8f649b..33335ebef3e 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -137,7 +137,7 @@ int PyObjectPlus::py_setattro(PyObject *attr, PyObject* value) //return PyObject::py_setattro(attr,value); //cerr << "Unknown attribute" << endl; PyErr_SetString(PyExc_AttributeError, "attribute cant be set"); - return 1; + return PY_SET_ATTR_MISSING; } PyObject *PyObjectPlus::py_get_attrdef(void *self, const PyAttributeDef *attrdef) @@ -699,13 +699,13 @@ int PyObjectPlus::py_setattro_self(const PyAttributeDef attrlist[], void *self, attrdef->m_type == KX_PYATTRIBUTE_TYPE_DUMMY) { PyErr_SetString(PyExc_AttributeError, "property is read-only"); - return 1; + return PY_SET_ATTR_FAIL; } return py_set_attrdef(self, attrdef, value); } } - return -1; + return PY_SET_ATTR_MISSING; } #endif -- cgit v1.2.3