diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-11-20 06:21:22 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-11-20 18:33:41 +0900 |
| commit | 8f2c62407c0659d84126545e19505a851059e750 (patch) | |
| tree | 7a073d389fc2f5fc7c14f86ffa96d0145bff9f82 /mrbgems/mruby-proc-ext | |
| parent | 6c06e77446f3cca4a92b3df8d0a5fe568c5fdc65 (diff) | |
| download | mruby-8f2c62407c0659d84126545e19505a851059e750.tar.gz mruby-8f2c62407c0659d84126545e19505a851059e750.zip | |
Add `MRB_METHOD_TABLE_INLINE` option.
Now the method tables (in classes/modules and caches) keeps C function
pointers without wrapping in `struct RProc` objects. For the sake of
portability, `mrb_method_t` is represented by the struct and union, but
if the most significant bit of the pointer is not used by the platform,
`mrb_method_t` should be packed in `uintptr_t` to reduce memory usage.
`MRB_METHOD_TABLE_INLINE` is turned on by default for linux.
Diffstat (limited to 'mrbgems/mruby-proc-ext')
| -rw-r--r-- | mrbgems/mruby-proc-ext/test/proc.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/mrbgems/mruby-proc-ext/test/proc.c b/mrbgems/mruby-proc-ext/test/proc.c index a77b68e9d..7072fe2e9 100644 --- a/mrbgems/mruby-proc-ext/test/proc.c +++ b/mrbgems/mruby-proc-ext/test/proc.c @@ -13,10 +13,13 @@ proc_new_cfunc_with_env(mrb_state *mrb, mrb_value self) { mrb_sym n; mrb_value n_val; + mrb_method_t m; + struct RProc *p; mrb_get_args(mrb, "n", &n); n_val = mrb_symbol_value(n); - mrb_define_method_raw(mrb, mrb_class_ptr(self), n, - mrb_proc_new_cfunc_with_env(mrb, return_func_name, 1, &n_val)); + p = mrb_proc_new_cfunc_with_env(mrb, return_func_name, 1, &n_val); + MRB_METHOD_FROM_PROC(m, p); + mrb_define_method_raw(mrb, mrb_class_ptr(self), n, m); return self; } @@ -33,9 +36,12 @@ cfunc_env_get(mrb_state *mrb, mrb_value self) { mrb_sym n; mrb_value *argv; mrb_int argc; + mrb_method_t m; + struct RProc *p; mrb_get_args(mrb, "na", &n, &argv, &argc); - mrb_define_method_raw(mrb, mrb_class_ptr(self), n, - mrb_proc_new_cfunc_with_env(mrb, return_env, argc, argv)); + p = mrb_proc_new_cfunc_with_env(mrb, return_env, argc, argv); + MRB_METHOD_FROM_PROC(m, p); + mrb_define_method_raw(mrb, mrb_class_ptr(self), n, m); return self; } |
