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 QString(QLatin1String(
"No wrapper constructor found for this type (") +
41 instanceType.name() + QLatin1String(
"). Did you forget to call init()?.")).toUtf8());
47static void qdataDestroyNotify(
void *cppInstance)
49 delete static_cast<RefCountedObject*
>(cppInstance);
52RefCountedObject *wrapObject(
void *gobject)
56 Quark q = g_quark_from_static_string(
"QGlib__object_wrapper");
57 RefCountedObject *obj =
static_cast<RefCountedObject*
>(g_object_get_qdata(G_OBJECT(gobject), q));
61 g_object_set_qdata_full(G_OBJECT(gobject), q, obj, &qdataDestroyNotify);
67RefCountedObject *wrapParamSpec(
void *param)
71 Quark q = g_quark_from_static_string(
"QGlib__paramspec_wrapper");
72 RefCountedObject *obj =
static_cast<RefCountedObject*
>(g_param_spec_get_qdata(G_PARAM_SPEC(param), q));
76 g_param_spec_set_qdata_full(G_PARAM_SPEC(param), q, obj, &qdataDestroyNotify);
82RefCountedObject *wrapInterface(Type interfaceType,
void *gobject)
86 Quark q =
Quark::fromString(QLatin1String(
"QGlib__interface_wrapper__") + interfaceType.name());
87 RefCountedObject *obj =
static_cast<RefCountedObject*
>(g_object_get_qdata(G_OBJECT(gobject), q));
91 g_object_set_qdata_full(G_OBJECT(gobject), q, obj, &qdataDestroyNotify);
Wrapper class for GQuark.
static Quark fromString(const char *str)
Base class for all the reference-counted object wrappers.
Wrappers for Glib and GObject classes.
RefCountedObject * constructWrapper(Type instanceType, void *instance)