Created
August 22, 2009 18:14
-
-
Save methodmissing/172903 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment