aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2010-02-03 14:07:27 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-02-03 17:58:01 -0200
commit2f0d1d28afaeb39130c1619e7a51907a5b182f69 (patch)
tree45a7415b963963e7c3e9a2e69ca760e9212c524f /libshiboken
parente557d7f4990e17c92174ca434e90ef03c059825e (diff)
Adding support for weakreference
Reviewer: Renato Filho <renato.filho@openbossa.org>
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/basewrapper.cpp8
-rw-r--r--libshiboken/basewrapper.h2
2 files changed, 9 insertions, 1 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index 512722b84..2eaff65cb 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -132,6 +132,7 @@ PyObject* SbkBaseWrapper_New(SbkBaseWrapperType* instanceType,
self->validCppObject = 1;
self->parentInfo = 0;
self->ob_dict = 0;
+ self->weakreflist = 0;
BindingManager::instance().registerWrapper(self);
return reinterpret_cast<PyObject*>(self);
}
@@ -146,6 +147,7 @@ PyObject* SbkBaseWrapper_TpNew(PyTypeObject* subtype, PyObject*, PyObject*)
self->validCppObject = 0;
self->parentInfo = 0;
self->ob_dict = 0;
+ self->weakreflist = 0;
return reinterpret_cast<PyObject*>(self);
}
@@ -159,6 +161,10 @@ bool cppObjectIsInvalid(PyObject* wrapper)
void SbkBaseWrapper_Dealloc_PrivateDtor(PyObject* self)
{
+
+ if (((SbkBaseWrapper *)self)->weakreflist)
+ PyObject_ClearWeakRefs(self);
+
BindingManager::instance().releaseWrapper(self);
Py_TYPE(reinterpret_cast<SbkBaseWrapper*>(self))->tp_free(self);
}
@@ -265,7 +271,7 @@ SbkBaseWrapperType SbkBaseWrapper_Type = { { {
/*tp_traverse*/ 0,
/*tp_clear*/ 0,
/*tp_richcompare*/ 0,
- /*tp_weaklistoffset*/ 0,
+ /*tp_weaklistoffset*/ offsetof(SbkBaseWrapper, weakreflist),
/*tp_iter*/ 0,
/*tp_iternext*/ 0,
/*tp_methods*/ 0,
diff --git a/libshiboken/basewrapper.h b/libshiboken/basewrapper.h
index 32a978f51..381562e39 100644
--- a/libshiboken/basewrapper.h
+++ b/libshiboken/basewrapper.h
@@ -101,6 +101,8 @@ struct LIBSHIBOKEN_API SbkBaseWrapper
unsigned int validCppObject : 1;
/// Information about the object parents and children, can be null.
ShiboParentInfo* parentInfo;
+ /// List of weak references
+ PyObject *weakreflist;
};
LIBSHIBOKEN_API PyAPI_FUNC(void) init_shiboken();