diff options
| -rw-r--r-- | CONTRIBUTING.md | 3 | ||||
| -rw-r--r-- | doc/guides/symbol.md | 14 | ||||
| -rw-r--r-- | doc/mruby3.md | 11 | ||||
| -rw-r--r-- | include/mruby.h | 44 | ||||
| -rw-r--r-- | include/mruby/presym/enable.h | 4 | ||||
| -rw-r--r-- | mrbgems/mruby-bin-config/mrbgem.rake | 3 |
6 files changed, 42 insertions, 37 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fa1c847a9..2ffd759b1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,7 @@ # How to contribute mruby is an open-source project which is looking forward to each contribution. +Contributors agree to license their contribution(s) under MIT license. ## Your Pull Request @@ -47,11 +48,13 @@ on-demand. #### Insert a break after the function return value: + ```C int main(void) { ... } + ``` ### Ruby code diff --git a/doc/guides/symbol.md b/doc/guides/symbol.md index 3613cf1ad..6943b2e26 100644 --- a/doc/guides/symbol.md +++ b/doc/guides/symbol.md @@ -57,13 +57,13 @@ To save RAM, `mruby` can use compile-time allocation of some symbols. You can use following macros to get preallocated symbols by including `mruby/presym.h` header. - * `MRB_SYM(xor)` //=> xor (Word characters) - * `MRB_SYM_B(xor)` //=> xor! (Method with Bang) - * `MRB_SYM_Q(xor)` //=> xor? (Method with Question mark) - * `MRB_SYM_E(xor)` //=> xor= (Method with Equal) - * `MRB_CVSYM(xor)` //=> @@xor (Class Variable) - * `MRB_IVSYM(xor)` //=> @xor (Instance Variable) - * `MRB_OPSYM(xor)` //=> ^ (Operator) + * `MRB_SYM(xor)` //=> xor (Word characters) + * `MRB_SYM_B(xor)` //=> xor! (Method with Bang) + * `MRB_SYM_Q(xor)` //=> xor? (Method with Question mark) + * `MRB_SYM_E(xor)` //=> xor= (Method with Equal) + * `MRB_CVSYM(xor)` //=> @@xor (Class Variable) + * `MRB_IVSYM(xor)` //=> @xor (Instance Variable) + * `MRB_OPSYM(xor)` //=> ^ (Operator) For `MRB_OPSYM()`, specify the names corresponding to operators (see `MRuby::Presym::OPERATORS` in `lib/mruby/presym.rb` for the names that diff --git a/doc/mruby3.md b/doc/mruby3.md index 75839705c..26d95e3e4 100644 --- a/doc/mruby3.md +++ b/doc/mruby3.md @@ -8,6 +8,7 @@ User visible changes in `mruby3` Typical build configuration files are located in `build_config` directory. For examples: +* `default`: the default configuration * `host-gprof`: compiles with `gprof` for performance tuning * `host-m32`: compiles in gcc 32bit mode on 64bit platforms * `boxing`: compiles all three boxing options @@ -128,6 +129,10 @@ Renamed from `OP_RAISE` * `OP_RAISEIF` +Instruction that is reserved for the future keyword argument support. + +* OP_SENDVK + ## Removed Instructions Instructions for old exception handling @@ -150,3 +155,9 @@ Jump addresses used to be specified by absolute offset from the start of `iseq`. ## `Random` now use `xoshiro128++`. For better and faster random number generation. + +## Preallocated Symnol + +Preallocated symbols are interned at compile-time. They can be accessed via symbols macros (e.g. `MRB_SYM()`). + +See [Symbols](https://github.com/mruby/mruby/blob/master/doc/guides/symbol.md). diff --git a/include/mruby.h b/include/mruby.h index b1cefb27b..d421dc58c 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -1303,34 +1303,26 @@ MRB_API mrb_value mrb_vformat(mrb_state *mrb, const char *format, va_list ap); + those E_* macros requires mrb_state* variable named mrb. + exception objects obtained from those macros are local to mrb */ -#ifdef MRB_SYM -/* mruby/presym.h is included earlier */ -# define MRB_E_SYM(sym) MRB_SYM(sym) -#else -# define MRB_E_SYM(sym) mrb_intern_lit(mrb, #sym) -#endif - -#define E_RUNTIME_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "RuntimeError")) -#define E_TYPE_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "TypeError")) -#define E_ZERODIV_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "ZeroDivisionError")) -#define E_ARGUMENT_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "ArgumentError")) -#define E_INDEX_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "IndexError")) -#define E_RANGE_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "RangeError")) -#define E_NAME_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "NameError")) -#define E_NOMETHOD_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "NoMethodError")) -#define E_SCRIPT_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "ScriptError")) -#define E_SYNTAX_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "SyntaxError")) -#define E_LOCALJUMP_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "LocalJumpError")) -#define E_REGEXP_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "RegexpError")) -#define E_FROZEN_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "FrozenError")) - -#define E_NOTIMP_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "NotImplementedError")) +#define MRB_ERROR_SYM(sym) mrb_intern_lit(mrb, #sym) +#define E_RUNTIME_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(RuntimeError)) +#define E_TYPE_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(TypeError)) +#define E_ZERODIV_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(ZeroDivisionError)) +#define E_ARGUMENT_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(ArgumentError)) +#define E_INDEX_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(IndexError)) +#define E_RANGE_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(RangeError)) +#define E_NAME_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(NameError)) +#define E_NOMETHOD_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(NoMethodError)) +#define E_SCRIPT_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(ScriptError)) +#define E_SYNTAX_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(SyntaxError)) +#define E_LOCALJUMP_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(LocalJumpError)) +#define E_REGEXP_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(RegexpError)) +#define E_FROZEN_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(FrozenError)) +#define E_NOTIMP_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(NotImplementedError)) +#define E_KEY_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(KeyError)) #ifndef MRB_NO_FLOAT -#define E_FLOATDOMAIN_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "FloatDomainError")) +# define E_FLOATDOMAIN_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(FloatDomainError)) #endif -#define E_KEY_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "KeyError")) - MRB_API mrb_value mrb_yield(mrb_state *mrb, mrb_value b, mrb_value arg); MRB_API mrb_value mrb_yield_argv(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv); MRB_API mrb_value mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv, mrb_value self, struct RClass *c); @@ -1396,7 +1388,7 @@ MRB_API mrb_value mrb_fiber_alive_p(mrb_state *mrb, mrb_value fib); * * Implemented in mruby-fiber */ -#define E_FIBER_ERROR mrb_exc_get_id(mrb, mrb_intern_lit(mrb, "FiberError")) +#define E_FIBER_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(FiberError)) MRB_API void mrb_stack_extend(mrb_state*, mrb_int); /* memory pool implementation */ diff --git a/include/mruby/presym/enable.h b/include/mruby/presym/enable.h index a5a4f2efb..844518c24 100644 --- a/include/mruby/presym/enable.h +++ b/include/mruby/presym/enable.h @@ -39,7 +39,7 @@ enum mruby_presym { static void init_##name(mrb_state *mrb) {} /* use MRB_SYM() for E_RUNTIME_ERROR etc. */ -# undef MRB_E_SYM -# define MRB_E_SYM(sym) MRB_SYM(sym) +#undef MRB_ERROR_SYM +#define MRB_ERROR_SYM(sym) MRB_SYM(sym) #endif /* MRUBY_PRESYM_ENABLE_H */ diff --git a/mrbgems/mruby-bin-config/mrbgem.rake b/mrbgems/mruby-bin-config/mrbgem.rake index 9f298ea76..b4c437640 100644 --- a/mrbgems/mruby-bin-config/mrbgem.rake +++ b/mrbgems/mruby-bin-config/mrbgem.rake @@ -7,7 +7,7 @@ MRuby::Gem::Specification.new('mruby-bin-config') do |spec| spec.summary = "#{name} command" if iscross - mruby_config_dir = "#{build.build_dir}/host/bin" + mruby_config_dir = "#{build.build_dir}/host-bin" else mruby_config_dir = "#{build.build_dir}/bin" end @@ -28,7 +28,6 @@ MRuby::Gem::Specification.new('mruby-bin-config') do |spec| config = Hash[File.readlines(make_cfg).map!(&:chomp).map! {|l| l.gsub('\\"', '"').split(' = ', 2).map! {|s| s.sub(/^(?=.)/, 'echo ')} }] - pp config tmplt = File.read(tmplt_path) File.write(t.name, tmplt.gsub(/(#{Regexp.union(*config.keys)})\b/, config)) chmod(0755, t.name) |
