summaryrefslogtreecommitdiffhomepage
path: root/include/mruby.h
AgeCommit message (Collapse)Author
2020-10-12Restore old function names for compatibility; fix #5070Yukihiro "Matz" Matsumoto
Rename new functions: - `mrb_convert_type(mrb,val,type,tname,method)` => `mrb_type_convert(mrb,val,type,tname,method)` - `mrb_check_convert_type(mrb,val,type,tname,method)` => `mrb_type_convert_check(mrb,val,type,tname,method)` Old names are defined by macros (support `tname` drop and `char*` => `mrb_sym` conversion).
2020-10-12Avoid `unsigned int`; Use `mrb_int` instead.Yukihiro "Matz" Matsumoto
2020-10-12Change some `int` variables to `mrb_int`.Yukihiro "Matz" Matsumoto
To silence some warnings. This change cancels part of 7ef3604134.
2020-10-12Update `mrb_get_args()` keyword argument support [incompatible]Yukihiro "Matz" Matsumoto
* `mrb_kwargs` structure reordered (`values` and `rest` come last) * take symbols instead of C `char*`
2020-10-12Silence warnings from implicit integer conversions.Yukihiro "Matz" Matsumoto
Caused from combination of `mrb_int`, `int` and `size_t`..
2020-10-12Reorganize `Integer` system.Yukihiro "Matz" Matsumoto
- Integrate `Fixnum` and `Integer` - Remove `Integral` - `int / int -> int` - Replace `mrb_fixnum()` to `mrb_int()` - Replace `mrb_fixnum_value()` to `mrb_int_value()`. - Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
2020-10-12Change the return type of `mrb_check_intern()` and friends.Yukihiro "Matz" Matsumoto
They used to return `mrb_value` but now return `mrb_sym` for consistency with other `intern` functions. If symbols are not defined, `check` functions return `0`, instead of `nil` in the past. It causes API incompatibility but I believe few people use those functions out of the core, and those changes are very easy to handle, hopefully.
2020-10-12Make division by zero cause `ZeroDivisionError`.Yukihiro "Matz" Matsumoto
As described in ISO 15.2.30.
2020-10-12Integrate `Fixnum` class into `Integer` classdearblue
* The `Fixnum` constant is now an alias for the `Integer` class. * Remove `struct mrb_state::fixnum_class` member. If necessary, use `struct mrb_state::integer_class` instead.
2020-10-12Rename float configuration option names.Yukihiro "Matz" Matsumoto
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT` - `MRB_USE_FLOAT` => `MRB_USE_FLOAT32` The former is to use `USE_XXX` naming convention. The latter is to make sure `float` is 32bit float and not floating point number in general.
2020-10-12Rename `MRB_METHOD_T_STRUCT` to `MRB_USE_METHOD_T_STRUCT`.Yukihiro "Matz" Matsumoto
It's the first change of renaming configuration options to `MRB_XXX` to `MRB_USE_XXX` or `MRB_NO_XXX`.
2020-10-12Replace global jump with catch handler implementationdearblue
When a global jump occurs, look at the catch handler table to determine where to jump. In that case, `pc` already shows the following instruction, but since the table shows `begin_offset ... end_offset`, the comparison is done with `begin_offset < pc && pc <= end_offset`. If there is a corresponding handler, move `pc` to `handler.target_offset` and continue running the VM. When a global jump across `ensure` is made by `return`, `break`, `next`, `redo` and `retry`, the extended `RBreak` object saves and restores the C-level execution position. This extended `RBreak` can have tag information, which makes it a pseudo coroutine (the "tag" mimics CRuby). The implementation of pseudo coroutines by `RBreak` is summarized by `CHECKPOINT_RESTORE ... CHECKPOINT_MAIN ... CHECKPOINT_END` and `throw_tagged_break` / `unwind_ensure` macros. The restart of processing is branched by `RBREAK_TAG_FOREACH(DISPATCH_CHECKPOINTS)`. - Not only `rescue` blocks but also `ensure` blocks are now sandwiched between `OP_EXCEPT` and `OP_RAISEIF`. - Remove the function `ecall()`. It is no longer necessary to re-enter the VM to perform an "ensure block". This will resolves #1888. - Added instruction `OP_JUW` (Jump while UnWind). It jumps unconditionally like `OP_JMP`, but searches the catch handler table and executes the ensure block. Since it searches the catch handler table, it is much heavier than `OP_JMP`.
2020-10-12Enable method cache by default.Yukihiro "Matz" Matsumoto
Introduced `MRB_NO_METHOD_CACHE` which is inverse of `MRB_METHOD_CACHE` that should be enabled intestinally. In addition, the default cache is made bigger (128 -> 256).
2020-10-12Generate C struct from `irep` instead of binary dump.Yukihiro "Matz" Matsumoto
2020-10-12Add `const` modifier to `mrb_irep` for `code_fetch_hook`.Yukihiro "Matz" Matsumoto
2020-10-12Change the arguments of following implicit conversion functions:Yukihiro "Matz" Matsumoto
- `mrb_convert_type` - `mrb_check_convert_type` Those function no longer take `tname` string representation of desired type, and take method symbols instead of `const char*` names. This is incompatible change. I hope no third-party gems use those functions.
2020-10-12Provide functions that take symbols instead of `const char*`.Yukihiro "Matz" Matsumoto
- mrb_define_class_id - mrb_define_module_id - mrb_define_method_id - mrb_define_singleton_method_id - mrb_define_module_function_id - mrb_define_const_id - mrb_undef_method_id - mrb_undef_class_method_id - mrb_class_defined_id - mrb_class_get_id - mrb_class_defined_under_id - mrb_class_get_under_id - mrb_module_get_id - mrb_module_get_under_id - mrb_define_class_under_id - mrb_define_module_under_id - mrb_exc_get_id
2020-10-12Add functions that take symbols as arguments.Yukihiro "Matz" Matsumoto
- :
2020-10-12Define a new function `mrb_funcall_id()`.Yukihiro "Matz" Matsumoto
`mrb_funcall_id()` takes `mrb_sym` instead of `char*` for a method name. You can use `MRB_SYM()`/`MRB_QSYM()` to specify the method to call.
2020-10-12Add `MRB_SYM()` for inline symbols.Yukihiro "Matz" Matsumoto
2020-09-25Prohibit string changes by "s"/"z" specifier of `mrb_get_args()`dearblue
- The `s` specifier is a string pointer obtained without performing `mrb_str_modify()`, so it cannot be changed. - The `z` specifier cannot be changed because it is a string pointer obtained by `RSTRING_CSTR()` which returns `const char *`.
2020-09-03Remove `enum call_type`dearblue
It seems to be unnecessary from mruby-1.0.0 or earlier.
2020-08-12Simplify MSVC detection to `mrb_static_assert`KOBAYASHI Shuji
2020-08-11Use normal `static_assert` in `mrb_static_assert` as much as possibleKOBAYASHI Shuji
* `_Static_assert` can also be used with `-std=gnu99` on GCC >= 4.6. * `static_assert` can be used on MSVC. * `static_assert` can be used even on old G++/Clang++ if `__GXX_EXPERIMENTAL_CXX0X__` is defined.
2020-08-09Allow `mrb_static_assert()` to be used outside of functionsKOBAYASHI Shuji
The use of `struct` is an idea by @dearblue.
2020-08-08Reintroduce `mrb_static_assert`; #5051Yukihiro "Matz" Matsumoto
Note that the home brew version of `mrb_static_assert` only works within the function body. This reverts commit 8f99689.
2020-08-06Remove `mrb_static_assert` from the core; #5051Yukihiro "Matz" Matsumoto
2020-06-20Add `mrb_get_arg1()` that retrieves single (and only) argument.Yukihiro "Matz" Matsumoto
`mrb_get_arg1()` raises `ArgumentError` if the method does not receive one argument. And replaces all `mrb_get_args(mrb, "o", &arg)` by the new function.
2020-06-05Merge master.Hiroshi Mimaki
2020-05-31Fix float constant redefinition warningsRory OConnell
2020-05-07Remove `mrb_run` from `MRB_API`; #4488Yukihiro "Matz" Matsumoto
`mrb_run` requires to push callinfo stack before calling, which is very hard from outside of `vm.c`. So there should be virtually no correct usage of the function, hence the cause of #4488. We removed it. You can use `mrb_top_run(mrb, proc, self, 0)` instead of `mrb_run(mrb, proc self)`.
2020-04-26Reduce `struct mrb_context`dearblue
2020-04-22Add new function `mrb_singleton_class_ptr()`; ref #4973Yukihiro "Matz" Matsumoto
The difference between `mrb_singleton_class` and `mrb_singleton_class_ptr`: - `mrb_singleton_class_ptr` returns `struct RClass*`. - `mrb_singleton_class_ptr` returns `NULL` on immediate values where `mrb_singleton_class` raises exceptions.
2020-04-10Update version to `2.1.1`. (mruby 2.1.1 RC)2.1.1-rcHiroshi Mimaki
2020-01-30Move fallback definitions of `FLT_EPSILON` etc. after `#include <mruby/value.h>`Yukihiro "Matz" Matsumoto
that includes `float.h`. It allows definitions from native headers.
2020-01-01Rename `mrb_num_args_error` to `mrb_argnum_error`; ref #4863Yukihiro "Matz" Matsumoto
2019-12-12Add `mrb_num_args_error()` for "wrong number of arguments" errorKOBAYASHI Shuji
To unify the style of messages.
2019-10-06Get keyword arguments with `mrb_get_args()`dearblue
Keyword arguments can now be retrieved with the `:` specifier and `mrb_kwargs` data. For the interface, I referred to CRuby's `rb_get_kwargs()`. For implementation, I referred to `OP_KARG` or etc.
2019-10-04Freeze strings from `nil.to_s`, `true.to_s`, `false.to_s`.Yukihiro "Matz" Matsumoto
This is an experimental changes in Ruby 2.7.
2019-09-26Fixed `codedump` for human readable symbol format; ref #4684Yukihiro "Matz" Matsumoto
2019-09-25Rename symbol-to-string functions; close #4684Yukihiro "Matz" Matsumoto
* mrb_sym2name -> mrb_sym_name * mrb_sym2name_len -> mrb_sym_name_len * mrb_sym2str -> mrb_sym_str
2019-09-16Remove `MRB_METHOD_TABLE_INLINE`.Yukihiro "Matz" Matsumoto
`MRB_METHOD_TABLE_INLINE` was fragile. It requires `-falign-functions=n`. On platform that uses higher bits of function pointers, you can use new `MRB_METHOD_T_STRUCT` configuration macro.
2019-09-16Refactor `mrb_method_t`.Yukihiro "Matz" Matsumoto
2019-09-14Add argument names to C function prototypes.Yukihiro "Matz" Matsumoto
2019-09-14Add a macro `mrb_frozen_p` that points to `MRB_FROZEN_P`.Yukihiro "Matz" Matsumoto
2019-09-14Remove `mrb_funcall` from `<=>` operations.Yukihiro "Matz" Matsumoto
2019-08-26fix lots of warnings and make logo not so bigDavid Siaw
2019-08-19Merge pull request #4636 from davidsiaw/doxygenYukihiro "Matz" Matsumoto
Generate doxygen docs for mruby
2019-08-18fix up documentation for valuesDavid Siaw
2019-08-18Prohibit changes to iseq in principledearblue