46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'ext/callback/callback.c', line 46
static VALUE rb_callback_initialize( int argc, VALUE *argv, VALUE cb )
{
VALUE object;
VALUE method;
ID meth;
RCallback* cbs = GetCallbackStruct(cb);
if (rb_block_given_p()) {
if (argc == 1) rb_raise(rb_eArgError, "wrong number of arguments");
cbs->object = rb_block_proc();
cbs->method = id_call;
}else {
rb_scan_args(argc, argv, "02", &object, &method);
cbs->object = object;
meth = rb_to_id(method);
if (!rb_respond_to(object,meth)) rb_raise(rb_eArgError, "object does not respond to %s", RSTRING_PTR(rb_obj_as_string(method)));
cbs->method = meth;
}
OBJ_FREEZE(cb);
return cb;
}
|