/** * \param self A PyObjectPlus_Proxy */ void PyObjectPlus::py_base_dealloc(PyObject *self) // python wrapper { #ifdef USE_WEAKREFS if (BGE_PROXY_WKREF(self) != NULL) PyObject_ClearWeakRefs((PyObject *) self); #endif if (BGE_PROXY_PYREF(self)) { PyObjectPlus *self_plus= BGE_PROXY_REF(self); if (self_plus) { if (BGE_PROXY_PYOWNS(self)) { /* Does python own this?, then delete it */ self_plus->m_proxy = NULL; /* Need this to stop ~PyObjectPlus from decrefing m_proxy otherwise its decref'd twice and py-debug crashes */ delete self_plus; } BGE_PROXY_REF(self)= NULL; // not really needed } // the generic pointer is not deleted directly, only through self_plus BGE_PROXY_PTR(self)= NULL; // not really needed } else { void *ptr= BGE_PROXY_PTR(self); if (ptr) { if (BGE_PROXY_PYOWNS(self)) { /* Does python own this?, then delete it */ // generic structure owned by python MUST be created though MEM_alloc MEM_freeN(ptr); } BGE_PROXY_PTR(self)= NULL; // not really needed } } #if 0 /* is ok normally but not for subtyping, use tp_free instead. */ PyObject_DEL( self ); #else Py_TYPE(self)->tp_free(self); #endif };
PyObject *PyObjectPlus::GetProxyPlus_Ext(PyObjectPlus *self, PyTypeObject *tp, void *ptr) { if (self->m_proxy==NULL) { self->m_proxy = reinterpret_cast<PyObject *>PyObject_NEW( PyObjectPlus_Proxy, tp); BGE_PROXY_PYOWNS(self->m_proxy) = false; BGE_PROXY_PYREF(self->m_proxy) = true; }
PyObject *CListValue::Pyappend(PyObject *value) { CValue* objval = ConvertPythonToValue(value, "CList.append(i): CValueList, "); if (!objval) /* ConvertPythonToValue sets the error */ return NULL; if (!BGE_PROXY_PYOWNS(m_proxy)) { PyErr_SetString(PyExc_TypeError, "CList.append(i): this CValueList is used internally for the game engine and can't be modified"); return NULL; } Add(objval); Py_RETURN_NONE; }