| Age | Commit message (Collapse) | Author |
|
### 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
```
|
|
|
|
|
|
|
|
|
|
|
|
- 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).
|
|
shuujii/sHARED-string-is-not-required-when-sharing-POOL-string
SHARED string is not required when sharing POOL string
|
|
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.
|
|
Because it may not create `struct mrb_shared_string`.
|
|
|
|
|
|
|
|
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.
|
|
This is an experimental changes in Ruby 2.7.
|
|
|
|
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`.
|
|
|
|
|
|
Also fix document about type of the first argument.
|
|
shuujii/use-type-predicate-macros-instead-of-mrb_type-if-possible
Use type predicate macros instead of `mrb_type` if possible
|
|
|
|
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for
all `enum mrb_vtype`).
|
|
* mrb_sym2name -> mrb_sym_name
* mrb_sym2name_len -> mrb_sym_name_len
* mrb_sym2str -> mrb_sym_str
|
|
|
|
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.
|
|
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
```
|
|
|
|
Also fix document about type of the first argument.
|
|
|
|
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.
|
|
Fix `Fixnum#(to_s|inspect)` argument specs
|
|
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"
|
|
Shrink `mrb_get_args()`
|
|
Entrust "no block given" error to `mrb_get_args()`
|
|
Fix argument specs to `Enumerable`
|
|
Some error messages will be changed.
|
|
As a side effect, all specifiers now accept the `!` modifier.
|
|
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.
|
|
|
|
This is partial `aspec` check that only checks `MRB_ARGS_NONE()`.
|
|
|
|
|
|
|
|
|
|
In the typical case, `mrb_funcall` invocation would be skipped.
|
|
|
|
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.
|
|
|
|
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.
|