Files
mruby-mruby/mrbgems/mruby-proc-binding/test/proc-binding.c
T
dearblue 927615e1f0 Added other methods for Binding
- Added to `mruby-binding-core`
  - `Binding#local_variable_defined?`
  - `Binding#local_variable_get`
  - `Binding#local_variable_set`
  - `Binding#local_variables`
  - `Binding#receiver`
  - `Binding#source_location`
  - `Binding#inspect`
- Added to `mruby-proc-binding`
  - `Proc#binding`

The reason for separating `Proc#binding` is that core-mrbgems has a method that returns a closure object to minimize possible problems with being able to manipulate internal variables.
By separating it as different mrbgem, each user can judge this problem and incorporate it arbitrarily.
2021-02-22 23:32:43 +09:00

15 lines
310 B
C

#include <mruby.h>
#include <mruby/compile.h>
static mrb_value
proc_in_c(mrb_state *mrb, mrb_value self)
{
return mrb_load_string(mrb, "proc { |a, b| a + b }");
}
void
mrb_mruby_proc_binding_gem_test(mrb_state *mrb)
{
mrb_define_method(mrb, mrb->object_class, "proc_in_c", proc_in_c, MRB_ARGS_NONE());
}