aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken/basewrapper.cpp
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-12-03 16:53:26 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:12:08 -0300
commit5c119a7d68a3c6197a6890192b99b0967fa8eed1 (patch)
tree4fd961bb045e55d2d3bf77bd91ef6e0e84d4ffe5 /libshiboken/basewrapper.cpp
parentf8ad4eba987f53c05c42c2af6ec76bd59e196b75 (diff)
Add subtype init hook.
The hook is invoked every time the user creates a sub-type inherited from a Shiboken based type.
Diffstat (limited to 'libshiboken/basewrapper.cpp')
-rw-r--r--libshiboken/basewrapper.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index 0d9439849..6c7d222ed 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -239,6 +239,13 @@ PyObject* SbkObjectTypeTpNew(PyTypeObject* metatype, PyObject* args, PyObject* k
d->d_func = 0;
d->is_user_type = 1;
newType->d = d;
+
+ std::list<SbkObjectType*>::const_iterator it = bases.begin();
+ for (; it != bases.end(); ++it) {
+ if ((*it)->d->subtype_init)
+ (*it)->d->subtype_init(newType, args, kwds);
+ }
+
return reinterpret_cast<PyObject*>(newType);
}
@@ -549,9 +556,20 @@ void initPrivateData(SbkObjectType* self)
memset(self->d, 0, sizeof(SbkObjectTypePrivate));
}
-void* getTypeUserData(SbkObjectType* type)
+void setSubTypeInitHook(SbkObjectType* self, SubTypeInitHook func)
+{
+ self->d->subtype_init = func;
+}
+
+void* getTypeUserData(SbkObjectType* self)
+{
+ return self->d->user_data;
+}
+
+void setTypeUserData(SbkObjectType* self, void* userData, DeleteUserDataFunc d_func)
{
- return type->d->user_data;
+ self->d->user_data = userData;
+ self->d->d_func = d_func;
}
} // namespace ObjectType