gpointer rbgobj_instance_from_ruby_object(VALUE obj) { GType type; if (NIL_P(obj)) return NULL; type = RVAL2GTYPE(obj); if (rbgobj_convert_has_type(type)) { gpointer instance; if (rbgobj_convert_robj2instance(type, obj, &instance)) return instance; } type = G_TYPE_FUNDAMENTAL(type); switch (type){ case G_TYPE_OBJECT: return rbgobj_get_gobject(obj); case G_TYPE_PARAM: return rbgobj_get_param_spec(obj); default: { gpointer instance; if (!rbgobj_convert_robj2instance(type, obj, &instance)) { rb_raise(rb_eTypeError, "%s isn't supported", rb_class2name(CLASS_OF(obj))); } return instance; } } }
gpointer rbgobj_boxed_get(VALUE obj, GType gtype) { gpointer boxed = NULL; if (NIL_P(obj)) return NULL; if (rbgobj_convert_robj2instance(gtype, obj, &boxed)) { return boxed; } return rbgobj_boxed_get_default(obj, gtype); }