Exemple #1
0
static VALUE application_initialize(VALUE self, VALUE args) {
    if (rb_thread_main() != rb_thread_current()) {
        rb_raise(rb_eThreadError, "Initializing QML::Application outside the main thread");
    }

    application_t *data;
    TypedData_Get_Struct(self, application_t, &data_type, data);

    if (rb_type(args) != T_ARRAY) {
        rb_raise(rb_eTypeError, "Expected Array");
    }

    args = rb_ary_concat(rb_ary_new_from_args(1, rb_argv0), args);

    int argc = RARRAY_LEN(args);
    char **argv = malloc(argc * sizeof(char *));

    for (int i = 0; i < argc; ++i) {
        VALUE arg = RARRAY_AREF(args, i);
        argv[i] = rb_string_value_cstr(&arg);
    }

    data->application = qmlbind_application_new(argc, argv);

    return self;
}
Exemple #2
0
PRIMITIVE VALUE
vm_ary_cat(VALUE ary, VALUE obj)
{
    VALUE ary2 = rb_check_convert_type(obj, T_ARRAY, "Array", "to_a");
    if (!NIL_P(ary2)) {
	rb_ary_concat(ary, ary2);
    }
    else {
	rb_ary_push(ary, obj);
    }
    return ary;
}
Exemple #3
0
static void
rb_mod_included_modules_nosuper(VALUE mod, VALUE ary)
{
    VALUE inc_mods = rb_attr_get(mod, idIncludedModules);
    if (inc_mods != Qnil) {
	int i, count = RARRAY_LEN(inc_mods);
	for (i = 0; i < count; i++) {
	    VALUE imod = RARRAY_AT(inc_mods, i);
	    rb_ary_push(ary, imod);
	    rb_ary_concat(ary, rb_mod_included_modules(imod));
	}
    }
}
Exemple #4
0
static VALUE
rclosure_marshal_do(VALUE arg_)
{
    struct marshal_arg *arg;
    GRClosure*      rclosure;
    GValue*         return_value;
    guint           n_param_values;
    const GValue*   param_values;
    /* gpointer        invocation_hint;*/
    /* gpointer        marshal_data; */

    VALUE ret = Qnil;
    VALUE args;
    GValToRValSignalFunc func;

    arg = (struct marshal_arg*)arg_;
    rclosure        = (GRClosure *)(arg->closure);
    return_value    = arg->return_value;   
    n_param_values  = arg->n_param_values; 
    param_values    = arg->param_values;
    /* invocation_hint = arg->invocation_hint; */
    /* marshal_data    = arg->marshal_data; */

    if (rclosure->g2r_func){
        func = (GValToRValSignalFunc)rclosure->g2r_func;
    } else { 
        func = (GValToRValSignalFunc)rclosure_default_g2r_func;
    }
    args = (*func)(n_param_values, param_values);

    if (rclosure_alive_p(rclosure)) {
        VALUE callback, extra_args;
        callback = rclosure->callback;
        extra_args = rclosure->extra_args;

        if (!NIL_P(extra_args)) {
            args = rb_ary_concat(args, extra_args);
        }

        ret = rb_apply(callback, id_call, args);
    } else {
        rb_warn("GRClosure invoking callback: already destroyed: %s",
                rclosure->tag[0] ? rclosure->tag : "(anonymous)");
    }

    if (return_value && G_VALUE_TYPE(return_value))
        rbgobj_rvalue_to_gvalue(ret, return_value);

    return Qnil;
}
static void
rb_gtk3_spin_button_input(RGClosureCallData *data)
{
    InputData input_data;
    VALUE args;

    args = rb_ary_new_from_args(1, GVAL2RVAL(&(data->param_values[0])));
    if (!NIL_P(data->extra_args)) {
        rb_ary_concat(args, data->extra_args);
    }
    input_data.data = data;
    input_data.args = args;
    input_data.new_value = g_value_get_pointer(&(data->param_values[1]));
    rb_rescue(rb_gtk3_spin_button_input_body, (VALUE)&input_data,
              rb_gtk3_spin_button_input_rescue, (VALUE)&input_data);
}
Exemple #6
0
static VALUE array_spec_rb_ary_concat(VALUE self, VALUE array1, VALUE array2) {
  return rb_ary_concat(array1, array2);
}
Exemple #7
0
VALUE array_concat(VALUE head, VALUE tail) {
	return rb_ary_concat(head, tail);
}