18 #include "refpointer.h"
20 #include <glib-object.h>
26 Quark q = g_quark_from_static_string(
"QGlib__wrapper_constructor");
29 for(
Type t = instanceType; t.isValid(); t = t.parent()) {
30 void *funcPtr = t.quarkData(q);
32 cppClass = (
reinterpret_cast<RefCountedObject *(*)(
void*)
>(funcPtr))(instance);
33 Q_ASSERT_X(cppClass,
"QGlib::constructWrapper",
34 "Failed to wrap instance. This is a bug in the bindings library.");
39 Q_ASSERT_X(
false,
"QGlib::constructWrapper",
40 "No wrapper constructor found for this type. Did you forget to call init()?.");
46 static void qdataDestroyNotify(
void *cppInstance)
48 delete static_cast<RefCountedObject*
>(cppInstance);
51 RefCountedObject *wrapObject(
void *gobject)
55 Quark q = g_quark_from_static_string(
"QGlib__object_wrapper");
56 RefCountedObject *obj =
static_cast<RefCountedObject*
>(g_object_get_qdata(G_OBJECT(gobject), q));
60 g_object_set_qdata_full(G_OBJECT(gobject), q, obj, &qdataDestroyNotify);
66 RefCountedObject *wrapParamSpec(
void *param)
70 Quark q = g_quark_from_static_string(
"QGlib__paramspec_wrapper");
71 RefCountedObject *obj =
static_cast<RefCountedObject*
>(g_param_spec_get_qdata(G_PARAM_SPEC(param), q));
75 g_param_spec_set_qdata_full(G_PARAM_SPEC(param), q, obj, &qdataDestroyNotify);
81 RefCountedObject *wrapInterface(Type interfaceType,
void *gobject)
85 Quark q =
Quark::fromString(QLatin1String(
"QGlib__interface_wrapper__") + interfaceType.name());
86 RefCountedObject *obj =
static_cast<RefCountedObject*
>(g_object_get_qdata(G_OBJECT(gobject), q));
90 g_object_set_qdata_full(G_OBJECT(gobject), q, obj, &qdataDestroyNotify);