void rbgobj_initialize_object(VALUE obj, gpointer cobj) { GType type; GType parent_type; if (!cobj) rb_raise(rb_eRuntimeError, "failed to initialize"); type = RVAL2GTYPE(obj); for (parent_type = type; parent_type != G_TYPE_INVALID; parent_type = g_type_parent(parent_type)) { if (rbgobj_convert_initialize(parent_type, obj, cobj)) return; } type = G_TYPE_FUNDAMENTAL(type); switch (type){ case G_TYPE_OBJECT: rbgobj_gobject_initialize(obj, cobj); break; case G_TYPE_PARAM: rbgobj_param_spec_initialize(obj, cobj); break; case G_TYPE_BOXED: rbgobj_boxed_initialize(obj, cobj); break; default: rbgobj_convert_initialize(type, obj, cobj); } }
VALUE rbgobj_get_ruby_object_from_param_spec(GParamSpec* pspec, gboolean alloc) { gpointer data = g_param_spec_get_qdata(pspec, qparamspec); if (data) return (VALUE)data; else if (alloc) { VALUE result = pspec_s_allocate(GTYPE2CLASS(G_PARAM_SPEC_TYPE(pspec))); rbgobj_param_spec_initialize(result, pspec); return result; } else return Qnil; }