diff options
| author | Tomasz Dąbrowski <[email protected]> | 2016-11-16 17:43:55 +0100 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-11-17 17:19:49 +0900 |
| commit | 4cca8bac6bbdab02eba11e6527f793f2e9a5e75d (patch) | |
| tree | 6b08ca177e1ebeaa0be3d87a993b27fbe58f795e /src/class.c | |
| parent | 784e07f902790dd13d33460d7365a2f0aee85727 (diff) | |
| download | mruby-4cca8bac6bbdab02eba11e6527f793f2e9a5e75d.tar.gz mruby-4cca8bac6bbdab02eba11e6527f793f2e9a5e75d.zip | |
inline structures data type for mruby (MRB_TT_INLINE) (fix #3237)
Inline structures have no instance variables, no finalizer, and offer as much space as possible in RBASIC object. This means 24 bytes on 64-bit platforms and 12 bytes on 32-bit platforms.
mruby-inline-struct gem is only provided for testing.
Diffstat (limited to 'src/class.c')
| -rw-r--r-- | src/class.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/class.c b/src/class.c index 4fc81689b..53354d02a 100644 --- a/src/class.c +++ b/src/class.c @@ -14,6 +14,7 @@ #include <mruby/variable.h> #include <mruby/error.h> #include <mruby/data.h> +#include <mruby/inline.h> KHASH_DEFINE(mt, mrb_sym, struct RProc*, TRUE, kh_int_hash_func, kh_int_hash_equal) @@ -491,6 +492,7 @@ to_sym(mrb_state *mrb, mrb_value ss) b: Boolean [mrb_bool] n: Symbol [mrb_sym] d: Data [void*,mrb_data_type const] 2nd argument will be used to check data type so it won't be modified + I: Inline struct [void*] &: Block [mrb_value] *: rest argument [mrb_value*,mrb_int] Receive the rest of the arguments as an array. |: optional Next argument of '|' and later are optional. @@ -702,6 +704,24 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) } } break; + case 'I': + { + void* *p; + mrb_value ss; + + p = va_arg(ap, void**); + if (i < argc) { + ss = ARGV[arg_i]; + if (mrb_type(ss) != MRB_TT_INLINE) + { + mrb_raisef(mrb, E_TYPE_ERROR, "%S is not inline struct", ss); + } + *p = mrb_inline_ptr(ss); + arg_i++; + i++; + } + } + break; case 'f': { mrb_float *p; |
