dearblue
0c5c04d7c8
Use MRB_VTYPE_FOREACH() in src/object.c
2021-06-20 11:11:37 +09:00
dearblue
cc95e346fd
Added MRB_OBJ_ALLOC() macro that does not require a cast
...
The `MRB_OBJ_ALLOC()` macro function returns a pointer of the type corresponding to the constant literal defined in `enum mrb_vtype`.
2021-06-20 11:08:28 +09:00
dearblue
c40802865a
Added MRB_API function to get block arguments info.
...
- ` mrb_block_given_p()` -- The name comes from CRuby's `rb_block_given_p ()`
At the same time, it applies to `f_instance_eval()` and `f_class_eval()` of `mruby-eval`.
2021-06-19 21:15:02 +09:00
Yukihiro "Matz" Matsumoto
4fcb5e8e4f
variable.c: add skip argument to skip base class in lookup.
...
`mrb_vm_const_get` function looks up the constant first in the base
class, so that fallback `const_get` need not to search from the base.
2021-06-17 16:53:54 +09:00
Yukihiro "Matz" Matsumoto
63bafca7f5
variable.c: refactor mrb_vm_const_get function.
2021-06-17 16:53:21 +09:00
Yukihiro "Matz" Matsumoto
090356ec3b
variable.c: skip prepended module for constant lookup.
...
```ruby
module M
FOO = 'm'
end
class A
FOO = 'a'
prepend M
end
class B < A
def foo
p FOO
end
end
B.new.foo # should print `m` not `a`
```
2021-06-17 16:35:39 +09:00
Yukihiro "Matz" Matsumoto
62754a4739
class.c: use MRB_FLAG_TEST() macro.
2021-06-17 16:34:51 +09:00
Yukihiro "Matz" Matsumoto
a528834df7
Revert "instance_eval for classes and modules should behave as class_eval."
...
This reverts commit ee3017496b .
I misunderstood something and the new behavior was different from CRuby.
The issue was reported by @dearblue, regarding #5478
2021-06-17 07:54:54 +09:00
Yukihiro "Matz" Matsumoto
2341e4f5e5
Merge pull request #5445 from jbampton/add-codespell-pre-commit-hook
...
Run pre-commit with GitHub Actions
2021-06-16 09:15:07 +09:00
John Bampton
dab5502e8a
Run pre-commit with GitHub Actions
...
Running pre-commit with GitHub Actions now gives us more tests and coverage
Remove duplicate GitHub Actions for merge conflicts and trailing whitespace
Remove duplicate checks for markdownlint and yamllint from the GitHub Super-Linter
Add new custom pre-commit hook running with a shell script to sort alphabetically and uniquify codespell.txt
Add new pre-commit hook to check spelling with codespell
https://github.com/codespell-project/codespell
Fix spelling
2021-06-16 08:34:54 +10:00
Yukihiro "Matz" Matsumoto
7c8a91ff5a
numeric.c: restore fmt argument for backward compatibility.
...
`mrb_float_to_str()` used to take `fmt` argument. We thought no one used
the function, and OK to remove the argument. But at least `mruby-redis`
gem used the function.
2021-06-15 16:19:16 +09:00
Yukihiro "Matz" Matsumoto
eaaa9148b5
readint.c: fixed typo.
2021-06-12 16:18:45 +09:00
dearblue
b45d95fa9e
Raise TypeError with super inside instance_eval / class_eval
...
Commit d0f60182af introduced an exception as a limitation of mruby.
Subsequent CRuby-2.7 has changed its behavior to raise an exception.
ref: https://github.com/ruby/ruby/commit/55b7ba368696033f2e89b77cbcd4a05dec97b139
2021-06-12 16:08:21 +09:00
Yukihiro "Matz" Matsumoto
49af1fca03
readint.c: add new function mrb_int_read.
...
Difference from `strtoul(3)`:
* reads `mrb_int` based on configuration
* specifies the end of the string
* no sign interpretation
* base 10 only
2021-06-11 15:14:17 +09:00
Yukihiro "Matz" Matsumoto
df549c12e5
readflt.c: renamed from strtod.c
...
The file provides `mrb_read_float()` renamed from `vim_strtod()`.
2021-06-10 15:04:35 +09:00
Yukihiro "Matz" Matsumoto
3acc09ae61
string.c: make mrb_str_len_{inum,dbl}() static.
2021-06-08 17:19:31 +09:00
Yukihiro "Matz" Matsumoto
d8ec544564
string.c: remove two unused functions.
...
* `mrb_cstr_to_inum()`
* `mrb_cstr_to_dbl()`
2021-06-08 17:00:54 +09:00
Yukihiro "Matz" Matsumoto
a5f323835e
string.c: add base>36 check to String#to_i.
2021-06-08 16:59:57 +09:00
Yukihiro "Matz" Matsumoto
abb288f5cb
codedump.c: fix a compiler condition bug with MRB_NO_FLOAT.
2021-06-05 08:09:04 +09:00
Yukihiro "Matz" Matsumoto
9775315240
vm.c: unify JUMP instructions in OP_SEND.
2021-06-02 18:53:22 +09:00
Yukihiro "Matz" Matsumoto
843abc5c7b
cdump.c: rename dump_ prefix to cdump for static functions.
2021-06-01 22:21:04 +09:00
Yukihiro "Matz" Matsumoto
ff93854c4a
cdump.c: separate irep dump in C feature.
2021-06-01 16:47:06 +09:00
Yukihiro "Matz" Matsumoto
cf2e78de44
numeric.c: fixed a silly bug related to pointer decrement.
2021-05-31 02:59:33 +09:00
Yukihiro "Matz" Matsumoto
8a4bcc58c9
numeric.c: introduce mrb_int_to_cstr() to dump mrb_int.
...
* refactor `mrb_integer_to_str()`
* refactor `mrb_str_format()`
2021-05-30 08:15:51 +09:00
Yukihiro "Matz" Matsumoto
2a717cf2aa
backtrace.c: do not skip frames for C function calls.
2021-05-28 07:36:20 +09:00
Yukihiro "Matz" Matsumoto
cefbc21e67
vm.c: skip actual method_missing call unless it's overridden.
...
So that `mruby -e 'a'` does not print backtrace history, i.e.
```
% mruby -e 'a'
-e:1: undefined method 'a' (NoMethodError)
```
Instead of
```
% mruby -e 'a'
trace (most recent call last):
[1] -e:1
-e:1: undefined method 'a' (NoMethodError)
```
2021-05-28 07:30:43 +09:00
Yukihiro "Matz" Matsumoto
d9c8626bb1
kernel.c: clear mid for raise and method_missing
...
Method names need not to be printed in backtrace history.
2021-05-27 21:48:26 +09:00
Yukihiro "Matz" Matsumoto
cb92f9ce0b
backtrace.c: do not print trace line if there's no backtrace history
2021-05-27 21:44:55 +09:00
Yukihiro "Matz" Matsumoto
48b08fecba
array.c: unify mrb_ary_ref and mrb_ary_entry
...
Use only `mrb_ary_entry` hereafter.
2021-05-27 21:43:43 +09:00
Yukihiro "Matz" Matsumoto
9a72869043
array.c: check for negative shift size.
2021-05-27 08:13:49 +09:00
Yukihiro "Matz" Matsumoto
c019d8d34d
fmt_fp.c: move mruby specific mrb_float_to_str to numeric.c
2021-05-26 17:29:18 +09:00
Yukihiro "Matz" Matsumoto
063b49ab8e
fmt_fp.c: truncate precision to prevent buffer overflow.
2021-05-25 13:32:29 +09:00
Yukihiro "Matz" Matsumoto
afbc199ed3
fmt_fp.c: use constant that depends on mrb_float size.
2021-05-25 13:31:41 +09:00
Yukihiro "Matz" Matsumoto
5ed3a3475e
fmt_fp.c: use a const int instead of a macro constant.
2021-05-25 13:30:17 +09:00
Yukihiro "Matz" Matsumoto
bf523b71d1
strtod.c: new public domain implementation of strtod; ref #5448
...
Instead of using copyrighted `strtod`, now use the public domain
implementation of `strtod` by Yasuhiro Matsumoto (@mattn). The function
has been renamed to `mrb_float_read()`; ref #5460 as well.
2021-05-24 12:10:14 +09:00
Yukihiro "Matz" Matsumoto
a44ca2e9be
fmt_fp.c: exponential may be bigger than 100.
2021-05-24 11:50:30 +09:00
Yukihiro "Matz" Matsumoto
d121075e49
class.c: no need to create aliases if both symbols are same.
2021-05-24 11:50:30 +09:00
Yukihiro "Matz" Matsumoto
e323cd0c6e
class.c: add write barrier for aliases.
2021-05-24 11:50:29 +09:00
KOBAYASHI Shuji
6cfe184d39
Fix typo in src/fmt_fp.c [ci skip]
2021-05-22 17:00:14 +09:00
Yukihiro "Matz" Matsumoto
5c7fe225a6
fp_fmt.c: remove mrb_float_to_cstr().
...
The function was intended to be a utility function for `mruby-sprintf`.
The functionality was integrated into `sprintf.c`.
2021-05-22 14:16:55 +09:00
Yukihiro "Matz" Matsumoto
328563995f
fmt_fp.c: replace with public domain float format routine; ref #5448
...
The original code can be found in `https://github.com/dhylands/format-float `.
Changes:
- support `double`
- support `#` (alt_form) modifier
- small refactoring
2021-05-22 09:35:27 +09:00
Yukihiro "Matz" Matsumoto
fa29bb3bb4
fmt_fp.c: remove fmt argument from mrb_float_to_str().
...
With major refactoring to prepare removing `snprintf(3) calls.
2021-05-21 08:13:38 +09:00
Yukihiro "Matz" Matsumoto
beaf365dd4
numeric.h: remove 2 functions from MRB_API
...
- `mrb_float_to_str()`
- `mrb_float_to_cstr()`
Both functions will be replaced to support new coming `format-float.c`.
2021-05-21 08:13:38 +09:00
KOBAYASHI Shuji
e9e720eab9
Support load 64-bit integer from mrb format with MRB_32BIT and MRB_INT64
2021-05-20 19:39:08 +09:00
Yukihiro "Matz" Matsumoto
5eebbd7df2
Global renaming regarding integer and float.
...
Consistent number conversion function names:
* `mrb_value` to immediate (C) value
* `mrb_int()` -> `mrb_as_int()`
* `mrb_to_flo()` -> `mrb_as_float()`
* `mrb_value` to `mrb_value` (converted)
* `mrb_to_int()'
* `mrb_Integer()` - removed
* `mrb_Float()` -> `mrb_to_float`
Consistent function name (avoid `_flo` suffix):
* `mrb_div_flo()` -> `mrb_div_float`
2021-05-17 15:07:05 +09:00
Yukihiro "Matz" Matsumoto
ea7f1953c3
Rename mrb_fixnum_to_str to mrb_integer_to_str.
2021-05-17 13:59:01 +09:00
Yukihiro "Matz" Matsumoto
080fdbf9e8
Rename mrb_flo_to_fixnum to mrb_float_to_integer.
2021-05-17 13:58:54 +09:00
Yukihiro "Matz" Matsumoto
364f275997
range.c: implement (part of) Range#to_a in C.
...
Mostly for performance reason.
2021-05-14 08:39:14 +09:00
Yukihiro "Matz" Matsumoto
99f0adc3f4
range.c: refactor conditional compilation code.
...
So that auto indentation works.
2021-05-14 08:28:27 +09:00
Yukihiro "Matz" Matsumoto
dfac706ac2
range.c: rename RANGE_INITIALIZED_MASK to RANGE_INITIALIZED_FLAG.
2021-05-14 08:27:21 +09:00