mruby/mruby — pull request #609 by mrbrdo (2012-12-10 06:17:42+00:00)
Title: add mrb_proc2closure

Would be nice to have a way to make a cfunc proc or existing irep proc into a closure. Right now it's not possible since mrb_closure_new can only take an irep. I suggest something like this, feel free to change details.

I provide nlocals as an argument so it can be used for cfunc also, since normally nlocals is read from irep, which is not there for cfunc.
Perhaps it would be better to define an extra internal *inline* function that does this, and call it from both mrb_proc2closure and mrb_capture_new (just for performance reasons).

Think about it :)