Skip to content

Instantly share code, notes, and snippets.

@wanabe
Created August 26, 2012 01:08
Show Gist options
  • Select an option

  • Save wanabe/3472908 to your computer and use it in GitHub Desktop.

Select an option

Save wanabe/3472908 to your computer and use it in GitHub Desktop.
sym = mrb_sym_value(mrb, args[i]);
name = mrb_sym2name(mrb, sym);
len = snprintf(dummy, 1, "Proc.new { @%s }", name) + 1;
scr = malloc(len);
snprintf(scr, len, "Proc.new { @%s }", name);
proc = mrb_load_string(mrb, scr);
free(scr);
mrb_define_method_vm(mrb, mrb_class_ptr(mod), sym, proc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment