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); } }
void rbgst_object_initialize(VALUE obj, gpointer cobj) { if (GST_OBJECT_IS_FLOATING(cobj)) { gst_object_ref(cobj); gst_object_sink(cobj); } rbgobj_gobject_initialize(obj, cobj); }
VALUE rbgobj_get_ruby_object_from_gobject(GObject* gobj, gboolean alloc) { gobj_holder *holder; holder = g_object_get_qdata(gobj, RUBY_GOBJECT_OBJ_KEY); if (holder) { return holder->self; } else if (alloc) { VALUE obj; obj = gobj_s_allocate(GTYPE2CLASS(G_OBJECT_TYPE(gobj))); gobj = g_object_ref(gobj); rbgobj_gobject_initialize(obj, (gpointer)gobj); return obj; } else { return Qnil; } }