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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user