Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-02-25 17:32:35 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-25 17:32:35 +0300
commit2cf20fde1b2f3494b8bd12e73fb9ccc17959f536 (patch)
tree875feaaf82672de1dd74034327f4641a26ac6485 /source/gameengine/Expressions/PyObjectPlus.h
parent60b22c5d1281a01f0675988d37fe002c7c2a6a98 (diff)
patch [#26215] Python weak reference (weakref) support for game objects
by Alex Fraser (z0r)
Diffstat (limited to 'source/gameengine/Expressions/PyObjectPlus.h')
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h
index 12ae31f6c82..315a328317d 100644
--- a/source/gameengine/Expressions/PyObjectPlus.h
+++ b/source/gameengine/Expressions/PyObjectPlus.h
@@ -31,6 +31,9 @@
* \ingroup expressions
*/
+/* for now keep weakrefs optional */
+#define USE_WEAKREFS
+
#ifndef _adr_py_lib_h_ // only process once,
#define _adr_py_lib_h_ // even if multiply included
@@ -95,6 +98,9 @@ typedef struct PyObjectPlus_Proxy {
void *ptr; // optional pointer to generic structure, the structure holds no reference to this proxy
bool py_owns; // true if the object pointed by ref should be deleted when the proxy is deleted
bool py_ref; // true if proxy is connected to a GE object (ref is used)
+#ifdef USE_WEAKREFS
+ PyObject *in_weakreflist; // weak reference enabler
+#endif
} PyObjectPlus_Proxy;
#define BGE_PROXY_ERROR_MSG "Blender Game Engine data has been freed, cannot use this python variable"
@@ -102,6 +108,7 @@ typedef struct PyObjectPlus_Proxy {
#define BGE_PROXY_PTR(_self) (((PyObjectPlus_Proxy *)_self)->ptr)
#define BGE_PROXY_PYOWNS(_self) (((PyObjectPlus_Proxy *)_self)->py_owns)
#define BGE_PROXY_PYREF(_self) (((PyObjectPlus_Proxy *)_self)->py_ref)
+#define BGE_PROXY_WKREF(_self) (((PyObjectPlus_Proxy *)_self)->in_weakreflist)
/* Note, sometimes we dont care what BGE type this is as long as its a proxy */
#define BGE_PROXY_CHECK_TYPE(_type) ((_type)->tp_dealloc == PyObjectPlus::py_base_dealloc)