static int MethodArity(VALUE method) { static VALUE aritySymbol = rb_intern("arity"); if (!rb_obj_respond_to(method, aritySymbol, 0)) return 0; return NUM2INT(rb_apply(method, aritySymbol, rb_ary_new())); }
static VALUE exec_callback(VALUE arg) { VALUE *parg = (VALUE *)arg; VALUE handler = parg[0]; VALUE mid = parg[1]; VALUE args = parg[2]; return rb_apply(handler, mid, args); }
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 VALUE rb_gtk3_spin_button_input_body(VALUE user_data) { InputData *input_data = (InputData *)user_data; VALUE new_value; new_value = rb_apply(input_data->data->callback, rb_intern("call"), input_data->args); if (NIL_P(new_value)) { g_value_set_int(input_data->data->return_value, FALSE); } else { g_value_set_int(input_data->data->return_value, TRUE); *(input_data->new_value) = NUM2DBL(new_value); } return Qnil; }
static VALUE na_aref_md(int argc, VALUE *argv, VALUE self, int keep_dim, int result_nd) { VALUE args; // should be GC protected narray_t *na1; na_aref_md_data_t data; VALUE store = 0; VALUE idx; narray_t *nidx; GetNArray(self,na1); args = rb_ary_new4(argc,argv); if (argc == 1 && result_nd == 1) { idx = argv[0]; if (rb_obj_is_kind_of(idx, rb_cArray)) { idx = rb_apply(numo_cNArray,id_bracket,idx); } if (rb_obj_is_kind_of(idx, numo_cNArray)) { GetNArray(idx,nidx); if (NA_NDIM(nidx)>1) { store = nary_new(CLASS_OF(self),NA_NDIM(nidx),NA_SHAPE(nidx)); idx = na_flatten(idx); RARRAY_ASET(args,0,idx); } } // flatten should be done only for narray-view with non-uniform stride. if (na1->ndim > 1) { self = na_flatten(self); GetNArray(self,na1); } } data.args = args; data.self = self; data.store = store; data.ndim = result_nd; data.q = na_allocate_index_args(result_nd); data.na1 = na1; data.keep_dim = keep_dim; return rb_ensure(na_aref_md_protected, (VALUE)&data, na_aref_md_ensure, (VALUE)&data); }
static VALUE cDO_OracleCommand_execute_try(cDO_OracleCommand_execute_try_t *arg) { VALUE result = Qnil; int insert_id_present; // no arguments given if(NIL_P(arg->args)) { result = rb_funcall(arg->cursor, DO_ID_EXEC, 0); // arguments given - need to typecast } else { insert_id_present = (!NIL_P(arg->self) && rb_iv_get(arg->self, "@insert_id_present") == Qtrue); if (insert_id_present) rb_funcall(arg->cursor, DO_ID_BIND_PARAM, 2, RUBY_STRING(":insert_id"), INT2NUM(0)); int i; VALUE r_orig_value, r_new_value; for (i = 0; i < RARRAY_LEN(arg->args); i++) { r_orig_value = rb_ary_entry(arg->args, i); r_new_value = typecast_bind_value(arg->connection, r_orig_value); if (r_orig_value != r_new_value) rb_ary_store(arg->args, i, r_new_value); } result = rb_apply(arg->cursor, DO_ID_EXEC, arg->args); if (insert_id_present) { VALUE insert_id = rb_funcall(arg->cursor, DO_ID_ELEM, 1, RUBY_STRING(":insert_id")); rb_iv_set(arg->self, "@insert_id", insert_id); } } if (SYM2ID(arg->statement_type) == DO_ID_SELECT_STMT) return arg->cursor; else { return result; } }
static VALUE rb_czmq_timer_fire(VALUE obj, VALUE args) { ZmqGetTimer(obj); if (timer->cancelled == TRUE) rb_raise(rb_eZmqError, "cannot fire timer, already cancelled!"); return rb_apply(timer->callback, intern_call, args); }
VALUE kobj_do_method_missing_call(VALUE args) { VALUE object = rb_ary_shift(args); return rb_apply(object, rb_intern("method_missing"), args); }
static VALUE call_ruby_from_js_invoke(VALUE args) { VALUE self = rb_ary_pop(args); VALUE id = rb_ary_pop(args); return rb_apply(self, SYM2ID(id), args); }
/* rf_protected and rf_call * * Used for: protection. * * This is called by rb_protect, and will make a call using * the above rb_path and to_call ID to call the method safely * on FuseRoot. * * We call rf_call(path,method_id), and rf_call will use rb_protect * to call rf_protected, which makes the call on FuseRoot and returns * whatever the call returns. */ static VALUE rf_protected(VALUE args) { ID to_call = SYM2ID(rb_ary_shift(args)); return rb_apply(FuseRoot,to_call,args); }
static VALUE DoMethodCall(VALUE args) { VALUE method = rb_ary_shift(args); VALUE rargs = rb_ary_shift(args); return rb_apply(method, rb_intern("call"), rargs); }
static VALUE rf_int_protected(VALUE args) { static VALUE empty_ary = Qnil; if (empty_ary == Qnil) empty_ary = rb_ary_new(); return rb_apply(args,id_to_i,empty_ary); }