summaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)Author
2019-10-22Fix incorrect `MRB_STR_ASCII` flag update in `mrb_str_dump`KOBAYASHI Shuji
### Example (with `MRB_UTF8_STRING`) ```ruby s = "\u3042" p s.size s.dump p s.size ``` #### Before this patch: ``` 1 3 ``` #### After this patch: ``` 1 1 ```
2019-10-20Use `mrb_str_cat_str` instead of `mrb_str_concat` if possibleKOBAYASHI Shuji
2019-10-19Fix that `Module#to_s` may return frozen string; ref 08eafe2KOBAYASHI Shuji
2019-10-17delete extern in Cyuri
2019-10-16Use `mrb_sym_name_len` instead of `mrb_sym_name` in `assign_class_name`KOBAYASHI Shuji
2019-10-15Adjust `buf` size in `str_escape`KOBAYASHI Shuji
2019-10-13Refactor `mrb_class_name_class`KOBAYASHI Shuji
- Use `mrb_sym_name_len` instead of `mrb_sym_name` (class name should not be escaped). - Avoid `mrb_str_dup` (it is unnecessary to be shared string because it is changed).
2019-10-12Merge pull request #4770 from ↵Yukihiro "Matz" Matsumoto
shuujii/sHARED-string-is-not-required-when-sharing-POOL-string SHARED string is not required when sharing POOL string
2019-10-12SHARED string is not required when sharing POOL stringKOBAYASHI Shuji
The heap string buffer of POOL string always exists, does not need to be released, and read only, so it can be shared as NOFREE string.
2019-10-12Rename `str_make_shared()` to `str_share()` in `src/string.c`KOBAYASHI Shuji
Because it may not create `struct mrb_shared_string`.
2019-10-10Integrate `mrb_str_inspect` and `mrb_str_dump`KOBAYASHI Shuji
2019-10-08Implement Ruby2.7's frozen strings from `Module#name`KOBAYASHI Shuji
2019-10-06Remove unnecessary function: `mrb_str_freeze`.Yukihiro "Matz" Matsumoto
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-10-04Implement Ruby2.7's frozen strings from `Symbol#to_s`.Yukihiro "Matz" Matsumoto
2019-10-03Remove duplicates header files in `src/pool.c`dearblue
These are included in `mruby.h`. As a background, if `enable_cxx_abi` is specified, the macro that defines the maximum value in `stdint.h` is undefined depending on the environment. - Confirmed with gcc on FreeBSD 12.0 and mingw32-gcc available on FreeBSD. - `INTPTR_MAX`, `INT64_MAX` and `UINT64_MAX` are defined by `cstdint` added in C++11. But `toolchains :gcc` adds `-std=c++03`, so the macros are not defined. - To have these defined in `C++03`, `__STDC_CONSTANT_MACROS` must be defined in advance. This is already done by `mruby.h`.
2019-10-02Avoid `symhash()` call for inline symbol in `sym_intern()`KOBAYASHI Shuji
2019-09-29Allow rethrowing `MRB_TT_BREAK`dearblue
2019-09-27Simplify arguments check in `String#rindex`KOBAYASHI Shuji
Also fix document about type of the first argument.
2019-09-27Merge pull request #4733 from ↵Yukihiro "Matz" Matsumoto
shuujii/use-type-predicate-macros-instead-of-mrb_type-if-possible Use type predicate macros instead of `mrb_type` if possible
2019-09-26Fixed `codedump` for human readable symbol format; ref #4684Yukihiro "Matz" Matsumoto
2019-09-26Use type predicate macros instead of `mrb_type` if possibleKOBAYASHI Shuji
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for all `enum mrb_vtype`).
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-24`Exception#initialize` should not allow two or more argumentsKOBAYASHI Shuji
2019-09-21Rename MRB_USE_ETEXT_EDATA to MRB_USE_LINK_TIME_RO_DATA_P and support lld ↵Fangrui Song
linked programs In lld linked programs, .rodata comes before .text, thus mrb_ro_data_p will return false for strings in .rodata. Change the lower bound from _etext to __ehdr_start to catch these cases. This works for ld.bfd, gold and lld, and it does not have false positives even if .init_array does not exist. Remove the branch that uses _edata: strings in .data can be modified so this is semantically incorrect. Delete the __APPLE__ branch (its manpages say get_etext() and get_edata() are strongly discouraged). .init_array has been adopted by most ELF platforms to supersede .ctors. Neither _etext nor _edata is used, so rename MRB_USE_ETEXT_EDATA to MRB_USE_EHDR_START.
2019-09-20Fix compatibility issue of class variables.Yukihiro "Matz" Matsumoto
Singleton class definition do not introduce its own class variable scope in CRuby/JRuby. So should mruby. ``` module Mod1 class << Object.new C = 1 @@cv = 1 p Module.nesting, # => [#<Class:#<Object:0x55cb16e60a50>>, Mod1] constants, # => [:C] class_variables, # => [] Mod1.class_variables # => [:@@cv] end end ```
2019-09-20Add optional argument to `Module#class_variables`.Yukihiro "Matz" Matsumoto
2019-09-19Simplify arguments check in `String#index`KOBAYASHI Shuji
Also fix document about type of the first argument.
2019-09-18Remove `mrb_get_args(mrb, "")`; ref 30f37872KOBAYASHI Shuji
2019-09-18Fix `super` from aliased methods to work correctly; fix #4718Yukihiro "Matz" Matsumoto
We needed to preserve the original method name somewhere. We kept it in the `env` structure pointed from aliased methods. #1457 and #1531 tried to address this issue. But this patch is more memory efficient. Limitation: this fix does not support `super` from methods defined by `define_method`. This limitation may be addressed in the future, but it's low priority.
2019-09-17Merge pull request #4717 from shuujii/fix-Fixnum-to_s-inspect-argument-specsYukihiro "Matz" Matsumoto
Fix `Fixnum#(to_s|inspect)` argument specs
2019-09-17Fix `Fixnum#(to_s|inspect)` argument specsKOBAYASHI Shuji
Before this patch: $ bin/mruby -e 'p 3.to_s(2)' trace (most recent call last): [0] -e:1 -e:1: 'to_s': wrong number of arguments (1 for 0) (ArgumentError) After this patch: $ bin/mruby -e 'p 3.to_s(2)' "11"
2019-09-17Merge pull request #4714 from dearblue/shrink-mrb_get_argsYukihiro "Matz" Matsumoto
Shrink `mrb_get_args()`
2019-09-17Merge pull request #4715 from dearblue/need-blockYukihiro "Matz" Matsumoto
Entrust "no block given" error to `mrb_get_args()`
2019-09-17Merge pull request #4713 from shuujii/fix-argument-specs-to-EnumerableYukihiro "Matz" Matsumoto
Fix argument specs to `Enumerable`
2019-09-16Entrust "no block given" error to `mrb_get_args()`dearblue
Some error messages will be changed.
2019-09-16Shrink `mrb_get_args()`dearblue
As a side effect, all specifiers now accept the `!` modifier.
2019-09-16Cache argv first in each specifiers for `mrb_get_args()`; ref #3090dearblue
In terms of specifiers, argv is never referenced after a method call as shown in #3090. Reduction of object code can be expected. If you need to refer to argv after a method call in the same loop, update argv after the method call.
2019-09-16Fix argument specs to `Enumerable`KOBAYASHI Shuji
2019-09-16Raise `ArgumentError` by `aspec` check; ref #4688Yukihiro "Matz" Matsumoto
This is partial `aspec` check that only checks `MRB_ARGS_NONE()`.
2019-09-14Add a macro `mrb_frozen_p` that points to `MRB_FROZEN_P`.Yukihiro "Matz" Matsumoto
2019-09-14Use `%C` to `mrb_name_error` in `mrb_method_search`; ref 5890c7d5KOBAYASHI Shuji
2019-09-14Remove `mrb_funcall` from `<=>` operations.Yukihiro "Matz" Matsumoto
2019-09-14Raise an error from `String#<=>` with a non string operand.Yukihiro "Matz" Matsumoto
2019-09-14Use `mrb_equal` instead of `mrb_funcall`.Yukihiro "Matz" Matsumoto
In the typical case, `mrb_funcall` invocation would be skipped.
2019-09-14Remove `mrb_funcall` from `mrb_method_search`.Yukihiro "Matz" Matsumoto
2019-09-12Remove `$/` from mruby implementation.Yukihiro "Matz" Matsumoto
1. `$/` and other Perl-ish global variables are not defined in ISO. 2. The current Ruby policy do not encourage those variables. 3. Those variables has global effect and can cause troubles.
2019-09-12Use `mrb_str_inspect` instead of `mrb_str_dup`; fix #4678Yukihiro "Matz" Matsumoto
2019-09-11Move `String#{getbyte,setbyte,byteslice}` to the core; #4696Yukihiro "Matz" Matsumoto
Unlike CRuby, there's no way to process strings byte-wise by core methods because there's no per string encoding in mruby, so that we moved 3 byte-wise operation methods from `mruby-string-ext` gem.