Пример #1
0
gpointer
rbgobj_instance_from_ruby_object(VALUE obj)
{
    GType type;
    GType fundamental_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;
    }

    fundamental_type = G_TYPE_FUNDAMENTAL(type);
    switch (fundamental_type) {
    case G_TYPE_OBJECT:
        return rbgobj_get_gobject(obj);
    case G_TYPE_BOXED:
        return rbgobj_boxed_get(obj, type);
    case G_TYPE_PARAM:
        return rbgobj_get_param_spec(obj);
    default:
      {
        gpointer instance;
        if (!rbgobj_convert_robj2instance(fundamental_type, obj, &instance)) {
            rb_raise(rb_eTypeError, "%s isn't supported",
                     rb_class2name(CLASS_OF(obj)));
        }
        return instance;
      }
    }
}
Пример #2
0
static void
boxed_from_ruby(VALUE from, GValue *to)
{
    gpointer boxed;
    boxed = rbgobj_boxed_get(from, G_VALUE_TYPE(to));
    g_value_set_boxed(to, boxed);
}