Compare commits

..

798 Commits

Author SHA1 Message Date
mimaki 28a1f7d143 Update version to 3.3.0RC2. 2024-01-04 14:56:56 +09:00
dearblue 69682e3d41 Fixed when combined mrb_fiber_resume() and Fiber#transfer
For example, the following code was crashing.

```c
#include <mruby.h>
#include <mruby/compile.h>
#include <mruby/proc.h>

int
main(int argc, char *argv[])
{
  mrb_state *mrb = mrb_open();

  mrb_value fiber = mrb_load_string(mrb, "Fiber.new { Fiber.new { 12345.6789 }.transfer }");
  mrb_value res = mrb_fiber_resume(mrb, fiber, 0, NULL);
  mrb_p(mrb, res);

  mrb_close(mrb);

  return 0;
}
```
2024-01-04 14:12:35 +09:00
John Bampton f8511ecb22 Fix pre-commit failure from prettier 2024-01-01 18:32:48 +09:00
Yukihiro "Matz" Matsumoto d4cd589733 NEWS: add mruby3.3 changes description 2024-01-01 10:11:32 +09:00
mimaki 82e289a64d Update version to 3.3.0RC. 2023-12-29 16:02:13 +09:00
mimaki c1ed125689 Merge remote-tracking branch 'origin/master' into stable 2023-12-29 14:26:19 +09:00
Yukihiro "Matz" Matsumoto 6d8323f3c7 mruby-pack (pack_unpack): unpack1 did not return single data; fix #6134
For following unpack directives:

- PACK_DIR_HEX (h)
- PACK_DIR_BSTR (b)
- PACK_DIR_STR (a,A,Z)
- PACK_DIR_BASE64 (m)
- PACK_DIR_QENC (M)
2023-12-29 13:09:14 +09:00
mimaki c11679ad79 Merge remote-tracking branch 'origin/master' into stable 2023-12-29 10:51:32 +09:00
Yukihiro "Matz" Matsumoto 95aa92d5c4 Update AUTHORS (date and commit hash) 2023-12-28 23:36:40 +09:00
Yukihiro "Matz" Matsumoto c1511d5f5d AUTHORS: update entries [ci skip] 2023-12-28 19:51:31 +09:00
mimaki e9047562a1 Merge branch 'master' into stable 2023-12-28 13:39:55 +09:00
Yukihiro "Matz" Matsumoto 67cb987510 doc/mruby3.{1,2}.md: update CVE links (nvd.nist.gov is down) 2023-12-27 22:24:12 +09:00
Yukihiro "Matz" Matsumoto 6ea3166005 doc/guides/memory.md: small style changes (markdownlink-cli) 2023-12-27 22:24:12 +09:00
Yukihiro "Matz" Matsumoto ae43ce7593 mruby-time: refactor _POSIX_TIMERS handling issue; ref #6124 2023-12-27 22:24:12 +09:00
Yukihiro "Matz" Matsumoto a8b82bfae5 Merge pull request #6128 from dearblue/fiber-end
Integrates the sequence when a fiber is terminated by `OP_RETURN`
2023-12-27 22:24:01 +09:00
Yukihiro "Matz" Matsumoto e51c20888b Merge pull request #6127 from dearblue/catch_handler_find
Changed parameters for `catch_handler_find()`
2023-12-27 22:22:12 +09:00
Yukihiro "Matz" Matsumoto 1ac4148020 Merge pull request #6126 from dearblue/block-return
Fixed return value of `OP_RETURN_BLK` called directly under C function
2023-12-27 22:19:36 +09:00
Yukihiro "Matz" Matsumoto 074374e28d Merge pull request #6125 from dearblue/cross-c
Allow `OP_RETURN_BLK` to cross C boundaries
2023-12-27 22:18:06 +09:00
Yukihiro "Matz" Matsumoto dc633ecae8 Merge pull request #6123 from dearblue/allocate-undef.2
Inherit `MRB_FL_UNDEF_ALLOCATE` in subclasses
2023-12-27 22:16:51 +09:00
Yukihiro "Matz" Matsumoto 7d83e9cd27 Merge pull request #6130 from sizious/dreamcast-shelf-build-config-overhaul
`dreamcast_shelf build config`: complete overhaul
2023-12-27 21:54:26 +09:00
SiZiOUS f81b7a3a1f dreamcast_shelf build config: complete overhaul
This configuration is used to support the Sega Dreamcast system.
mruby is now officially supported as a KallistiOS Port in kos-ports.
See: https://dreamcast.wiki/Using_Ruby_for_Sega_Dreamcast_development
2023-12-25 21:40:37 +00:00
Yukihiro "Matz" Matsumoto ebf66a2b80 Add prettier pre-commit hook; close #5490 2023-12-25 08:02:58 +09:00
Yukihiro "Matz" Matsumoto 9c66d4a453 Merge pull request #6124 from sizious/mruby-time-update
`mruby-time`: protect against incorrectly defined `_POSIX_TIMERS`
2023-12-24 17:33:23 +09:00
dearblue dba1dcdd25 Integrates the sequence when a fiber is terminated by OP_RETURN
In the `ensure` block while executing `fiber.transfer`, keep `fiber->cxt->prev` to be `NULL`.
2023-12-24 15:45:15 +09:00
dearblue dc09000f01 Fixed return value of OP_RETURN_BLK called directly under C function
```ruby
def cross; Class.new { return 1 }; end; p cross'
# => #<Class:0x8245cf170>               # without this patch
# => 1                                  # with this patch
```
2023-12-24 13:56:25 +09:00
dearblue d41a2612f4 Allow OP_RETURN_BLK to cross C boundaries
The restriction was introduced in commit b563bcb7ff to resolve https://github.com/mruby/mruby/issues/3462.
Subsequently, the `RBreak` object, introduced by mruby 1.3.0, allowed crossing the C boundary.

```ruby
def cross; Class.new { proc { return }.call }; end; cross
# => unexpected return (LocalJumpError) # without this patch
# => nothing raised                     # with this patch
```
2023-12-24 13:56:25 +09:00
SiZiOUS c0ffc13801 mruby-time: protect against incorrectly defined _POSIX_TIMERS
This update avoids the following error: operator '&&' has no right operand (related to _POSIX_TIMERS)
See: https://stackoverflow.com/questions/48538243/macro-if-statement-returns-error-operator-has-no-right-operand
2023-12-23 19:16:23 +00:00
dearblue 6a9671eac7 Changed parameters for catch_handler_find()
- Removed `mrb` and `ci` parameters.
  - Added `irep` parameter.
    The caller must guarantee that `irep->clen > 0`.
2023-12-23 23:02:48 +09:00
dearblue 2a1ea7d605 Inherit MRB_FL_UNDEF_ALLOCATE in subclasses
If `Class#allocate` is prohibited, subclasses should also be implicitly prohibited.

```ruby
p Class.new(Struct).allocate.class
# => #<Class:0x82362ac00>                                             by #6122
# => allocator undefined for #<Class:0x000000083a983220> (TypeError)  by Ruby 3.2
```

Added `MRB_DEFINE_ALLOCATOR()` to allow subclasses to use `Class#allocate`.

Supplement to #6122.
2023-12-23 21:01:42 +09:00
Yukihiro "Matz" Matsumoto 63580581f7 Merge pull request #6122 from dearblue/allocate-undef.1
Prohibit `Class#allocate` in a different way
2023-12-23 15:15:11 +09:00
dearblue 8ecfacefca Prohibit Class#allocate in a different way
The method introduced by #5979 causes a fault by swapping classes.

```console
% bin/mruby -e 'Method = Proc; p Object.method(:inspect)'
zsh: segmentation fault (core dumped)  bin/mruby -e 'Method = Proc; p Object.method(:inspect)'
```

After applying this patch, a `TypeError` exception will be raised.

```console
% bin/mruby -e 'Method = Proc; p Object.method(:inspect)'
trace (most recent call last):
        [1] -e:1
-e:1:in method: allocation failure of Proc (TypeError)
```

However, if the `mrb_vtype` is the same object, the same care must still be taken as before.

```console
% bin/mruby -e 'Method = Binding; p method(:puts).eval("12345")'
trace (most recent call last):
        [1] -e:1
-e:1:in eval: wrong argument type nil (expected Proc) (TypeError)
```
2023-12-22 21:59:34 +09:00
Yukihiro "Matz" Matsumoto fa75865a33 Merge pull request #6121 from dearblue/separate-breaks
Separate unwinding process for `break` / `return`
2023-12-22 16:12:12 +09:00
Yukihiro "Matz" Matsumoto 97b522d778 src/fmt_fp.c: change condition order for memory safety 2023-12-22 15:35:21 +09:00
Yukihiro "Matz" Matsumoto cfee5c2753 doc/guides/memory.md: guide to memory management customization 2023-12-21 16:48:33 +09:00
Yukihiro "Matz" Matsumoto 28b526cf81 Update .pre-commit-config.yaml 2023-12-21 16:47:16 +09:00
Yukihiro "Matz" Matsumoto 34c5d96e86 allof.c: mrb_default_allocf() definition in the separate file
So that the user can define their own version of mrb_default_alloc
function to override memory allocation of mruby.
2023-12-21 15:28:04 +09:00
dearblue 859f1b3002 Separate unwinding process for break / return 2023-12-20 21:54:53 +09:00
Yukihiro "Matz" Matsumoto 899a09152b mruby.h (mrb_alloc): better description for the function type 2023-12-20 19:39:09 +09:00
Yukihiro "Matz" Matsumoto 72ca266ed7 mruby-io: rename some functions with io_buf prefix
Now all functions with `io_buf` takes `mrb_io_buf` as an argument.

Renamed functions (old names):

- io_init_buf (io_buf_init)
- io_fill_buf (io_buf_fill)
- io_fill_buf_comp (io_buf_fill_comp) for UTF-8 encoding
2023-12-20 08:59:46 +09:00
Yukihiro "Matz" Matsumoto 84fb9f40f0 mruby-io: some functions take mrb_io_buf as an argument
- io_buf_reset
- io_buf_shift
- io_buf_cat
- io_buf_cat_all
2023-12-20 08:59:46 +09:00
Yukihiro "Matz" Matsumoto 054f5b5284 mruby-io (io_eof): avoid unnecessary read(2) call 2023-12-20 08:59:46 +09:00
Yukihiro "Matz" Matsumoto 2e8bede6ea mruby-io (io_read): small refactoring; ref #6118
If `outbuf` is `nil` we allocate a buffer string, if `outbuf` is a
string, we resize it to zero length. In the function `io_read`, this
condition is done twice, so we refactor out to `io_reset_outbuf()`.
2023-12-20 08:59:46 +09:00
Yukihiro "Matz" Matsumoto 2e24c94873 Merge pull request #6120 from dearblue/file-EBADF
Set `EBADF` if `check_file_descriptor()` fails
2023-12-20 08:59:29 +09:00
Yukihiro "Matz" Matsumoto 82ed1c2600 Merge pull request #6118 from dearblue/io.read
Fixed `IO#read` with `buf`.
2023-12-19 08:00:42 +09:00
Yukihiro "Matz" Matsumoto 992bd49344 Merge pull request #6116 from dearblue/send-branch
Improve branching in the execution part of the `OP_SEND` block
2023-12-18 12:17:39 +09:00
Yukihiro "Matz" Matsumoto e8a36235d8 Merge pull request #6115 from dearblue/loop-inclusion
Replace `for` and `CHECKPOINT` block comprehensions
2023-12-18 12:16:38 +09:00
dearblue 5e3e75ed7b Set EBADF if check_file_descriptor() fails 2023-12-17 10:50:59 +09:00
Yukihiro "Matz" Matsumoto b20418cf78 Merge pull request #6119 from jbampton/fix-spelling
docs: fix spelling
2023-12-17 07:14:17 +09:00
John Bampton 4c79fce665 docs: fix spelling 2023-12-17 00:58:24 +10:00
dearblue 7611dc8338 Fixed IO#read with buf.
I hit the following two problems.

  - `io.read(0, buf)` always returned a new empty string object.
  - `io.read(num, buf)` was appending data to the given `buf`.
    This also meant that `buf` was never empty if EOF was reached.
2023-12-16 14:42:52 +09:00
Yukihiro "Matz" Matsumoto d14a269f49 Merge pull request #6114 from dearblue/integrate-catch
Move `L_RAISE` and `L_BREAK` blocks to `OP_RAISEIF`
2023-12-16 13:08:33 +09:00
Yukihiro "Matz" Matsumoto ecea3f2531 Merge pull request #6117 from mruby/dependabot/github_actions/actions/upload-artifact-4
build(deps): bump actions/upload-artifact from 3 to 4
2023-12-16 13:05:38 +09:00
Yukihiro "Matz" Matsumoto 6fad067ded mruby-binding: raise in upper count check
We count `Proc` upper links then check for upper bounds (default:20),
but now we raise an exception as soon as the count exceeds the limit so
that we can avoid traverse unnecessary upper links.
2023-12-16 12:21:55 +09:00
dependabot[bot] 1b7f2fb175 build(deps): bump actions/upload-artifact from 3 to 4
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-15 14:22:12 +00:00
dearblue 990e18ad59 Improve branching in the execution part of the OP_SEND block
The `MRB_METHOD_CFUNC_P()` macro contains several branches, which will be replaced by simple branches.
2023-12-15 21:46:00 +09:00
dearblue 7144eab350 Replace for and CHECKPOINT block comprehensions
I think it will make the eyes less tired for a process flow.
2023-12-15 21:46:00 +09:00
dearblue e9904ddb2a Move L_RAISE and L_BREAK blocks to OP_RAISEIF
`OP_RAISEIF` should be easier to relate than `OP_RETURN`.
2023-12-15 21:46:00 +09:00
Yukihiro "Matz" Matsumoto 24eca2e50b mruby-fiber (fiber_to_s): omit position info for terminated fibers
Since Fiber#to_s did not include location information before #6105,
when location information cannot be retrieved for terminated fibers,
instead of meaningless information such as "(unknown):0", we omit
positional information altogether for terminated fibers; ref #6111
2023-12-14 18:56:19 +09:00
Yukihiro "Matz" Matsumoto e9237f444a Merge pull request #6111 from dearblue/fiber-to_s.1
Consider proc to be GC'ed if fiber is terminated
2023-12-14 14:59:18 +09:00
Yukihiro "Matz" Matsumoto 5311d1aa1b Merge pull request #6106 from dearblue/fiber-limits-ease
Ease fiber limitations
2023-12-13 16:10:42 +09:00
Yukihiro "Matz" Matsumoto ae8dcb82ba vm.c: CINFO_SKIP should not be called with prev_jmp == NULL
We have added assertion to ensure.
2023-12-12 16:49:11 +09:00
Yukihiro "Matz" Matsumoto 89d4e8c851 Merge pull request #6113 from dearblue/unreachable
Remove unreachable code in `OP_R_BREAK`
2023-12-12 16:48:55 +09:00
dearblue 38c7936c94 Remove unreachable code in OP_R_BREAK
Termination of fiber by `break` results in a `LocalJumpError`, so the indicated code will not be executed.
2023-12-11 21:25:08 +09:00
Yukihiro "Matz" Matsumoto 93d842e045 Merge pull request #6112 from dearblue/labeler
Update labeler.yml for version 5
2023-12-10 20:01:17 +09:00
dearblue c0b5bc4ae8 Consider proc to be GC'ed if fiber is terminated
When fiber is terminated, the pointer indicated by `f->cxt->cibase->proc` is not protected from GC.
I should have done this patch way as of commit 9af6264d6b (#6105).
2023-12-09 22:28:47 +09:00
dearblue 88571052e8 Update labeler.yml for version 5 2023-12-09 17:28:13 +09:00
Yukihiro "Matz" Matsumoto 34346e75a4 Merge pull request #6103 from dearblue/RBreak-ci
RBreak remembers the CI location
2023-12-09 11:35:23 +09:00
Yukihiro "Matz" Matsumoto 645a464b2d mruby-fiber (fiber_to_s): retrieve position from terminated fibers; #6105
Since `cxt->ci` points to the last active callinfo, `cxt->ci == cxt->cibase`
does not mean it does not have correct `proc` information, so we have
removed the `f->cxt->ci > f->cxt->cibase` check. Instead, just in case
`proc` does not have `irep` information, we try to confirm `proc` does not
point to `CFUNC` nor is not an alias.
2023-12-08 09:33:05 +09:00
Yukihiro "Matz" Matsumoto fdea7924fe mruby-fiber (fiber_to_s): do not rely on mrb_any_to_s(); ref #6105 2023-12-08 09:25:46 +09:00
Yukihiro "Matz" Matsumoto b7949e81d7 mruby-fiber (fiber_to_s): use "(unknown):0" for unknown position
Ref #6105
2023-12-08 09:22:59 +09:00
Yukihiro "Matz" Matsumoto cb54138b81 Merge pull request #6105 from dearblue/fiber.to_s
Implement `Fiber#to_s` method
2023-12-08 09:00:05 +09:00
dearblue 73c8330cbd RBreak remembers the CI location
It is now possible to specify return destination directly.
This allows callinfo to distinguish between calls to the same proc object.

At the same time, the `Kernel#catch` method is adjusted.
By removing the previously required double lambda object, the REnv object is no longer created as well.
2023-12-07 21:33:14 +09:00
Yukihiro "Matz" Matsumoto 658d5a51ac mruby-string-ext: add test for String#valid_encoding? 2023-12-07 11:34:10 +09:00
Yukihiro "Matz" Matsumoto eabe2d96e2 mruby-string-ext: add String#valid_encoding? method 2023-12-07 10:58:20 +09:00
Yukihiro "Matz" Matsumoto bef7eea468 mruby-method: small refactoring mostly regarding declarations 2023-12-06 22:20:38 +09:00
Yukihiro "Matz" Matsumoto b01eb03d2a Merge pull request #6110 from mruby/dependabot/github_actions/actions/labeler-5
build(deps): bump actions/labeler from 4 to 5
2023-12-06 15:58:59 +09:00
Yukihiro "Matz" Matsumoto fab3dfc145 Merge pull request #6107 from mruby/dependabot/github_actions/super-linter/super-linter-5.7.2
build(deps): bump super-linter/super-linter from 5.7.0 to 5.7.2
2023-12-06 15:58:47 +09:00
Yukihiro "Matz" Matsumoto 5a258f0872 Merge pull request #6109 from dearblue/fix-6108
Needs `cipop()` before crossing the C boundary
2023-12-06 15:57:16 +09:00
Yukihiro "Matz" Matsumoto abd26b7ca6 mruby-bin-mrbc/mrbc.c: replace mrbc_ prefix by mrb_ccontext
This is a most confusion file because it contained both `mrbc_` from
"mruby compiler" (e.g. mrbc_args) and `mrbc_` from "mruby compiler
context".
2023-12-06 15:54:33 +09:00
Yukihiro "Matz" Matsumoto 7be67d3acf mruby-bin-mirb: replace mrbc_ prefix by mrb_ccontext 2023-12-06 15:51:20 +09:00
Yukihiro "Matz" Matsumoto 72689b0b9c mruby-eval: replace mrbc_ prefix by mrb_ccontext 2023-12-06 15:49:21 +09:00
Yukihiro "Matz" Matsumoto 7e74dbeed3 mruby-bin-mruby: replace mrbc_ prefix by mrb_ccontext 2023-12-06 15:45:01 +09:00
Yukihiro "Matz" Matsumoto c36b212fa9 mruby-bin-debugger: replace mrbc_ prefix by mrb_ccontext 2023-12-06 15:41:15 +09:00
Yukihiro "Matz" Matsumoto a66c685c81 mruby-bin-debugger/mrdb.h: remove unnecessary struct declarations 2023-12-06 15:40:31 +09:00
Yukihiro "Matz" Matsumoto 6de4df3b31 parse.y: replace mrbc_ prefix by mrb_ccontext 2023-12-06 15:32:13 +09:00
Yukihiro "Matz" Matsumoto 9c2af6aaed load.c: replace mrbc_ prefix by mrb_ccontext 2023-12-06 15:29:02 +09:00
Yukihiro "Matz" Matsumoto 073a4f19f8 proc.h: update document in the comment (regarding compiler context) 2023-12-06 15:22:09 +09:00
Yukihiro "Matz" Matsumoto c5e3cbe4bf compile.h: stop using mrbc_ prefix for compiler context
Since it is confusing that the term `mrbc` stands for both "mruby
compiler" and "mruby compiler context" in the source code. Instead,
we use `mrb_ccontext` (stands for compiler context) prefix hereafter.

We choose `mrb_ccontext` because we have already used `mrb_context` (for
VM execusion context).
2023-12-06 15:22:08 +09:00
dependabot[bot] 7ac0b60255 build(deps): bump actions/labeler from 4 to 5
Bumps [actions/labeler](https://github.com/actions/labeler) from 4 to 5.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](https://github.com/actions/labeler/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/labeler
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-05 14:41:52 +00:00
dearblue ca9e8d91e4 Needs cipop() before crossing the C boundary
fix #6108
2023-12-05 22:03:38 +09:00
dependabot[bot] 7b74d22310 build(deps): bump super-linter/super-linter from 5.7.0 to 5.7.2
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.7.0 to 5.7.2.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.7.0...v5.7.2)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-04 14:03:16 +00:00
dearblue 4f1c1c16da Check fiber backward when switching with Fiber#transfer
Previously, if the caller of `Fiber#resume` had a C function call, an inconsistency would occur.
2023-12-04 22:32:57 +09:00
dearblue 42308c42b5 Fix CI misalignment between Fiber#resume and Fiber.yield
When a fiber switched by `Fiber.yield` is resumed by `Fiber#resume` by C, it is necessary to pop CI with `fiber_switch()`.
Previously, CI misalignment caused inconsistencies, including crashes, on the next `Fiber#resume`.
2023-12-04 22:32:57 +09:00
dearblue 568309b25a Propagating exceptions to the caller of Fiber#resume
Need to return control from `mrb_vm_exec()` to the caller if `Fiber#resume` was done from C.
2023-12-04 22:32:57 +09:00
dearblue aaa0f124c3 Restore the value of ci->cci with fiber_switch()
If `mrb_fiber_resume()` was called from a C function as a method definition, the mruby VM was not processed afterwards.

    Called Fiber.yield
    mrb_vm_exec()       <<-- returns from the function by CINFO_RESUMED
    fiber_switch()      <<-- this patch causes the value to return to its pre-call state
    mrb_fiber_resume()
    mrb_vm_exec()       <<-- previously, returns from the function immediately as it was CINFO_RESUMED
    ...
    main()
2023-12-04 22:32:57 +09:00
dearblue ef8b0b7ed8 Allows calling Fiber#resume from C
This patch is effectively reverts to the following:
  - commit dc65b1faf1 (#5782)
  - commit f4c4809750 (#5947)

Ref. #6063
2023-12-04 22:32:51 +09:00
dearblue ad4c35b022 Enhanced Fiber Testing
The main objective is to make sure that fiber can be handled from C.

Also, add a mechanism to detect that the mruby VM has stopped in the middle of the process.
If it stops halfway, the test will be terminated with `abort()`.
2023-12-04 21:48:23 +09:00
Yukihiro "Matz" Matsumoto 7f1ae1c344 mruby-method (method_to_s): avoid goto across declarations for C++ 2023-12-03 22:39:27 +09:00
Yukihiro "Matz" Matsumoto 90ec09a716 mruby-proc-ext (mrb_proc_source_location): support aliases 2023-12-03 22:38:31 +09:00
Yukihiro "Matz" Matsumoto 87453fb70b vm.c (CI_PROC_SET): consider alias proc 2023-12-03 22:38:31 +09:00
Yukihiro "Matz" Matsumoto 9eae7df26e mruby-method (method_to_s): _proc may be nil; add check 2023-12-03 22:38:31 +09:00
Yukihiro "Matz" Matsumoto e8da16cdf5 vm.c (exec_irep): need to support aliases 2023-12-03 22:38:30 +09:00
Yukihiro "Matz" Matsumoto 02f189cebc mruby-method (method_to_s): add origin name in the string representation 2023-12-03 22:38:30 +09:00
Yukihiro "Matz" Matsumoto f5bc82f267 mruby-method (method_to_s): avoid origin class like Object(Object) 2023-12-03 22:38:30 +09:00
Yukihiro "Matz" Matsumoto b52870b4c6 mruby-method: add const modifier to struct RProc* 2023-12-03 22:38:29 +09:00
Yukihiro "Matz" Matsumoto 9da0c7e1a4 Update .pre-commit-config.yaml 2023-12-03 09:39:33 +09:00
dearblue 9af6264d6b Implement Fiber#to_s method
If the filename and line number cannot be obtained, "(unknown):1" is used instead.

Also, the file name information of the terminated fiber cannot be retrieved and will be replaced as well.
This limitation is due to the fact that `cibase->proc` of the terminated fiber is collected by the GC.

```console
% bin/mruby -e 'p Fiber.new { p Fiber.current }.resume'
#<Fiber:0x82423bef0 -e:1 (resumed)>
#<Fiber:0x82423bef0 (unknown):1 (terminated)>
```
2023-12-01 21:30:16 +09:00
Yukihiro "Matz" Matsumoto ccdd81eb69 Merge pull request #6101 from dearblue/unwinding
Reorganization of unwinding at `break` / `return`.
2023-11-22 08:11:15 +09:00
Yukihiro "Matz" Matsumoto fdef59b3a1 AUTHORS: update entries [ci skip] 2023-11-21 09:37:58 +09:00
Yukihiro "Matz" Matsumoto 53a8472e5e mruby-kernel-ext/test: skip some tests that related to alias callee.
The last commit changed the behavior of aliases, and we no longer keep
the alias name symbol but the original name. Since this is a small
incompatibility from CRuby and it requires some memory to fix this, we
keep this issue right now.
2023-11-21 09:37:17 +09:00
Yukihiro "Matz" Matsumoto f2dc76e3b5 Change alias handling to avoid using mid in Env; ref 6098
Since `Env` objects are shared by Blocks/Procs in the same context,
making multiple aliases in one context screws up with alias names.
New implementation uses alias bodies (Procs) to refer new names.
As a side effect, `__callee__` stop working correctly for aliases.
To fix this `__callee__` problem, we need to keep alias method names in
`callinfo`, which consumes more memory. We are wondering that is worth
the compatibility.
2023-11-21 09:37:17 +09:00
Yukihiro "Matz" Matsumoto f6cbf6ac1a Merge pull request #6102 from mruby/dependabot/github_actions/super-linter/super-linter-5.7.0
build(deps): bump super-linter/super-linter from 5.6.1 to 5.7.0
2023-11-21 09:37:07 +09:00
Yukihiro "Matz" Matsumoto 9c1c9ba8e5 vm.c: rename local variable m to p
`m` usually stands for a method but this one was `struct RProc*`.
2023-11-19 23:21:05 +09:00
Yukihiro "Matz" Matsumoto 956379928c mruby-io/io.c: fix possible short integer overflow 2023-11-19 07:47:23 +09:00
Yukihiro "Matz" Matsumoto 698da0982f mruby-io/io.c: fix fsize_t and mrb_ssize mixture 2023-11-19 07:45:29 +09:00
dependabot[bot] ee7ea34b10 build(deps): bump super-linter/super-linter from 5.6.1 to 5.7.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.6.1 to 5.7.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.6.1...v5.7.0)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-16 14:28:54 +00:00
Yukihiro "Matz" Matsumoto 91b4da3a2b class.c: keep alias flag in proc object; fix #6098 2023-11-16 17:18:28 +09:00
Yukihiro "Matz" Matsumoto 9959d4fc66 range.c: use presym for symbol initialization 2023-11-16 16:30:40 +09:00
Yukihiro "Matz" Matsumoto a94005b740 range.c: use presym to initialize Range class 2023-11-16 16:27:57 +09:00
dearblue 2e881d3297 Reorganization of unwinding at break / return.
The unwinding process that has been done at each point in time is now done in a merged block after looking for the last ci to `break` / `return`.
2023-11-12 20:39:33 +09:00
Yukihiro "Matz" Matsumoto 431d9d8a12 mrbgems/full-core.gembox: use parentheses for method call expression 2023-11-12 19:01:08 +09:00
Yukihiro "Matz" Matsumoto 76d0ff9a45 error.c: use presym for error initialization 2023-11-11 23:49:32 +09:00
Yukihiro "Matz" Matsumoto 8e6f4a79a8 hash.c: use presym to initialize Hash class 2023-11-11 23:48:31 +09:00
Yukihiro "Matz" Matsumoto df1d397da5 numeric.c: use presym to initialize numeric classes 2023-11-11 23:48:31 +09:00
Yukihiro "Matz" Matsumoto 5084716e6b class.c: use presym to undefine Module methods 2023-11-11 23:48:23 +09:00
Yukihiro "Matz" Matsumoto d5a69ac8c7 proc.c: use presym to initialize Proc class 2023-11-07 21:40:45 +09:00
Yukihiro "Matz" Matsumoto e41bbaa67a class.c: move Proc class allocation to proc.c 2023-11-07 21:40:45 +09:00
Yukihiro "Matz" Matsumoto eb906bd4c1 array.c: use presyms to define the class 2023-11-07 21:40:44 +09:00
Yukihiro "Matz" Matsumoto 1dec82d82f object.c: use presyms to define classes 2023-11-07 21:40:44 +09:00
Yukihiro "Matz" Matsumoto 4fd63cfb9d kernel.c: use presym to define a module 2023-11-07 21:40:44 +09:00
Yukihiro "Matz" Matsumoto 82f6facaad Merge pull request #6097 from dearblue/fiber-new
Add a new `mrb_fiber_new()` with MRB_API
2023-11-07 21:40:31 +09:00
dearblue 1bb77170ec Add a new mrb_fiber_new() with MRB_API 2023-11-05 20:36:29 +09:00
Yukihiro "Matz" Matsumoto 9e50d67fe7 Merge pull request #6096 from mruby/dependabot/github_actions/super-linter/super-linter-5.6.1
build(deps): bump super-linter/super-linter from 5.6.0 to 5.6.1
2023-11-03 07:35:13 +09:00
dependabot[bot] 52ac930af3 build(deps): bump super-linter/super-linter from 5.6.0 to 5.6.1
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.6.0 to 5.6.1.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.6.0...v5.6.1)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-02 14:07:54 +00:00
Yukihiro "Matz" Matsumoto 587d93d5a5 Merge pull request #6095 from mruby/dependabot/github_actions/super-linter/super-linter-5.6.0
build(deps): bump super-linter/super-linter from 5.4.3 to 5.6.0
2023-11-02 13:21:35 +09:00
Yukihiro "Matz" Matsumoto bc012deef9 object.c (mrb_eql): avoid mrb_funcall_argv() when possible 2023-11-02 13:20:10 +09:00
Yukihiro "Matz" Matsumoto 7db4050040 enum.c: use presym 2023-11-02 13:15:45 +09:00
Yukihiro "Matz" Matsumoto 8c068c57c8 Merge pull request #6092 from dearblue/lockfile
Get from local only if there is no default branch name
2023-11-02 12:07:56 +09:00
Yukihiro "Matz" Matsumoto 1e3d47760f Merge pull request #6090 from LanzaSchneider/patch-1
fix(class.c): typo in format specifiers
2023-11-02 08:20:39 +09:00
Yukihiro "Matz" Matsumoto 8708186692 Merge pull request #6091 from dearblue/binding.5
Fixed acquisition of wrong target class in `Kernel#binding`
2023-11-01 23:05:50 +09:00
Yukihiro "Matz" Matsumoto c99b67db65 gc.c: use presym for GC initialization 2023-11-01 22:24:57 +09:00
Yukihiro "Matz" Matsumoto c080d16150 string.c: use presym to define String class 2023-11-01 22:23:35 +09:00
Yukihiro "Matz" Matsumoto 571cb54f38 compar.c: remove unused file 2023-11-01 22:21:59 +09:00
dependabot[bot] ccf37b00aa build(deps): bump super-linter/super-linter from 5.4.3 to 5.6.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.4.3 to 5.6.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.4.3...v5.6.0)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-31 14:26:22 +00:00
dearblue 8284234229 Get from local only if there is no default branch name
The branch name of the cloned repository should be determined by the build configuration file.

fixes #6087
2023-10-28 19:02:50 +09:00
dearblue 0b25c9d224 Fixed acquisition of wrong target class in Kernel#binding
fixed #6089
2023-10-28 18:24:41 +09:00
Lanza 4ae0bacc6e fix(class.c): typo in format specifiers 2023-10-28 13:47:05 +08:00
Yukihiro "Matz" Matsumoto 552944b34e Merge pull request #6088 from jbampton/format-markdown-table
Standardize Markdown table format
2023-10-27 07:46:14 +09:00
John Bampton bbd5701617 Standardize Markdown table format 2023-10-26 16:15:57 +10:00
Yukihiro "Matz" Matsumoto c1feb41828 Merge pull request #6056 from dearblue/build/host-shared
Brush up `build_config/host-shared.rb` file
2023-10-26 14:23:49 +09:00
Yukihiro "Matz" Matsumoto ac73793a8f range.c: use mrb_define_method_id() which directly use symbols 2023-10-25 22:01:54 +09:00
dearblue 41cce1561f Brush up build_config/host-shared.rb file
Summary:

  - VisualC++ does not supported.
  - `cc.flags` must maintain array objects.
2023-10-25 21:58:28 +09:00
Yukihiro "Matz" Matsumoto 7a08c7042f string.c: move __ENCODING__ from kernel.c 2023-10-25 15:05:10 +09:00
Yukihiro "Matz" Matsumoto f85a3aff2b Merge pull request #6086 from yujiyokoo/add-wii-build-config
Add build config for Nintendo Wii
2023-10-23 17:34:33 +09:00
Yukihiro "Matz" Matsumoto 279e100ad5 Merge pull request #6085 from dearblue/define_installer.1
Fixed `MRuby::Build#define_installer`
2023-10-23 15:36:14 +09:00
Yukihiro "Matz" Matsumoto bba659f174 Merge pull request #6083 from mruby/dependabot/github_actions/super-linter/super-linter-5.4.3
build(deps): bump super-linter/super-linter from 5.4.0 to 5.4.3
2023-10-23 15:34:17 +09:00
Yukihiro "Matz" Matsumoto 461c97225e LICENSE: remove the end date of copyright notice; close #6080 2023-10-23 15:31:34 +09:00
Yukihiro "Matz" Matsumoto e7e47bb683 AUTHORS: update entries [ci skip] 2023-10-23 15:29:23 +09:00
Yukihiro "Matz" Matsumoto 0443f14fd0 array.c,hash.c,numeric.c,string.c: use mrb_define_method_id()
For primary class libraries.
2023-10-23 15:23:08 +09:00
Yukihiro "Matz" Matsumoto 8ad825dc3b class.c,kernel.c,object.c: use mrb_define_method_id()
Instead of mrb_define_method(), so that symbol resolution can be done in
compile-time.
2023-10-23 15:18:26 +09:00
Yukihiro "Matz" Matsumoto 0b8daabf27 object.c: fix wrong ISO section numbers 2023-10-23 12:26:51 +09:00
Yukihiro "Matz" Matsumoto fe6f9faba4 vm.c: reduce number of check_method_noarg() calls 2023-10-22 22:04:58 +09:00
Yuji Yokoo 2b9287dbc4 Add build_config.rb for Nintendo Wii 2023-10-22 00:07:22 +10:30
dearblue 9b0d516310 Fixed MRuby::Build#define_installer
Symbolic links were created with absolute paths, but to cope with path fluctuations between build and reference, they are now relative paths.

ref. #6084
2023-10-21 19:42:26 +09:00
dependabot[bot] 3c5aa936c7 build(deps): bump super-linter/super-linter from 5.4.0 to 5.4.3
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.4.0 to 5.4.3.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.4.0...v5.4.3)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-18 14:50:06 +00:00
Yukihiro "Matz" Matsumoto 10d4a4278e class.c: make keyword_max mrb_int; ref #4754
Which is compared to other mrb_int.
2023-10-17 13:27:19 +09:00
Yukihiro "Matz" Matsumoto 9553284480 Merge pull request #6081 from dearblue/open-x
Add "x" mode option for `IO.open`
2023-10-17 13:27:07 +09:00
dearblue 88bc8c9144 Add "x" mode option for IO.open
From CRuby 2.6 feature.

This is the "x" mode (`O_EXCL`; exclusive create) of `fopen(3)` introduced in C11.

ref. https://bugs.ruby-lang.org/issues/11258
2023-10-15 16:41:48 +09:00
dearblue 782fd7e014 Integrate error handling for IO.open 2023-10-15 16:32:01 +09:00
Yukihiro "Matz" Matsumoto dec81fde4a Merge pull request #6079 from jbampton/fix-case-of-mruby
include/mruby/version.h: change `MRuby` to `mruby`
2023-10-15 05:16:04 +07:00
Yukihiro "Matz" Matsumoto 244156af2a Merge pull request #6078 from jbampton/fix-indent
Fix indentation in two Ruby files
2023-10-15 05:15:38 +07:00
John Bampton db20a19711 include/mruby/version.h: change MRuby to mruby 2023-10-14 19:13:49 +10:00
John Bampton a83d7d3510 Fix indentation in two Ruby files 2023-10-14 18:52:30 +10:00
Yukihiro "Matz" Matsumoto 4656ea5ccd Merge pull request #6000 from jbampton/update-docker-files
docker: use less image layers and update compose version
2023-10-14 05:36:04 +07:00
Yukihiro "Matz" Matsumoto 56a46cdff5 Merge pull request #6075 from mruby/dependabot/github_actions/super-linter/super-linter-5.4.0
build(deps): bump super-linter/super-linter from 5.3.1 to 5.4.0
2023-10-14 05:34:49 +07:00
Yukihiro "Matz" Matsumoto c22fbb2aa7 Merge pull request #6076 from dearblue/fiber-unwinding
Fixed unwinding block that could point to invalid PC
2023-10-13 20:33:03 +07:00
Yukihiro "Matz" Matsumoto 3e20c5c9b3 Merge pull request #6069 from dearblue/MRUBY_PACKAGE_DIR
Corrected wrong `MRUBY_PACKAGE_DIR`
2023-10-13 16:04:25 +07:00
Yukihiro "Matz" Matsumoto 4c696ed9e3 array.c: set array size limitation again
Unlike strings, arrays occupies more memory. It is still arguable
whether the current limit (131072) is appropriate.
2023-10-13 18:01:21 +09:00
Yukihiro "Matz" Matsumoto 1321e33f08 mruby-range-ext: implement __empty_range? in C 2023-10-13 16:59:21 +09:00
Yukihiro "Matz" Matsumoto deae227dff mruby-range-ext: update overlap? to handle empty ranges
The code is taken from ActiveSupport (Rails).
2023-10-12 13:40:28 +09:00
Yukihiro "Matz" Matsumoto 3277cc9ce1 numeric.c (int_to_s): avoid mrb_get_args() 2023-10-11 20:32:09 +09:00
Yukihiro "Matz" Matsumoto 717f91e5c6 array.c (mrb_ary_last): avoid mrb_get_args() 2023-10-11 20:31:23 +09:00
Yukihiro "Matz" Matsumoto fae8e55396 pool.c (mrb_pool_realloc): add comments in reallocation code 2023-10-11 13:39:53 +09:00
Yukihiro "Matz" Matsumoto 64e08c6d99 pool.c: add cast to void* 2023-10-11 13:38:59 +09:00
Yukihiro "Matz" Matsumoto 5d53c2b951 pool.c: remove unused mrb_pool_can_realloc() 2023-10-10 22:31:34 +09:00
Yukihiro "Matz" Matsumoto a538837fb1 pool.c (mrb_pool_realloc): do nothing if realloc() tries to shrink 2023-10-10 22:17:30 +09:00
dearblue e7828bac4d Fixed unwinding block that could point to invalid PC
Switching back from a fiber with an exception could point to an invalid PC.
The investigation was inspired by #6060.
2023-10-10 21:29:38 +09:00
Yukihiro "Matz" Matsumoto 42a621b42e pool.c: small refactoring regarding local variable declarations 2023-10-10 14:49:19 +09:00
dependabot[bot] 66ce1c03f4 build(deps): bump super-linter/super-linter from 5.3.1 to 5.4.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.3.1 to 5.4.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.3.1...v5.4.0)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-09 14:09:08 +00:00
Yukihiro "Matz" Matsumoto 097681b4d4 mruby-pack: unpack "b/B" should limit result size 2023-10-09 22:39:44 +09:00
Yukihiro "Matz" Matsumoto 861f8bdfa9 mruby-enumerator: add Enumerator#size
If the original object responds to `size` method, `Enumerator#size` calls
that method, otherwise return `nil`. CRuby returns the exact size for
more cases (e.g. Enumerable::Lazy#size), but mruby has more limitations.
2023-10-09 22:39:43 +09:00
Yukihiro "Matz" Matsumoto 49f86f19b2 mruby-enumerator: put "__" prefix to internal enumerator_block_call() 2023-10-09 22:39:43 +09:00
Yukihiro "Matz" Matsumoto 735fa246bf mruby-enumerator: remove internal attribute methods; ref #6068
Removed methods: obj, args, kwd, meth, fib.
2023-10-09 22:39:43 +09:00
Yukihiro "Matz" Matsumoto 298155d59e Merge pull request #6071 from jbampton/pre-commit-autoupdate 2023-10-06 23:58:45 +09:00
John Bampton 903ffb1584 pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2023-10-04 01:17:23 +10:00
John Bampton 24ac7a547a Fix spelling 2023-10-04 01:17:23 +10:00
Yukihiro "Matz" Matsumoto 83d12f8d52 vm.c: GCC does not provide __has_feature() 2023-10-03 01:05:26 +09:00
Yukihiro "Matz" Matsumoto b9536ea35f vm.c: use smaller MRB_CALL_LEVEL_MAX with address sanitizer; fix #6068
Since ASAN uses lower memory bound. The other ideas to address #6068
might follow, e.g. removing `args=` from Enumerator.
2023-10-02 21:15:54 +09:00
Yukihiro "Matz" Matsumoto 771b56c796 mruby-socket: hide internal method new_with_prelude
- rename new_with_prelude to _new_with_prelude
- take a block instead of proc
2023-09-28 14:36:42 +09:00
Yukihiro "Matz" Matsumoto 67f1f0997c Merge pull request #6070 from komainu8/demotion-mrb_f_raise-from-mrb_api
Demotion mrb_f_raise() in kernel.c from MRB_API too
2023-09-28 14:22:19 +09:00
Yukihiro "Matz" Matsumoto 10aab4cc1b proc.c: prohibit direct Proc allocation() like CRuby; ref #6065 2023-09-28 11:37:46 +09:00
Yukihiro "Matz" Matsumoto d298da8e72 vm.c (eval_under): check if irep is NULL; fix #6065 2023-09-28 11:37:07 +09:00
Yukihiro "Matz" Matsumoto 0e98508c33 string.c (mrb_string_value_cstr): RSTR_PTR(s) may be NULL; fix #6067 2023-09-28 09:26:02 +09:00
Yukihiro "Matz" Matsumoto 4c7fab6126 string.c (check_null_byte): str may point NULL buffer; ref #6067 2023-09-28 09:24:30 +09:00
Horimoto Yasuhiro d55cec41eb Demotion mrb_f_raise() in kernel.c from MRB_API
The prototype declaration of mrb_f_raise() has arleady demoted from
MRB_API in a below commit.

https://github.com/mruby/mruby/commit/0898ce982eea706c9a7b814280cdda09e82abe17

However, the entity of mrb_f_raise() in kernel.c is set MRB_API yet.
Therefore, mruby occures build error with MSVC(in Visual Studio 2022) as below.

https://github.com/groonga/groonga/actions/runs/6310140553/job/17131485675#step:11:2067

The cause of the above error that we define both mrb_f_raise() with
MRB_API and mrb_f_raise() without MRB_API.
2023-09-28 09:17:54 +09:00
Yukihiro "Matz" Matsumoto 0ac917e228 Revert "mrbgems/mruby-struct/src/struct.c: use direct array access"
This reverts commit 159ff5b28d.
Fix #6066
2023-09-28 07:40:31 +09:00
Yukihiro "Matz" Matsumoto a80f394d97 mruby-array-ext (ary_rotate_bang): mrb_ary_modify may alter buf address 2023-09-27 18:37:38 +09:00
Yukihiro "Matz" Matsumoto 629a6839fd mruby-array-ext (ary_compact_bang): skip check that is always true 2023-09-27 18:32:44 +09:00
Yukihiro "Matz" Matsumoto f65229d103 mruby-array-ext (ary_compact_bang): mrb_ary_modify may alter buf address 2023-09-27 18:30:43 +09:00
Yukihiro "Matz" Matsumoto 7d3679dfc8 mruby-string-ext: refactoring
- raise exception in utf8code
- str_codepoints() use mrb_utf8len_table directly
2023-09-27 18:11:19 +09:00
Yukihiro "Matz" Matsumoto 5705d884ce mruby-string-ext (utf8code): change arguments to point at the end 2023-09-27 18:08:12 +09:00
dearblue c805d4dbba Corrected wrong MRUBY_PACKAGE_DIR
ref. #6064
2023-09-25 21:50:31 +09:00
Yukihiro "Matz" Matsumoto 2e3b482aa9 array.c, string.c: remove length limits on UNIX-ish OSes
- Linux
- MacOS
- FreeBSD
- OpenBSD

Send us a pull-request if you want to add your favorite OS here.
The size limitation will be done by malloc(3) on those OSes.
2023-09-23 19:57:44 +09:00
Yukihiro "Matz" Matsumoto 15bb6a9f9b mruby-string-ext: fix a typo; ref #6016 2023-09-23 11:44:15 +09:00
Yukihiro "Matz" Matsumoto 8a538c40c0 mruby-string-ext: implement core part of codepoints in C; close #6061 2023-09-23 11:36:20 +09:00
Yukihiro "Matz" Matsumoto 2db80b81c9 Merge pull request #6062 from mruby/dependabot/github_actions/super-linter/super-linter-5.3.1
build(deps): bump super-linter/super-linter from 5.3.0 to 5.3.1
2023-09-23 00:04:07 +09:00
Yukihiro "Matz" Matsumoto 9ee7edc1ac mruby-fiber/fiber.c (fiber_switch): check c->cibase->proc env is NULL
ref #6060
2023-09-22 19:36:33 +09:00
dependabot[bot] ed30e2e568 build(deps): bump super-linter/super-linter from 5.3.0 to 5.3.1
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.3.0 to 5.3.1.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.3.0...v5.3.1)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-21 14:29:25 +00:00
Yukihiro "Matz" Matsumoto 0730bda60e mruby-range-ext: add tests for Range#overlap? 2023-09-21 15:28:56 +09:00
Yukihiro "Matz" Matsumoto 384d0e2d21 mruby-range-ext: implement Range#overlap? method
Which is implemented in CRuby recently.
2023-09-21 15:28:06 +09:00
Yukihiro "Matz" Matsumoto 393aaada64 mruby-pack/pack.c (read_tmpl): fix out-of-bound access with templates 2023-09-20 09:51:22 +09:00
Yukihiro "Matz" Matsumoto b064d7e547 mruby-time/time.c (time_alloc_time): need to handle negative time_t 2023-09-19 14:22:49 +09:00
Yukihiro "Matz" Matsumoto ec3baece4f vm.c (catch_handler_find): check if irep is NULL; fix #6052 2023-09-19 14:22:49 +09:00
Yukihiro "Matz" Matsumoto 75e8a72649 vm.c (CI_PROC_SET): check whether p->body.irep is not NULL; ref #6052 2023-09-19 14:22:49 +09:00
Yukihiro "Matz" Matsumoto 8afb73f3e2 mruby-socket/socket.rb: should not call unix_path for non UNIX Addrinfo
ref #6051
2023-09-19 14:22:49 +09:00
Yukihiro "Matz" Matsumoto 52082ba399 mruby-socket/socket.c (mrb_addrinfo_unix_path): check sockaddr type
`sockaddr` should be a string; fix #6051
2023-09-19 14:22:49 +09:00
Yukihiro "Matz" Matsumoto 40f08e22f1 Merge pull request #6058 from mruby/dependabot/github_actions/super-linter/super-linter-5.3.0
build(deps): bump super-linter/super-linter from 5.2.2 to 5.3.0
2023-09-19 14:05:20 +09:00
dependabot[bot] 38113d2524 build(deps): bump super-linter/super-linter from 5.2.2 to 5.3.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.2.2 to 5.3.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.2.2...v5.3.0)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-18 14:15:49 +00:00
Yukihiro "Matz" Matsumoto 39d805e1da Merge pull request #6055 from dearblue/libmruby-name
Fix libmruby name for VisualC++
2023-09-18 15:47:41 +09:00
Yukihiro "Matz" Matsumoto 3ce5f2df8b Merge pull request #6054 from dearblue/mruby-config-plus
Extends `bin/mruby-config`
2023-09-17 18:23:54 +09:00
dearblue 7112db9fba Extends bin/mruby-config
Added output for C++ and Assembly, ObjectiveC.
2023-09-17 17:48:36 +09:00
dearblue 7ac536e3ca Fix libmruby name for VisualC++ 2023-09-17 17:42:25 +09:00
Yukihiro "Matz" Matsumoto 74949b3e7e Merge pull request #6053 from dearblue/gitattributes
Add `.gitattributes` for newline code normalization
2023-09-17 16:36:28 +09:00
dearblue 078b5ccaff Add .gitattributes for newline code normalization
References:
  - [Git] リポジトリで改行コードを正規化する
    https://zenn.dev/murnana/articles/eol-and-gitattributes
  - 行終端を処理するようGitを設定する - GitHub Docs
    https://docs.github.com/ja/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
2023-09-17 13:52:48 +09:00
Yukihiro "Matz" Matsumoto 4810706ccc vm.c: refactor redundant if conditions 2023-09-16 14:49:58 +09:00
Yukihiro "Matz" Matsumoto f041d3a5d5 Merge pull request #6047 from mruby/dependabot/github_actions/super-linter/super-linter-5.2.2
build(deps): bump super-linter/super-linter from 5.2.1 to 5.2.2
2023-09-15 13:35:03 +09:00
Yukihiro "Matz" Matsumoto e8254eda42 gc.c: update comment for flexible array members (C++ incompatible) [ci skip] 2023-09-15 13:33:52 +09:00
Yukihiro "Matz" Matsumoto 4fe8b074bb gc.c: remove prev link from mrb_heap_page 2023-09-15 13:33:52 +09:00
Yukihiro "Matz" Matsumoto 44b5153360 gc.c: revert af68de52dddd80afe1620c45680eb055767a412f
The change increased memory consumption significantly
2023-09-15 13:33:52 +09:00
Yukihiro "Matz" Matsumoto 22e74a7ee5 gc.c: experiment before removing page->prev link 2023-09-15 13:33:52 +09:00
Yukihiro "Matz" Matsumoto 9b90fd4f60 gc.c (incremental_sweep_phase): rebuild free pages link only if needed 2023-09-15 13:33:52 +09:00
Yukihiro "Matz" Matsumoto 9f840e111a gc.c: inline unlink_heap_page which was called only once 2023-09-15 13:33:52 +09:00
Yukihiro "Matz" Matsumoto 0f69e93664 gc.c: inline link_heap_page which was called once 2023-09-15 13:33:51 +09:00
Yukihiro "Matz" Matsumoto 117fcfc8e9 gc.c: stop using bidirectional link for free_heaps
Reduce size of the heap pages again; ref #6041
2023-09-15 13:33:51 +09:00
Yukihiro "Matz" Matsumoto e1c96b709a Merge pull request #6045 from dearblue/presym-escape.2
Fixes escape sequence bug and enhancements in Presym scanning
2023-09-15 13:11:26 +09:00
dependabot[bot] d8ad654460 build(deps): bump super-linter/super-linter from 5.2.1 to 5.2.2
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.2.1 to 5.2.2.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.2.1...v5.2.2)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-13 14:08:56 +00:00
Yukihiro "Matz" Matsumoto d708931b10 gc.c: revert 38b9a25e83
Fix #6041
2023-09-09 14:31:13 +09:00
dearblue 25f360803c Fixes escape sequence bug and enhancements in Presym scanning
In #6011, a hexadecimal escape sequence followed by a hexadecimal character would cause a compile error.
Also, avoid using "Numbered Parameter" which older Ruby does not have (e.g. AppVeyor).

ref. #6044
2023-09-08 22:57:24 +09:00
Yukihiro "Matz" Matsumoto 5eddccf89a gc.c: remove unnecessary symbol local variables 2023-09-08 14:15:54 +09:00
Yukihiro "Matz" Matsumoto d7b2e3ab14 mruby-compiler/parse.y: add print name for identifier tokens 2023-09-05 23:29:24 +09:00
Yukihiro "Matz" Matsumoto e8841fbf58 gc.h: move mrb_heap_page definition to gc.c 2023-09-05 23:29:24 +09:00
Yukihiro "Matz" Matsumoto acf5b74daa vm.c (ary_new_from_regs): avoid mrb_ary_push()
Use mrb_ary_new_from_values(), which is faster instead.
2023-09-05 23:29:23 +09:00
Yukihiro "Matz" Matsumoto 9914243d68 vm.c: use direct array access if possible 2023-09-05 23:29:23 +09:00
Yukihiro "Matz" Matsumoto 0eef05cc00 array.c (mrb_ary_to_s): use direct array access 2023-09-05 23:29:23 +09:00
Yukihiro "Matz" Matsumoto 159ff5b28d mrbgems/mruby-struct/src/struct.c: use direct array access
Unless we need boundary check, we don't need to use mrb_ary_ref().
2023-09-05 23:29:23 +09:00
Yukihiro "Matz" Matsumoto 1578f4bb99 mruby-data/data.c: use direct array access
Unless we need boundary check, we don't need to use mrb_ary_ref()
2023-09-05 23:29:23 +09:00
Yukihiro "Matz" Matsumoto 4cf810e4ea Merge pull request #6042 from mruby/dependabot/github_actions/actions/checkout-4
build(deps): bump actions/checkout from 3 to 4
2023-09-05 23:28:55 +09:00
dependabot[bot] f893c18088 build(deps): bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-04 14:59:02 +00:00
Yukihiro "Matz" Matsumoto 792459e63d Merge pull request #6040 from dearblue/puts-eol
Convert to string before output in `puts`
2023-08-30 22:30:58 +09:00
Yukihiro "Matz" Matsumoto a20fbe54b9 mrbgems/mruby-test/mrbgem.rake: stop mrb isolation for each test file
It reduces the number of `mrb_state` initialization in `mrbtest`. But at
the same time, each test in a gem shares states (classes, methods, etc.)
2023-08-30 18:32:48 +09:00
Yukihiro "Matz" Matsumoto a67f32561f test/t/codegen.rb: test 127 arguments with break not next
In addition, avoid using undefined constant `A` because it terminates
actual execution by `NameError`.
2023-08-30 18:28:59 +09:00
dearblue 301bcc636e Convert to string before output in puts
For example, evaluating `puts nil` raised `NoMethodError` before.
2023-08-29 21:59:09 +09:00
Yukihiro "Matz" Matsumoto a17fdb7481 AUTHORS: update entries [ci skip] 2023-08-28 10:59:29 +09:00
Yukihiro "Matz" Matsumoto b85b6822b2 hash.c (mrb_hash_aset): avoid slower mrb_get_args() 2023-08-26 22:30:20 +09:00
Yukihiro "Matz" Matsumoto 0578e518e6 src/vm.c: adjust mrb_gc_protect() for kdict argument
It was called repeatedly in some cases.
2023-08-25 23:12:08 +09:00
Yukihiro "Matz" Matsumoto 1e385692d1 Rakefile: remove default build target directories in deep_clean
Ref #6038, #6032
2023-08-24 12:57:27 +09:00
Yukihiro "Matz" Matsumoto f43f2fc8f3 mruby-socket/socket.c: use internal name for instance variables
For Socket::Option objects.
2023-08-23 11:27:03 +09:00
Yukihiro "Matz" Matsumoto 2160be7db7 mruby-socket/socket.rb: remove unused canonname accessor 2023-08-22 23:27:08 +09:00
Yukihiro "Matz" Matsumoto 95e09c0c95 mruby-method: implement Kernel#singleton method in C
- Also fixes error message inconsistency
- Avoid unnecessary method object allocation if possible
2023-08-22 10:53:52 +09:00
Yukihiro "Matz" Matsumoto a16b2b0e12 Merge pull request #6038 from dearblue/revert-6032-update-rake-task-clean
Revert "Rake: update task clean to remove `bin` and `build` folders"
2023-08-21 22:28:17 +09:00
Yukihiro "Matz" Matsumoto 182c06a46b codedump.c: fflush() output 2023-08-21 17:27:03 +09:00
Yukihiro "Matz" Matsumoto 982a378425 mruby-print/print.c: stop flushing every time in printstr
Instead, call `fflush` at the end of `print` method, if stdout is
connected to a tty.
2023-08-21 12:47:44 +09:00
Yukihiro "Matz" Matsumoto 192e6e3b9f mruby-print/print.c: remove internal method __printstr
Instead, implement `print` method in C and use it from mrblib/print.rb
2023-08-21 12:47:44 +09:00
dearblue 14a0cc4b7b Revert "Rake: update task clean to remove bin and build folders" 2023-08-18 22:36:21 +09:00
Yukihiro "Matz" Matsumoto bd41dfbcb9 mruby-socket/socket.c (socket_option_inspect): readable family name
Print readable name for know protocol families.
2023-08-17 10:54:59 +09:00
Yukihiro "Matz" Matsumoto 2fb478db76 Merge pull request #6037 from mruby/dependabot/github_actions/super-linter/super-linter-5.2.1
build(deps): bump super-linter/super-linter from 5.2.0 to 5.2.1
2023-08-17 10:53:10 +09:00
dependabot[bot] 1dbfeab2df build(deps): bump super-linter/super-linter from 5.2.0 to 5.2.1
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.2.0 to 5.2.1.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.2.0...v5.2.1)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-16 14:29:51 +00:00
Yukihiro "Matz" Matsumoto 58e10f16e9 mruby-socket/socket.c: include Socket::Constants in C init 2023-08-16 13:23:56 +09:00
Yukihiro "Matz" Matsumoto 1d7c00e920 mruby-socket/socket.c: implement whole Socket::Option class in C
`mruby-pack` gem no longer needed.
2023-08-15 15:29:36 +09:00
Yukihiro "Matz" Matsumoto 83b6a63c16 mruby-socket/socket.c: implement accessors in C 2023-08-15 07:35:29 +09:00
Yukihiro "Matz" Matsumoto e209f0a220 mruby-socket/socket.c (socket_option_init): add integer type checks 2023-08-15 07:31:04 +09:00
Yukihiro "Matz" Matsumoto 892596d372 mruby-socket/socket.c: implement Socket::Option#initialize in C 2023-08-14 23:32:22 +09:00
Yukihiro "Matz" Matsumoto 2a3af5dc67 Merge pull request #6036 from jbampton/add-pre-commit-hook
pre-commit: add hook `forbid-submodules`
2023-08-13 22:05:20 +09:00
Yukihiro "Matz" Matsumoto d53aa54e3b Merge pull request #6035 from jbampton/fix-super-linter-path
Fix Super-Linter action path
2023-08-13 22:04:33 +09:00
Yukihiro "Matz" Matsumoto 3310e10318 mruby-test/mrbgem.rake: fix mrb_state handling bug
You should not pass values from different mrb_state. No one has ever
used test_args for gems, the issue has not been realized.
2023-08-13 20:02:01 +09:00
John Bampton 6ac6d690dd pre-commit: add hook forbid-submodules
https://github.com/pre-commit/pre-commit-hooks#forbid-submodules

If you want to ban them entirely use forbid-submodules.

Really this is just one extra check or test we can have.
2023-08-13 11:17:22 +10:00
John Bampton 9051367fd8 Fix Super-Linter action path
https://github.com/super-linter/super-linter

https://github.com/marketplace/actions/super-linter

They changed the organization name to "super-linter" from "github" for the Super-Linter Action
2023-08-13 11:03:28 +10:00
Yukihiro "Matz" Matsumoto 4769a474a4 mruby-test/mrbgem.rake: remove unnecessary arena_index 2023-08-12 23:43:48 +09:00
Yukihiro "Matz" Matsumoto 435cce7efd mruby-socket/socket.c: use mrb_iv_get() instead of accessors 2023-08-12 20:19:32 +09:00
Yukihiro "Matz" Matsumoto c675c0cbb1 mruby-socket/socket.c: use mrb_ensure_int_type() 2023-08-11 23:10:02 +09:00
Yukihiro "Matz" Matsumoto 34e7a0ef4b mruby-socket/socket.c (socket_option_class): a new function
To retrieve Socket::Option class from C functions.
2023-08-11 23:07:38 +09:00
Yukihiro "Matz" Matsumoto 0864f44c24 mruby-socket/socket.c: use mrb_obj_new() instead of mrb_obj_funcall() 2023-08-09 18:45:42 +09:00
Yukihiro "Matz" Matsumoto 08a780edd6 mruby-socket/socket.c: rename a local variable for clarity (res0 -> addr) 2023-08-09 14:33:14 +09:00
Yukihiro "Matz" Matsumoto edf3f1226c mruby-socket/socket.c: pass klass to gen_addrinfo 2023-08-09 14:33:14 +09:00
Yukihiro "Matz" Matsumoto 9e37a490f8 mruby-socket/socket.c: narrow local variable scope 2023-08-09 14:33:14 +09:00
Yukihiro "Matz" Matsumoto 10ed2ea03b mruby-socket/socket.c: use z! argument specifier rather than o
`z!` specifier checks if the argument is NULL terminated string or nil.
2023-08-09 14:33:14 +09:00
Yukihiro "Matz" Matsumoto 9d370e0851 mruby-socket/socket.c: ensure struct addrinfo to be freed
Instead of referring the last addrinfo via Addrinfo's class variable, we
use `mrb_ensure()` from `mruby-error` gem.
2023-08-09 13:51:25 +09:00
Yukihiro "Matz" Matsumoto 12bd395012 fmt_fp.c: revert 647324ad45c0d779a3c36f0bb7955b8b8fc9f491
C++ complier does not allow jump across local variable declaration, even
if we don't access those variables after the destination label.
2023-08-08 11:24:15 +09:00
Yukihiro "Matz" Matsumoto 8591211494 dump.c (mrb_dump_irep): remove a function which only delegates 2023-08-08 11:24:14 +09:00
Yukihiro "Matz" Matsumoto ceb5086eb3 fmt_fp.c: unify returning code 2023-08-08 11:24:14 +09:00
Yukihiro "Matz" Matsumoto 7e865aec51 mruby-bigint/bigint.c: remove unused mrb_bint_new() 2023-08-08 11:24:14 +09:00
Yukihiro "Matz" Matsumoto a22ea766e2 mruby-numeric-ext/numeric_ext.c: use local variables. 2023-08-08 11:24:14 +09:00
Yukihiro "Matz" Matsumoto 5de3be1bee mruby-dir/dir.c (mrb_di_getwd): reduce buffer allocation size
Instead of allocating `MAXPATHLEN` buffer string at the beginning,
allocate smaller (64 bytes) buffer, then resize it if needed. The
allocating max size is safe but consumes more memory.
2023-08-08 11:24:14 +09:00
Yukihiro "Matz" Matsumoto a2649652f1 mruby-os-memsize/memsize.c: fix irep size calculation
Need to count the following as well:

- size of pool values
- size of reps array
2023-08-02 07:04:35 +09:00
Yukihiro "Matz" Matsumoto 1bc8ef903e Merge pull request #6032 from jbampton/update-rake-task-clean
Rake: update task clean to remove `bin` and `build` folders
2023-07-31 10:42:01 +09:00
Yukihiro "Matz" Matsumoto 0af6f8ff57 Merge pull request #6033 from jbampton/file-sorter-unique
pre-commit: file-contents-sorter ensure each line is unique
2023-07-30 18:30:26 +09:00
John Bampton a2785a8180 pre-commit: file-contents-sorter ensure each line is unique
https://github.com/pre-commit/pre-commit-hooks#file-contents-sorter
2023-07-30 04:25:38 +10:00
John Bampton a94a8b1cf0 Rake: update task clean to remove bin and build folders 2023-07-30 03:51:48 +10:00
Yukihiro "Matz" Matsumoto bbd4edc607 mruby-data/data.c (mrb_data_ref): remove code duplication 2023-07-29 08:42:25 +09:00
Yukihiro "Matz" Matsumoto 8d2f9b3d12 mruby-data/data.c: skip inefficient env for first some accessors 2023-07-28 23:45:25 +09:00
Yukihiro "Matz" Matsumoto 1e1184f62d mruby-pack/pack.c (read_tmpl): should consume skips in the function 2023-07-28 17:05:49 +09:00
Yukihiro "Matz" Matsumoto 0542d6bad4 debug.c (mrb_packed_int_encode): remove end argument
The function requires the buffer bigger than `mrb_packed_int_len()`
anyway, so we don't need boundary checks for each iteration. Should
makes the function a little bit faster.
2023-07-28 17:05:38 +09:00
Yukihiro "Matz" Matsumoto 5b2056efda Merge pull request #6031 from jbampton/pre-commit-autoupdate
Run `pre-commit autoupdate` and update `codespell.txt`
2023-07-25 10:57:03 +09:00
John Bampton 0464ca3870 Run pre-commit autoupdate 2023-07-24 22:26:53 +10:00
John Bampton b66b67beda Update codespell.txt 2023-07-24 22:25:03 +10:00
Yukihiro "Matz" Matsumoto 1535e031df mruby-pack/pack.c (read_tmpl): direct return from skipping directives
We used to read counts after spaces, for example `pack("j 4")` read `4`
as counts after a space.
2023-07-24 18:03:39 +09:00
Yukihiro "Matz" Matsumoto a5a13ad35f mruby-pack/pack.c (read_tmpl): read_tmpl to return dir
Use return value for directives information.
2023-07-24 18:03:39 +09:00
Yukihiro "Matz" Matsumoto 8a3d52f494 mruby-pack/pack.c (read_tmpl): rename PACK_DIR_INVALID
The value is used for spaces and comments, so the term "skip" is more
appropriate than "invalid".
2023-07-24 18:03:38 +09:00
Yukihiro "Matz" Matsumoto e17f3256c6 mruby-pack/pack.c (read_tmpl): support comments in derectives 2023-07-24 18:03:38 +09:00
Yukihiro "Matz" Matsumoto 5d0016186f numeric.c (mrb_float_to_str): avoid memcpy() 2023-07-24 18:03:38 +09:00
Yukihiro "Matz" Matsumoto 0eceadd037 mruby-pack/test/pack.rb: test B/b directives 2023-07-24 18:03:38 +09:00
Yukihiro "Matz" Matsumoto e7021f190a mruby-pack/pack.c (pack_bstr): support B/b directives 2023-07-24 18:03:38 +09:00
Yukihiro "Matz" Matsumoto 05549410d9 mruby-pack/pack.c (read_tmpl): check unknown directives 2023-07-24 18:03:38 +09:00
Yukihiro "Matz" Matsumoto 2a1e3a572c mruby-pack/pack.c (read_tmpl): support J/j template in pack
J/j is available since Ruby 2.3.
2023-07-24 18:03:37 +09:00
Yukihiro "Matz" Matsumoto 663f936ba8 Merge pull request #6030 from jbampton/standardize-dots
Standardize docs to use 3 dots: `...`
2023-07-24 08:21:16 +09:00
Yukihiro "Matz" Matsumoto 0876cf82ff Merge pull request #6028 from jbampton/fix-super-linter-button
Fix Super-Linter button in README
2023-07-24 08:20:06 +09:00
John Bampton 14b4f5953b Standardize docs to use 3 dots: ... 2023-07-23 03:39:03 +10:00
Yukihiro "Matz" Matsumoto 455a5689f3 lib/mruby/build/command.rb: skip mrbgems in parent directory; fix #6029
If `mrbgems` is included in the parent directory path (MRUBY_ROOT), it
confuses gem path and build path.
2023-07-17 13:24:47 +09:00
Yukihiro "Matz" Matsumoto f84f129d65 AUTHORS: update entries [ci skip] 2023-07-17 12:18:10 +09:00
Yukihiro "Matz" Matsumoto 5e7d763e91 variable.c (mrb_obj_iv_set_force): check namespace_p beforehand
To reduce number of assign_class_name() invocation.
2023-07-17 12:09:28 +09:00
John Bampton 95fbacb1dc Fix Super-Linter button in README
Updated the button to the latest format seen here:

https://github.com/marketplace/actions/super-linter#add-super-linter-badge-in-your-repository-readme
2023-07-15 20:49:58 +10:00
Yukihiro "Matz" Matsumoto 82a48bd455 error.c (mrb_bug): avoid formatting in mrb_bug()
Since mrb_bug() would be called under the abnormal situation (and should
not be called if possible), the process should be minimal.
2023-07-14 21:48:11 +09:00
Yukihiro "Matz" Matsumoto d6d434eb3f Inline loop variables everywhere 2023-07-13 08:05:00 +09:00
Yukihiro "Matz" Matsumoto d4a03be96b mruby-string-ext/string.c (str_casecmp): small refactoring 2023-07-12 09:14:45 +09:00
Yukihiro "Matz" Matsumoto 2af0ff52e9 backtrace.c (count_backtrace_i): remove empty callback
Instead specifying NULL as function argument of each_backtrace()
count the number of callbacks.
2023-07-11 07:17:19 +09:00
Yukihiro "Matz" Matsumoto 6f99806d5b backtrace.c (packed_backtrace): remove count_backtrace()
Since we have stop calling mrb_debug_get_position() in each_backtrace(),
we don't need to craft special function count_backtrace(). We just use
each_backtrace() to count the number of backtraces.
2023-07-11 06:59:09 +09:00
Yukihiro "Matz" Matsumoto 316119069d backtrace.c (each_backtrace): skip callinfo without debug_info 2023-07-10 07:57:02 +09:00
Yukihiro "Matz" Matsumoto 7aa914b4d4 cdump.c (cdump_debug): restore arena index at the end of the function 2023-07-10 07:26:19 +09:00
Yukihiro "Matz" Matsumoto c57610ad8a backtrace.c (packed_backtrace): fix broken ciidx
- fix at higher level to remove redundancy
- ciidx should always be smaller than ci stack length
2023-07-10 07:05:27 +09:00
Yukihiro "Matz" Matsumoto 9c61c66045 gc.c (mrb_obj_alloc): clarify the heap initialization 2023-07-09 22:59:58 +09:00
Yukihiro "Matz" Matsumoto eebbc6eaa4 gc.c (mrb_obj_alloc): gc->heaps may be NULL 2023-07-07 06:53:19 +09:00
Yukihiro "Matz" Matsumoto af85b1fbed gc.c (gc_mark_gray_list): cut gcnext link 2023-07-06 22:57:14 +09:00
Yukihiro "Matz" Matsumoto aa5ffb686f mruby-os-memsize: more precise memory size for method tables 2023-07-06 16:12:51 +09:00
Yukihiro "Matz" Matsumoto 0a4473bf64 mruby-socket/socket.c: fix indentation 2023-07-04 17:50:37 +09:00
Yukihiro "Matz" Matsumoto 0558b1abd8 backtrace.c: reorder functions for clarity 2023-07-03 15:26:45 +09:00
Yukihiro "Matz" Matsumoto 97b60e7fb1 backtrace.c (backtrace_location): defer retrieving positions
Instead of calling `mrb_debug_get_position` in the `each_backtrace`, we
just keep `irep` and `idx` information in the backtrace_location, and
get the exact position in `mrb_unpack_backtrace` which may not be called
if exceptions are handled in the `rescue` clauses.
2023-07-03 15:21:16 +09:00
Yukihiro "Matz" Matsumoto 40bdd65ce6 backtrace.c (each_backtrace): return number of traces iterated 2023-07-03 15:20:24 +09:00
Yukihiro "Matz" Matsumoto 70b49eaef2 debug.c (debug_get_line): remove obsolete debug line types
- mrb_debug_line_ary
- mrb_debug_line_flat_map

Those two are no longer used, so we can safely remove the support.
2023-07-03 15:16:29 +09:00
Yukihiro "Matz" Matsumoto ea649e70b8 mruby-pack/pack.c (mrb_pack_pack): use direct array buffer access
We don't need index wrap-around not boundary check here, so we can use
faster direct array access.
2023-06-29 22:54:58 +09:00
Yukihiro "Matz" Matsumoto 0c4f5a4093 backtrace.c (mrb_unpack_backtrace): make the function static 2023-06-29 22:54:09 +09:00
Yukihiro "Matz" Matsumoto e563a3cb2c backtrace.c (packed_backtrace): reduce unnecessary calls
Instead of calling each_backtrace() twice, use a new function
count_backtrace().
2023-06-28 21:53:17 +09:00
Yukihiro "Matz" Matsumoto f1d6af08cf gc.c: inline heap page linkage 2023-06-27 15:48:33 +09:00
Yukihiro "Matz" Matsumoto 38b9a25e83 gc.c (mrb_obj_alloc): remove free_next,free_prev from heap pages
It used to be maintain heap pages with allocatable objects (free_heaps)
but we can save two words (16 bytes) per page by scanning live heap pages.
2023-06-27 15:48:25 +09:00
Yukihiro "Matz" Matsumoto 695ad6ea95 gc.c (incremental_sweep_phase): freed need not to be smaller than page size 2023-06-26 17:14:43 +09:00
Yukihiro "Matz" Matsumoto b2110c23a1 Merge pull request #6023 from dearblue/expose-headers
"expose_header_files" task split per build
2023-06-24 15:35:31 +09:00
Yukihiro "Matz" Matsumoto a3365d8b3f gc.c (obj_free): need not to unshare env object when freeing fibers
Since when env objects reference the context, we no longer need to
unshare (stack reallocate) env objects. Currently all env objects
referenced from fibers are already recycled, so we removed unnecessary
code altogether.
2023-06-23 23:06:15 +09:00
Yukihiro "Matz" Matsumoto fc9fffc5b5 kernel.rb (_inspect): _inspect method no longer needed 2023-06-22 23:32:31 +09:00
Yukihiro "Matz" Matsumoto 6ae6b63aaf mruby-struct: add recursive inspect check instead of _inspect hack 2023-06-22 12:53:51 +09:00
Yukihiro "Matz" Matsumoto 849963b81e variable.c (mrb_obj_iv_inspect): support recursion detection 2023-06-21 23:36:59 +09:00
Yukihiro "Matz" Matsumoto 0713f2a840 mruby-set/set.rb (inspect): add recursive inspect check to Set#inspect 2023-06-20 11:25:49 +09:00
Yukihiro "Matz" Matsumoto 113565a1c5 hash.c (mrb_hash_to_s): add recursive inspect check to Hash#inspect 2023-06-20 11:18:38 +09:00
Yukihiro "Matz" Matsumoto 5cb0c7463b array.c (mrb_ary_to_s): add recursive check to Array#inspect 2023-06-20 07:06:33 +09:00
Yukihiro "Matz" Matsumoto e2bbf75d58 kernel.c: prepare for new recursive inspect check
Like previous recursive `<=>` check, scan call stack to detect recursive
`inspect` calls. We no longer need incomplete `_inspect` hack to pass
around a hash table to record objects currently inspecting.
2023-06-20 07:04:28 +09:00
Yukihiro "Matz" Matsumoto 75c8ffddf5 object.c (mrb_equal) move mrb_equal() back to object.c 2023-06-20 06:45:05 +09:00
Yukihiro "Matz" Matsumoto 89a1719a13 compar.rb: use equal?() instead of ==
To avoid unnecessary infinite recursion.
2023-06-19 15:33:13 +09:00
dearblue fdec32a8f2 "expose_header_files" task split per build
If there are multiple build targets, it should be preferable to have the task processed at each of them.
2023-06-18 21:22:31 +09:00
Yukihiro "Matz" Matsumoto 7f85ae2c48 Merge pull request #6022 from chasonr/msdos-build
Build configuration for MS-DOS and DJGPP
2023-06-18 18:13:24 +09:00
Ray Chason 23e9befbc0 Changes to cross-compile with DJGPP 2023-06-17 17:20:33 -04:00
Ray Chason 853b25972e Build configuration for MS-DOS 2023-06-17 17:20:20 -04:00
Yukihiro "Matz" Matsumoto a638a71c72 test/hash.rb: remove some inspect/to_s tests
CRuby does prohibits Hash modification during iteration, so remove those
self modifying inspect/to_s.
2023-06-17 17:56:41 +09:00
Yukihiro "Matz" Matsumoto 20552fe176 hash.c (mrb_hash_foreach): wrap function call with h_check_modified
If the iterating hash is modified in the function, h_each loop may
crash accessing modified (and probably deallocated) internal data.
2023-06-17 10:55:55 +09:00
Yukihiro "Matz" Matsumoto e502fd88b9 kernel.c (mrb_cmp_m): check recursive <=> calls
If previous `<=>` method invocation with same arguments is detected in
the stack trace, this `<=>` call must be recursive and can cause stack
overflow.
2023-06-17 09:18:55 +09:00
Yukihiro "Matz" Matsumoto 7c9cb0901c kernel.c (mrb_equal): simplify the code 2023-06-16 13:45:58 +09:00
Yukihiro "Matz" Matsumoto 5e4cecf766 internal.h: add mrb_obj_equal_m to internal.h 2023-06-15 23:36:27 +09:00
Yukihiro "Matz" Matsumoto a04d18bb6d kernel.c (mrb_eqq_m): rename function equal -> eqq
This function implements `Kernel#===` and it's usually abbreviated to
`eqq` not `equal`.
2023-06-15 23:32:41 +09:00
Yukihiro "Matz" Matsumoto 359c630d73 kernel.c (mrb_equal): move mrb_equal() from object.c 2023-06-15 23:31:45 +09:00
Yukihiro "Matz" Matsumoto 2be7cba8f5 kernel.c (obj_respond_to): refactoring
- skip basic_obj_respond_to(); call mrb_respond_to() directly
- narrower scope for `mrb_sym rtm_id`
- use mrb_func_basic_p() to detect override
- use mrb_funcall_id() to avoid local mrb_value array
2023-06-14 11:41:21 +09:00
Yukihiro "Matz" Matsumoto 347586e400 kernel.c: define respond_to_missing? method 2023-06-14 11:31:55 +09:00
Yukihiro "Matz" Matsumoto e96d90dab2 Merge pull request #6017 from jbampton/standardize-pre-commit-config
Standardize the `pre-commit` config
2023-06-13 15:44:51 +09:00
Yukihiro "Matz" Matsumoto 7125481952 Merge pull request #6021 from jbampton/news-remove-duplicate-cve
NEWS: remove duplicate CVE from list
2023-06-13 14:09:59 +09:00
John Bampton 26659ef76c NEWS: remove duplicate CVE from list 2023-06-13 15:02:57 +10:00
Yukihiro "Matz" Matsumoto 0d863ae85f Merge pull request #6018 from jbampton/configure-dependabot-for-bundler
Configure Dependabot updates for Bundler/Ruby
2023-06-13 13:50:40 +09:00
Yukihiro "Matz" Matsumoto c99403d635 Merge pull request #6020 from jbampton/fix-markdown-link
Enable markdownlint rule MD052
2023-06-13 13:49:49 +09:00
Yukihiro "Matz" Matsumoto a332ea1f67 Merge pull request #6019 from jbampton/docs-remove-duplicate-cve
docs: remove duplicate CVE from list
2023-06-13 13:47:55 +09:00
John Bampton 50e0aad288 Enable markdownlint rule MD052
https://github.com/DavidAnson/markdownlint/blob/main/doc/md052.md
2023-06-13 14:34:52 +10:00
John Bampton 343a633fb0 doc: fix Markdown reference links 2023-06-13 14:31:29 +10:00
John Bampton 36f2d1733b docs: remove duplicate CVE from list 2023-06-13 13:27:23 +10:00
John Bampton 760ce71af0 Configure Dependabot updates for Bundler/Ruby
https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/about-dependabot-version-updates#supported-repositories-and-ecosystems

In future this will keep the Gemfile.lock up to date
2023-06-13 12:44:00 +10:00
John Bampton f14f2ae174 Standardize the pre-commit config 2023-06-13 08:54:17 +10:00
Yukihiro "Matz" Matsumoto 17720c9b7b variable.c (const_get): avoid mrb_funcall if possible
Directly call mrb_const_missing() if const_missing is not overridden.
2023-06-12 23:47:35 +09:00
Yukihiro "Matz" Matsumoto 89f7bb1056 use more lightweight mrb_funcall_argv instead of mrb_funcall_id 2023-06-12 14:22:04 +09:00
Yukihiro "Matz" Matsumoto 39a29a7de1 mruby-bin-debugger/mrbgem.rake: fix defines configuration
`spec.build.defines` should be update inline. Otherwise, configuration
may differ from file to file.
2023-06-12 13:07:57 +09:00
Yukihiro "Matz" Matsumoto a867fb0703 class.c: remove methID from the example and codespell dict 2023-06-09 17:56:21 +09:00
Yukihiro "Matz" Matsumoto b6181ae58a mruby/gc.h: reorder mrb_gc members to reduce alignment gaps 2023-06-09 17:19:09 +09:00
Yukihiro "Matz" Matsumoto 727a2ec793 gc.c (obj_free): use simpler is_dead()
`mrb_object_dead_p()` is heavier if the pointer is (or used to be) an
object in the heaps.
2023-06-07 17:03:32 +09:00
Yukihiro "Matz" Matsumoto 336b7efb41 gc.c (mrb_incremental_gc): clarify the if-condition 2023-06-06 11:29:48 +09:00
Yukihiro "Matz" Matsumoto 8b8e186688 gc.h: rename majorgc_old_threashold to oldgen_threashold
This field means that if you have more old generation objects than
this value, major GC mode will be turned on.
2023-06-06 11:26:35 +09:00
Yukihiro "Matz" Matsumoto b47c8b738a gc.c (clear_all_old): fix a generational GC bug
This issue was caused by 375d22b that introduced a serious mark
leakage in the generational GC mode.
2023-06-06 07:29:41 +09:00
Yukihiro "Matz" Matsumoto 0bb08718b8 gc.c (incremental_marking_phase): clear gcnext for debugging 2023-06-05 23:31:36 +09:00
Yukihiro "Matz" Matsumoto 6958368daa gc.c (gc_mark_children): declare a loop variable in the for-statement 2023-06-05 23:30:33 +09:00
Yukihiro "Matz" Matsumoto 623cda5521 gc.c: make color macros literals for debugging clarity 2023-06-05 16:00:04 +09:00
Yukihiro "Matz" Matsumoto f07281a026 Revert "object.h: make GC color uint8_t that fits in 3 bits"
The change made the size of mruby data types bigger on Win.
This reverts commit afcf7fc86d.
2023-06-03 16:55:58 +09:00
Yukihiro "Matz" Matsumoto 93648fc954 gc.c (mrb_env_unshare): fix a write barrier bug 2023-06-02 11:00:13 +09:00
Yukihiro "Matz" Matsumoto 9369679e36 vm.c: reduce local variables 2023-06-01 09:14:39 +09:00
Yukihiro "Matz" Matsumoto 5b61407414 class.c (prepare_singleton_class): defer method table allocation 2023-06-01 09:13:44 +09:00
Yukihiro "Matz" Matsumoto 0d8545e01b error.c (frozen_error): change specifier from %t to %T
- `%t` prints type (class) of the argument
- `%T` prints real class of the argument, skipping TT_ICLASS, etc.
2023-05-31 08:35:54 +09:00
Yukihiro "Matz" Matsumoto e6c89ef1f9 mruby.h: make mrb_check_frozen to a normal function from inline one 2023-05-31 08:33:58 +09:00
Yukihiro "Matz" Matsumoto ccdf75c1c2 error.c: a new function mrb_check_frozen_value() 2023-05-31 08:31:13 +09:00
Yukihiro "Matz" Matsumoto 8b39a7825d Reduce unnecessary mrb_obj_ptr() to mrb_check_frozen() 2023-05-31 08:29:12 +09:00
Yukihiro "Matz" Matsumoto afcf7fc86d object.h: make GC color uint8_t that fits in 3 bits 2023-05-31 08:27:23 +09:00
Yukihiro "Matz" Matsumoto 8873229312 codedump.c: fix indentation of OP_SCLASS 2023-05-30 16:08:38 +09:00
Yukihiro "Matz" Matsumoto 6eedf1065d numeric.c (flo_idiv): add mrb_check_num_exact 2023-05-30 08:54:44 +09:00
Yukihiro "Matz" Matsumoto 795044f82c internal.h: add mrb_check_num_exact prototype to the header 2023-05-30 08:54:05 +09:00
Yukihiro "Matz" Matsumoto e84060a900 string.c: rename function str_check_too_big -> str_check_length 2023-05-30 08:40:16 +09:00
Yukihiro "Matz" Matsumoto f813b5d1d8 string.c (str_new): add string length check 2023-05-29 23:18:44 +09:00
Yukihiro "Matz" Matsumoto aecaaf011f string.c (mrb_str_resize): refactor string length check 2023-05-29 23:18:19 +09:00
Yukihiro "Matz" Matsumoto 0a6e1c0ffe class.c (copy_class): copy source flags as well (except frozen flag) 2023-05-29 22:59:05 +09:00
Yukihiro "Matz" Matsumoto c0c4219b25 class.c (copy_class): avoid copying method table in some cases
To prevent memory leaks
2023-05-29 22:57:59 +09:00
Yukihiro "Matz" Matsumoto bba2fd84ea class.h: instance type should occupy 5 bits in flags 2023-05-29 09:27:08 +09:00
Yukihiro "Matz" Matsumoto e4e3740688 class.c (init_copy): add an assertion 2023-05-29 09:26:45 +09:00
Yukihiro "Matz" Matsumoto a02894afa3 small cosmetic changes 2023-05-29 09:26:45 +09:00
Yukihiro "Matz" Matsumoto 0ffe9b987a class.c (mrb_prepend_module): c should not be MRB_TT_ICLASS 2023-05-29 09:26:44 +09:00
Yukihiro "Matz" Matsumoto 6ac10a01e4 Merge pull request #6014 from dearblue/setup_debug.1
Fixed visibility of `MRuby::Command::Compiler#setup_debug`
2023-05-29 09:26:32 +09:00
dearblue a7bee69452 Fixed visibility of MRuby::Command::Compiler#setup_debug
In #5977 it was incorrectly set to `private`.
2023-05-26 21:37:29 +09:00
Yukihiro "Matz" Matsumoto 7f887f1928 class.c (mrb_class_initialize): check duplicated initialization 2023-05-26 12:48:34 +09:00
Yukihiro "Matz" Matsumoto 8914c2318c Merge pull request #6013 from CaptainJet/master
Fix Android toolchain
2023-05-26 12:47:08 +09:00
Robert Rowe fb727a169f Spacing fix 2023-05-25 19:47:32 -07:00
Robert Rowe bcb5674676 Update Android building
New minimum SDK. NDK longer supports mips, plain armeabi, nor GCC. Fix tooling.
2023-05-25 19:45:14 -07:00
Yukihiro "Matz" Matsumoto 2ad3f0e34b vm.c (mrb_yield_with_class): keep mid of the callee
Otherwise `super` from within blocks may call wrong methods.
2023-05-26 11:17:51 +09:00
Yukihiro "Matz" Matsumoto 9040baa270 vm.c (mrb_yield_with_class): avoid redundant initialization of mid 2023-05-26 11:14:58 +09:00
Yukihiro "Matz" Matsumoto 2b3ecef66c mruby-data/data.c: use mrb_ary_ref instead of direct memory access
Avoid out-of-bound memory access when actual data object size is smaller
than the number of data members.
2023-05-25 09:05:03 +09:00
Yukihiro "Matz" Matsumoto 9bc9ff771d mruby-data/data.c (mrb_data_s_def): simplify the code 2023-05-25 09:05:03 +09:00
Yukihiro "Matz" Matsumoto 05f4831751 mruby-data/data.c (mrb_data_s_def): add member duplication check 2023-05-25 09:05:03 +09:00
Yukihiro "Matz" Matsumoto eeab289f87 mruby-data/data.c (mrb_data_ref): avoid out-of-bound access 2023-05-25 09:05:02 +09:00
Yukihiro "Matz" Matsumoto de69190df5 mruby-struct/struct.c: need to copy the argument array
Just in case for stack reallocations.
2023-05-25 09:05:02 +09:00
Yukihiro "Matz" Matsumoto e05ac91217 mruby-struct/struct.c: update the behavior when actual size differs
Assertions may be false and terminate the whole process when actual size
for struct objects are different.
2023-05-25 09:05:02 +09:00
Yukihiro "Matz" Matsumoto f50e40f291 mruby-struct/struct.c: use mrb_ary_set to simplify the code
We don't need to do `mrb_struct_modify()` and calling write barriers by
ourselves for the small performance issue.
2023-05-25 09:05:02 +09:00
Yukihiro "Matz" Matsumoto 0295e6a688 mruby-struct/struct.c (struct_aref_int): update index check
Check should use the number of members, not the actual size of the
struct object, which may be smaller than the declared size.
2023-05-25 08:40:46 +09:00
Yukihiro "Matz" Matsumoto 8e579e6552 mruby-data/data.c (mrb_data_ref): check if reader has no argument 2023-05-24 22:45:35 +09:00
Yukihiro "Matz" Matsumoto ed5fbb5d63 mruby-struct.c (mrb_struct_s_def): check duplicate members 2023-05-24 22:43:09 +09:00
Yukihiro "Matz" Matsumoto f80192e8ac mruby-struct/struct.c (struct_s_member): avoid break
Direct `return` is more readable, IMO.
2023-05-24 17:59:32 +09:00
Yukihiro "Matz" Matsumoto c2f3f103bb mruby-struct/struct.c (mrb_struct_ref): update the function
- use `num_members`
- ensure the function takes no argument
- avoid out-of-bound access when struct is failed to initialize
2023-05-24 17:53:41 +09:00
Yukihiro "Matz" Matsumoto 69d33de527 mruby-struct/struct.c (num_members): simplify the code by new argument 2023-05-24 17:51:44 +09:00
Yukihiro "Matz" Matsumoto 52fb2f59d8 mruby-struct/struct.c (struct_aref_sym): simplify the logic 2023-05-24 17:51:03 +09:00
Yukihiro "Matz" Matsumoto 7b7ea70b84 mruby-struct/struct.c (mrb_struct_to_h): RSTRUCT_PTR() may be NULL
Especially when you define a member named `initialize`.
2023-05-24 17:48:51 +09:00
Yukihiro "Matz" Matsumoto 53de96426a mruby-io/io.c (io_init): File.new should not take blocks 2023-05-23 15:34:37 +09:00
Yukihiro "Matz" Matsumoto 67187881c2 mruby-io/io.c (io_init_copy): copy flags before io_buf_init() 2023-05-23 15:17:13 +09:00
Yukihiro "Matz" Matsumoto 8f745b7728 vm.c (OP_ENTER): fix issues by unreferenced kdict and blk
There's short a period where kdict and blk are not pointed from the stack.
2023-05-23 14:54:36 +09:00
Yukihiro "Matz" Matsumoto 2f7f797473 remove extra spaces before ; 2023-05-22 12:05:35 +09:00
Yukihiro "Matz" Matsumoto 6a6c0869dc add a space between for and ( 2023-05-22 11:58:23 +09:00
Yukihiro "Matz" Matsumoto f1a3cfbd3b add a space between if and ( 2023-05-22 11:55:21 +09:00
Yukihiro "Matz" Matsumoto c32f7915fb reformat else clause indentation style 2023-05-20 00:21:01 +09:00
Yukihiro "Matz" Matsumoto eea72ec84a fix spaces in the type cast expressions (cosmetic changes) 2023-05-18 23:29:16 +09:00
Yukihiro "Matz" Matsumoto cead78b394 variable.c (iv_rehash): fixed removed check
This check removed in 70cc2cc was necessary.
2023-05-17 09:52:00 +09:00
Yukihiro "Matz" Matsumoto 49927a7035 mruby-biding/binding.c: unify get_line and get_filename 2023-05-16 23:40:53 +09:00
Yukihiro "Matz" Matsumoto 15be2a24c3 mruby-proc-ext/proc.c: unify get_line and get_filename 2023-05-16 23:39:51 +09:00
Yukihiro "Matz" Matsumoto 5ead26be3d vm.c (ci_bidx): inline the function if possible 2023-05-16 22:41:32 +09:00
Yukihiro "Matz" Matsumoto b10c99bb1b Merge pull request #6012 from sinisterchipmunk/allow-to-skip-tests-for-specific-mgems
Allow tests to be disabled for specific gems; warn about disabled tests
2023-05-16 14:36:40 +09:00
Colin MacKenzie IV 1a0c31130c Allow tests to be disabled for specific gems; warn about disabled tests 2023-05-15 12:43:37 -04:00
Yukihiro "Matz" Matsumoto 33bd6caf31 Merge pull request #6011 from dearblue/presym-escape
Encode and decode escape characters for presym
2023-05-15 00:15:40 +09:00
dearblue 03a42b52ee Encode and decode escape characters for presym
The purpose is to deal with `$"`, which has been treated as three characters including the escape character.
2023-05-14 17:54:13 +09:00
Yukihiro "Matz" Matsumoto cd276715f8 variable.c: move inline function before usage 2023-05-13 22:52:39 +09:00
Yukihiro "Matz" Matsumoto f210d3b106 Merge pull request #6010 from jbampton/add-hook-markdown-link-check 2023-05-12 23:31:34 +09:00
John Bampton ac0e157b89 pre-commit: add hook markdown-link-check
https://github.com/tcort/markdown-link-check
2023-05-11 12:37:38 +10:00
John Bampton de0779d6ca docs: fix links in Markdown 2023-05-11 12:34:59 +10:00
Yukihiro "Matz" Matsumoto 3d5cc1ab8f Merge pull request #6007 from dearblue/define_installer
Correct the `MRuby::Build#define_installer`
2023-05-10 23:54:27 +09:00
Yukihiro "Matz" Matsumoto 2217201603 Merge pull request #6006 from dearblue/mrbc-final_mrbgems
Remove `mrb_final_mrbgems()` in `mrbc.c`
2023-05-09 14:46:51 +09:00
Yukihiro "Matz" Matsumoto 568a7edf1f Merge pull request #6004 from jbampton/add-info-links-to-workflows
yml: document `workflows` with links as comments
2023-05-09 14:45:48 +09:00
Yukihiro "Matz" Matsumoto feb07d1d1a Merge pull request #6002 from jbampton/standardize-whitespace-spec-authors
mrbgems: standardize `spec.authors` for whitespace and author name
2023-05-08 17:01:23 +09:00
Yukihiro "Matz" Matsumoto d3f030f02a Merge pull request #5999 from alpha-netzilla/fix_poppen_mode
lib/mruby/build/command.rb: narrow down poppen mode
2023-05-08 17:00:28 +09:00
Yukihiro "Matz" Matsumoto e545ec3810 Merge pull request #6001 from jbampton/update-docs
docs: fix links, grammar and spelling in Markdown
2023-05-08 17:00:03 +09:00
Yukihiro "Matz" Matsumoto 599982454e Merge pull request #6008 from dearblue/bintest-dirfree 2023-05-07 19:10:59 +09:00
Yukihiro "Matz" Matsumoto 727d83c118 Merge pull request #6009 from dearblue/ghost-bintest
Avoid adding `<MRUBY_ROOT>/bintest` which does not exist
2023-05-06 22:28:41 +09:00
dearblue 5a4c319dd8 Avoid adding <MRUBY_ROOT>/bintest which does not exist
The `<MRUBY_ROOT>/bintest` directory does not exist in current mruby.
2023-05-06 22:08:48 +09:00
dearblue eb4c7d0edf Make "bintest" independent of directory
Previously, "bintest" would fail to run unless `MRUBY_ROOT` and `Dir.pwd` were the same.
2023-05-06 22:00:57 +09:00
dearblue 44f9fa1b61 Correct the MRuby::Build#define_installer
This is a complement to #5928.
The previous PR had the following problem:

  - The `<INSTALL_DIR>/bin/*` file could not be replaced if the destination of the symbolic link was lost.
  - The wrong link destination was written if `MRuby::Build.install_dir` was a relative path.
2023-05-06 21:54:49 +09:00
dearblue e570ca82a8 Remove mrb_final_mrbgems() in mrbc.c
The current `mrb_final_mrbgems()` function is only referenced in the `mrbgem/gem_init.c` file.

Also, the definition in that file makes it a static function.
2023-05-06 21:07:08 +09:00
John Bampton 04a120f7c2 yml: document workflows with links as comments 2023-05-06 08:31:20 +10:00
Yukihiro "Matz" Matsumoto 9033191efa Merge pull request #6003 from jbampton/label-more-files
`.github/labeler.yml`: label more files for `doc`
2023-05-06 06:43:53 +09:00
John Bampton 5fab261d8a .github/labeler.yml: label more files for doc 2023-05-06 07:19:46 +10:00
John Bampton 63e170170e mrbgems: standardize spec.authors for whitespace and author name 2023-05-06 06:06:29 +10:00
John Bampton db3774ea45 docs: fix links, grammar and spelling in Markdown 2023-05-06 04:43:50 +10:00
John Bampton d63115a0f1 docker: use less image layers and update compose version
https://stackoverflow.com/questions/30256386/how-to-copy-multiple-files-in-one-layer-using-a-dockerfile

https://docs.docker.com/compose/compose-file/compose-file-v3/
2023-05-06 01:46:51 +10:00
Yukihiro "Matz" Matsumoto 9b4046f479 Merge pull request #5961 from jbampton/add-docker
Add `Docker` to build and run all `mruby` tests. Run `pre-commit` and generate `YARD` docs with Docker
2023-05-05 22:42:33 +09:00
alpha.netzilla 3409c1f309 lib/mruby/build/command.rb: narrow down poppen mode 2023-05-05 19:23:18 +09:00
Yukihiro "Matz" Matsumoto 28a29c6da1 Merge pull request #5997 from jbampton/pre-commit-autoupdate
Run `rake checkupdate` -> `pre-commit autoupdate`
2023-05-04 08:36:36 +09:00
Yukihiro "Matz" Matsumoto ab0f2297ab Merge pull request #5996 from jbampton/fix-case-of-mruby
Change `MRuby` to `mruby`
2023-05-04 08:34:46 +09:00
John Bampton be722da0d1 pre-commit autoupdate
Run `rake checkupdate`
2023-05-03 22:49:34 +10:00
John Bampton 12f64cc6d9 Update codespell.txt. Disable markdownlint rule MD052 2023-05-03 22:44:58 +10:00
John Bampton 06a765a1c2 Change MRuby to mruby 2023-05-03 22:12:59 +10:00
Yukihiro "Matz" Matsumoto 5956496267 lib/mruby/build/command.rb: remove unnecessary block parameter; fix #5995 2023-05-03 12:41:52 +09:00
Yukihiro "Matz" Matsumoto 077d8ad514 symbol.c (sym_intern): check NUL before calling strlen()
To avoid accidental buffer overrun if a string without NUL termination
is provided.
2023-05-02 09:45:47 +09:00
Yukihiro "Matz" Matsumoto 19b2c1c73d symbol.c: remove unused macro 2023-05-02 09:45:23 +09:00
Yukihiro "Matz" Matsumoto 7fd3108201 README.md: update English description (used ChatGPT) 2023-05-02 09:44:49 +09:00
Yukihiro "Matz" Matsumoto 7154526c04 Merge pull request #5994 from masahino/fix_typo_in_io_c
fix typo in mrbgems/mruby-io/src/io.c
2023-05-02 09:44:13 +09:00
masahino ad318e55c0 fix typo MRB_NO_IO_POEPN -> MRB_NO_IO_POPEN 2023-05-02 07:34:30 +09:00
Yukihiro "Matz" Matsumoto b488f197c5 Merge pull request #5992 from dearblue/doc/directory
Replace "folder" with "directory" for consistency
2023-04-30 23:19:40 +09:00
Yukihiro "Matz" Matsumoto abd1222089 class.h (mrb_class): treat immediate values first 2023-04-30 23:19:00 +09:00
dearblue 5c19b259e4 Replace "folder" with "directory" for consistency
Also, use "x/y/z directory" instead of "directory x/y/z" if there is no problem.
2023-04-30 18:32:54 +09:00
Yukihiro "Matz" Matsumoto 70cc2cc173 variable.c (iv_rehash): remove unnecessary checks 2023-04-29 23:17:08 +09:00
Yukihiro "Matz" Matsumoto 5024c3453d variable.c (iv_put): remove NULL check since t must not be NULL 2023-04-27 17:14:48 +09:00
Yukihiro "Matz" Matsumoto 68d67aee0e mruby-io/io.c: need to adjust buffer limit before searching; fix #5991 2023-04-26 09:09:05 +09:00
Yukihiro "Matz" Matsumoto 01e5f2a3c8 mruby-io/io.c: fix indent 2023-04-25 23:27:59 +09:00
Yukihiro "Matz" Matsumoto 9a5a9b814f mruby-catch/catch.c: remove mrb_ prefix from a static function 2023-04-25 23:27:30 +09:00
Yukihiro "Matz" Matsumoto e0194bba67 mruby-string-ext/string.c: remove mrb_ prefix from static functions 2023-04-25 14:25:15 +09:00
Yukihiro "Matz" Matsumoto 62e8f047b9 mruby-sleep/sleep.c: remove mrb_ prefix from static functions 2023-04-24 12:19:12 +09:00
Yukihiro "Matz" Matsumoto f116808d80 Merge pull request #5435 from jbampton/add-github-pr-labeler
Add the pull request labeler Action
2023-04-23 23:50:06 +09:00
Yukihiro "Matz" Matsumoto 49b887d75f mruby-object-ext/object.c: remove mrb_ prefix from static functions 2023-04-20 22:40:10 +09:00
Yukihiro "Matz" Matsumoto 2810491587 mruby-class-ext/class.c: remove mrb_ prefix from static functions 2023-04-19 00:12:28 +09:00
Yukihiro "Matz" Matsumoto c1010624a4 Merge pull request #5989 from dearblue/integrate-eval
Integrate `mruby-binding-eval` into `mruby-eval`
2023-04-19 00:06:13 +09:00
Yukihiro "Matz" Matsumoto ac7e63ab3b Merge pull request #5986 from dearblue/bytesplice
Fix bugs in `String#bytesplice`
2023-04-17 07:17:00 +09:00
Yukihiro "Matz" Matsumoto ceabb9cac8 Merge pull request #5988 from dearblue/int-inv
Returns the value of `Integer#~` from `mrb_bint_rev()`
2023-04-16 23:55:51 +09:00
dearblue 0e00d8e224 Integrate mruby-binding-eval into mruby-eval
Currently mruby-eval depends on mruby-binding (formerly mruby-binding-core).
Also, `Kernel#eval` can accept `binding` objects.
With this in mind, it would be better if `Binding#eval` could also be handled by `mrbgems/mruby-eval`.
2023-04-16 21:44:00 +09:00
Yukihiro "Matz" Matsumoto a959ce5755 Merge pull request #5985 from dearblue/sign-extension
Sign extension with `OP_LOADI32` in `get_int_operand()`
2023-04-15 23:25:07 +09:00
dearblue 0279067dc4 Returns the value of Integer#~ from mrb_bint_rev()
fixed #5987
2023-04-15 22:39:05 +09:00
dearblue 8665f88791 Allow an empty string for String#bytesplice 2023-04-15 21:26:01 +09:00
dearblue 59931e95c4 Prohibit string lengths less than 0 in String#bytesplice 2023-04-15 21:26:00 +09:00
dearblue 5bc3a48ecb Handling negative indices in String#bytesplice 2023-04-15 21:25:59 +09:00
dearblue dcced0016c Countermeasure to overflow for String#bytesplice 2023-04-15 21:25:58 +09:00
dearblue 73b6c6619c Need type check for replace by String#bytesplice 2023-04-15 21:25:57 +09:00
dearblue 2e9ac8f448 Returns self for String#bytesplice 2023-04-15 21:25:56 +09:00
dearblue c981e151ae Sign extension with OP_LOADI32 in get_int_operand()
Previously, the following code did not give the expected result.

```
% bin/mruby -e 'p "%08X" % ~(-1 << 16)'
"..F0000FFFF"

% ruby32 -e 'p "%08X" % ~(-1 << 24)'
"00FFFFFF"
```

For information: this problem arises in the process of folding numbers through optimisation.
2023-04-15 20:52:43 +09:00
Yukihiro "Matz" Matsumoto 836bebc708 mruby-compar-ext/compar.rb: Comparable#clamp to accept nil as arguments 2023-04-14 01:06:29 +09:00
Yukihiro "Matz" Matsumoto 68c58eac91 Merge pull request #5981 from dearblue/binding-only-ruby
`Kernel#binding` responds only to calls from Ruby
2023-04-14 01:06:16 +09:00
Yukihiro "Matz" Matsumoto c80db85ed5 Merge pull request #5980 from dearblue/binding-noise
Remove noise in new `mruby-binding`
2023-04-14 01:05:05 +09:00
Yukihiro "Matz" Matsumoto 4f125a3f19 mruby-struct/struct.c: allow struct size differ from members
The situation may be caused by `Struct.new(...).alloc` etc.
2023-04-13 07:39:05 +09:00
Yukihiro "Matz" Matsumoto 8af45425d0 mruby-struct/struct.c: Struct.new should take 1+ arguments 2023-04-13 07:39:05 +09:00
Yukihiro "Matz" Matsumoto bb7b4b67ae mruby-struct/struct.c (struct_corrupted): fix error message 2023-04-13 07:39:05 +09:00
Yukihiro "Matz" Matsumoto a7c96edf6f mruby-struct/struct.c: prohibit Struct.allocate; ref #5979 2023-04-13 07:39:05 +09:00
Yukihiro "Matz" Matsumoto 9822c843e9 mruby-array-ext/array.c: remove mrb_ prefix from static functions 2023-04-13 07:39:05 +09:00
John Bampton 00d43ad960 Add Docker to build and run all mruby tests
Run `pre-commit` and  generate `YARD` docs with Docker

Update CONTRIBUTING
2023-04-13 00:12:32 +10:00
John Bampton 976ec87100 Add the pull request labeler Action
https://github.com/actions/labeler
https://github.com/marketplace/actions/labeler

Verified Action

Update labeler.yml
2023-04-12 19:25:51 +10:00
Yukihiro "Matz" Matsumoto 8d014e9f43 Merge pull request #5984 from mruby/dependabot/github_actions/github/super-linter-5.0.0
build(deps): bump github/super-linter from 4.10.1 to 5.0.0
2023-04-12 09:12:00 +09:00
dependabot[bot] 71e78428ea build(deps): bump github/super-linter from 4.10.1 to 5.0.0
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.10.1 to 5.0.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.10.1...v5.0.0)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-11 14:57:54 +00:00
Yukihiro "Matz" Matsumoto 0df3e68a5d Merge pull request #5979 from dearblue/allocate-undef
Allow `Class#allocate` to be prohibited
2023-04-10 10:45:00 +09:00
dearblue 5cb2764279 Kernel#binding responds only to calls from Ruby
This follows the behavior changed in CRuby 3.2.
2023-04-09 21:15:13 +09:00
dearblue 93e07eec1c Remove noise in new mruby-binding
`Binding#eval` should not be defined in `mruby-binding`.
2023-04-09 21:14:33 +09:00
dearblue d3128ce58a Allow Class#allocate to be prohibited
Calling `Class#allocate` with `UnboundMethod#bind_call` usually succeeds without problems.
If this behavior does not make us happy, we can now prohibit it with `MRB_SET_INSTANCE_TT(klass, MRB_TT_UNDEF)`.

At the same time, it applies to the `Binding`, `Complex`, `Data`, `Float`, `Integer`, `Method`, `Rational` and `UnboundMethod` classes.
2023-04-09 21:14:07 +09:00
Yukihiro "Matz" Matsumoto c3ba76794f Merge pull request #5977 from dearblue/setup_debug
Make `MRuby::Build#enable_debug` compiler flag setting abstract
2023-04-09 15:51:44 +09:00
dearblue 0f2c1caa96 Make MRuby::Build#enable_debug compiler flag setting abstract
Previously, compiler flags were only added for GCC or similar.
The situation has not changed, but it has become easier to improve.

I expect `MRuby::Command::Compiler#setup_debug` to be defined as a singleton method inside the block given to `MRuby::Toolchain.new`.
2023-04-09 11:21:50 +09:00
Yukihiro "Matz" Matsumoto 64536b866b string.c (str_escape): simplify the logic 2023-04-07 13:53:19 +09:00
Yukihiro "Matz" Matsumoto d0653ca908 cdump.c: escape filename debug information; fix #5974
Windows path separator is "\" so that it needs to be escaped.
2023-04-07 13:51:59 +09:00
Yukihiro "Matz" Matsumoto 27a14f0a9a vm.c (OP_CMP): fixed wrong numeric comparison for integers; fix #5975
MRB_TT_INTEGER value may not be fixnum (immediate integer), so we should
not use mrb_fixnum() here.
2023-04-07 10:46:01 +09:00
Yukihiro "Matz" Matsumoto 761816bf8a fmt_fp.c (mrb_format_float): change else indentation style 2023-04-06 16:49:08 +09:00
Yukihiro "Matz" Matsumoto 956d0c5127 fmt_fp.c (mrb_format_float): set minimum precision 1 for "%e" 2023-04-06 16:47:43 +09:00
Yukihiro "Matz" Matsumoto 31c99eb99b debug.c (mrb_debug_get_position): do not keep lp and fp uninitialized 2023-04-06 15:47:24 +09:00
Yukihiro "Matz" Matsumoto ce86040a0f Merge pull request #5973 from dearblue/envadjust
Small improvements to `envadjust()`
2023-04-06 10:48:49 +09:00
Yukihiro "Matz" Matsumoto 9e4b3af553 Merge pull request #5972 from dearblue/simple-mrb_top_run
Simplify `mrb_top_run()`
2023-04-06 10:46:56 +09:00
Yukihiro "Matz" Matsumoto b4d7b269b0 Merge pull request #5971 from dearblue/simple-raise.2
Remove unnecessary branches in `L_RAISE` block
2023-04-06 10:46:02 +09:00
dearblue 17abe548a7 Small improvements to envadjust()
- Calculate the difference between `oldbase` and `newbase` only once outside the loop.
  - To make sure they are within range, the comparison is done only once instead of twice.
2023-04-05 22:29:27 +09:00
dearblue b90f59d36e Simplify mrb_top_run() 2023-04-05 22:11:36 +09:00
dearblue b46a852acb Remove unnecessary branches in L_RAISE block
The previous `while` loop ends if the catch handler pointer `ch` is not `NULL`.

Supplement to #5843.
2023-04-05 21:52:21 +09:00
Yukihiro "Matz" Matsumoto 35a3bab369 Merge pull request #5966 from jbampton/add-mruby-debugger
Update `default.gembox` add mruby debugger `mrdb`
2023-04-05 15:11:29 +09:00
Yukihiro "Matz" Matsumoto 8e9da2130f Merge pull request #5968 from jbampton/add-mruby-logo-to-readme
Add `mruby` logo to the README
2023-04-05 15:10:26 +09:00
Yukihiro "Matz" Matsumoto 730cbe7c0c Merge pull request #5969 from jbampton/docs-fix-grammar
Fix grammar in `mruby-YOUR-bigint/TODO-HINT.md`
2023-04-05 15:08:44 +09:00
Yukihiro "Matz" Matsumoto 19a2145204 Merge pull request #5970 from jbampton/fix-spelling-of-homepage
`README.md` fix spelling: `home-page` -> `homepage`
2023-04-05 15:07:44 +09:00
John Bampton 6467488854 Add mruby logo to the README
Center logo, mruby title and linter badge

Fix for YARD and Doxygen output
2023-04-05 15:53:02 +10:00
John Bampton e9756c77ea README.md fix spelling: home-page -> homepage
https://en.wikipedia.org/wiki/Home_page
2023-04-05 13:39:41 +10:00
John Bampton ebdb03b4d4 Fix grammar in mruby-YOUR-bigint/TODO-HINT.md 2023-04-05 11:26:05 +10:00
Yukihiro "Matz" Matsumoto 8171edc4eb Merge pull request #5967 from jbampton/sort-gitignore
Sort and remove blank lines from `.gitignore`
2023-04-05 08:05:45 +09:00
John Bampton 076520cac1 Sort and remove blank lines from .gitignore 2023-04-05 03:49:49 +10:00
Yukihiro "Matz" Matsumoto 90e3022936 Merge pull request #5965 from jbampton/fix-word-case-yard
Fix word case: `yard` -> `YARD`
2023-04-04 23:12:48 +09:00
John Bampton b486a3c425 Update default.gembox add mruby debugger mrbd 2023-04-04 19:31:42 +10:00
John Bampton 7082e95fa2 Fix word case: yard -> YARD
https://yardoc.org/
2023-04-04 18:20:52 +10:00
Yukihiro "Matz" Matsumoto b44d757b8c Merge pull request #5962 from jbampton/code-blocks-add-languages
docs: add language `console` to code blocks
2023-04-04 12:09:54 +09:00
Yukihiro "Matz" Matsumoto 76df8d737d Merge pull request #5960 from dearblue/gem-init-final.2
Shrink `<BUILD-DIR>/mrbgems/gem_init.c` if possible
2023-04-04 11:30:21 +09:00
Yukihiro "Matz" Matsumoto 5265e35ad2 mruby-time/time.c: remove mrb_ prefix from static functions 2023-04-03 08:58:33 +09:00
Yukihiro "Matz" Matsumoto 3d2cf0d9bf mruby-bigint/bigint.c: fix int64/uint64 conversion
The functions were totally wrong in digit order and sign treatment. We
didn't notice since they are only called from mruby-time in the m64-i32
configuration.
2023-04-03 08:55:48 +09:00
Yukihiro "Matz" Matsumoto 65897145aa mruby-time/time.c (mrb_to_time_t): should always initialize usec 2023-04-03 08:46:30 +09:00
Yukihiro "Matz" Matsumoto 875e0b0b59 mruby-time/time.c (time_value_from_time_t): should raise exception
When time_t does not fit in mrb_int; ref #5958
2023-04-03 08:38:52 +09:00
Yukihiro "Matz" Matsumoto dd453080e0 Merge pull request #5958 from dearblue/fixable_time_t_p
Need `fixable_time_t_p()` always
2023-04-03 07:34:11 +09:00
John Bampton f0d6674352 docs: add language console to code blocks
https://github.com/github/linguist/blob/79c4aa4706e08f9eb36e46535f0e909f51f3b74d/lib/linguist/languages.yml#L6392
2023-04-03 08:28:59 +10:00
dearblue 73b2e0bf76 Shrink <BUILD-DIR>/mrbgems/gem_init.c if possible
If none of the GEMs have `mrblib/` or `src/` directories, generate `mrb_init_mrbgems()` which does nothing, and omit `mrb_final_mrbgems()`.

The impetus was to avoid `gem_funcs[]` becoming a zero-length array, which is not allowed by the C standard.
The problem is caused by #5938.
2023-04-02 20:28:14 +09:00
Yukihiro "Matz" Matsumoto c6e7dfe9e5 Merge pull request #5959 from dearblue/mruby-strip
Need a dependency to `mruby-compiler` for `mruby-bin-strip`
2023-04-02 08:58:58 +09:00
dearblue 96190dba59 Need a dependency to mruby-compiler for mruby-bin-strip
It uses `mrb_irep_remove_lv()` defined in `mrbgems/mruby-compiler/core/codegen.c`.
2023-04-01 23:32:36 +09:00
dearblue bcce4b7141 Need fixable_time_t_p() always 2023-04-01 23:22:08 +09:00
Yukihiro "Matz" Matsumoto 2de602b869 mruby-eval: add dependency to mruby-binding 2023-04-01 10:37:56 +09:00
Yukihiro "Matz" Matsumoto eaaa474630 mruby-method/method.c: fix proc comparison for uncovered case 2023-04-01 10:37:16 +09:00
Yukihiro "Matz" Matsumoto a3fc6ae53c mruby-proc-ext/proc.c: use mrb_debug_get_position() 2023-04-01 10:37:15 +09:00
Yukihiro "Matz" Matsumoto 6629112291 Merge pull request #5957 from jbampton/clean-up-doc-limitations-md
doc/limitations.md: remove whitespace, add code block languages
2023-04-01 10:37:08 +09:00
John Bampton e76525568a doc/limitations.md: remove whitespace, add code block languages 2023-04-01 07:52:29 +10:00
Yukihiro "Matz" Matsumoto 58a83f3b9a codeql-analysis.yml: stop running codeql workflow 2023-03-31 09:43:30 +09:00
Yukihiro "Matz" Matsumoto 85aefa8992 Merge pull request #5955 from LanzaSchneider/master
fix: wrong comment for ```mrb_debug_get_filename```
2023-03-31 08:27:27 +09:00
Yukihiro "Matz" Matsumoto d482eabfa2 mruby-bigint/bigint.c: int.pow(n,m) to take bigint as exponential 2023-03-31 08:26:47 +09:00
Yukihiro "Matz" Matsumoto 62c52d5a28 mruby-bigint/bigint.c: remove unreachable line 2023-03-30 08:18:27 +09:00
Yukihiro "Matz" Matsumoto 35cedfb400 mruby-numeric-ext/numeric.c: Integer#pow fix for 2nd argument type
`int.pow()` takes 2nd argument only if 1st argument is an integer.
2023-03-30 08:18:27 +09:00
Lanza 01b03d852f fix: wrong comment for ``mrb_debug_get_filename`` 2023-03-30 06:57:33 +08:00
Yukihiro "Matz" Matsumoto f1568af0d2 gc.c: fix GC regressions
The past fix was wrong.
2023-03-29 08:46:10 +09:00
Yukihiro "Matz" Matsumoto 1f5a4d5386 mruby-method/method.c (method_eql): simplify the logic 2023-03-27 19:21:40 +09:00
Yukihiro "Matz" Matsumoto 553f9ba802 mruby-method/method.c (method_eql): use mrb_proc_eql 2023-03-27 19:15:03 +09:00
Yukihiro "Matz" Matsumoto fbb3a2426f proc.c (mrb_proc_eql): define == and eql? for Proc class 2023-03-27 19:14:21 +09:00
Yukihiro "Matz" Matsumoto ddb2240b5e proc.c: update ISO section numbers for methods 2023-03-27 11:39:58 +09:00
Yukihiro "Matz" Matsumoto b885d7387d proc.c: no need to define Proc.lambda
Since Kernel is an ancestor of Kernel module itself recursively.
2023-03-27 11:33:13 +09:00
Yukihiro "Matz" Matsumoto 0f63551def mruby-method/method.c (method_p): stricter method type check 2023-03-27 11:32:15 +09:00
Yukihiro "Matz" Matsumoto f4cff664e6 mruby-proc-ext/proc.c: no need to define Kernel.proc
Since Kernel is an ancestor of Kernel module itself recursively.
2023-03-27 00:18:57 +09:00
Yukihiro "Matz" Matsumoto 3e7ced5d63 mruby-proc-ext/proc.c: remove prefix from static functions 2023-03-27 00:12:18 +09:00
Yukihiro "Matz" Matsumoto 0bbfec3e8b mruby-eval: use functions from mruby-binding to simplify the code 2023-03-25 19:12:46 +09:00
Yukihiro "Matz" Matsumoto 11af5db1c3 mruby-binding: renamed from mruby-binding-core
The dependency is now:

mruby-binding-eval:

  - mruby-binding
  - mruby-eval

mruby-proc-binding:

  - mruby-binding

mruby-eval:

  - mruby-binding [new]
2023-03-24 12:25:57 +09:00
Yukihiro "Matz" Matsumoto 3ef41672ab mruby-biding-eval: move essential part of the gem to mruby-eval
This change makes mruby-binding-eval gem nearly empty, but needed to
make `eval(str, binding)` works as well as `binding.eval(str)`.
2023-03-24 07:33:13 +09:00
Yukihiro "Matz" Matsumoto 910afdc691 mruby-binding-eval: modify struct initialization 2023-03-23 22:10:20 +09:00
Yukihiro "Matz" Matsumoto 5914d9e9d4 mruby-binding-eval: remove unused members from binding_eval_prepar_body 2023-03-23 16:16:52 +09:00
Yukihiro "Matz" Matsumoto bf9a2501d1 mruby-binding-eval: move non raising code to the parent function 2023-03-22 23:22:45 +09:00
Yukihiro "Matz" Matsumoto bdbc613ccb parse.y (mrbc_filename): should not raise exceptions 2023-03-22 17:33:49 +09:00
Yukihiro "Matz" Matsumoto feabcfe29e doc/limitations.md: remove an entry regarding binding
Since it's no longer a limitation.
2023-03-22 15:26:29 +09:00
Yukihiro "Matz" Matsumoto 501b22a2ac mruby-binding-eval: renamed from mruby-binding
Since this gem only provides `Binding#eval`.
2023-03-22 15:25:23 +09:00
Yukihiro "Matz" Matsumoto 979e8602dd mruby-binding-core: make mrb_binding_wrap_lvspace static 2023-03-21 16:18:15 +09:00
Yukihiro "Matz" Matsumoto 66ca9722b6 mruby-binding-core (mrb_binding_new): new function
Use this function instead of `mrb_binding_alloc` (removed).
2023-03-21 16:17:08 +09:00
Yukihiro "Matz" Matsumoto 88ae5e8cf8 mruby-binding-core: use mrb_binding_wrap_lvspace if possible 2023-03-21 16:10:15 +09:00
Yukihiro "Matz" Matsumoto 495845443c mruby-binding-core (mrb_binding_p) add new function 2023-03-21 16:10:15 +09:00
Yukihiro "Matz" Matsumoto 35e2779575 Small cosmetic changes (adjust indent, and remove extra space) 2023-03-21 16:10:15 +09:00
Yukihiro "Matz" Matsumoto 0c8404a3e2 mruby-binding: use C implementation of Kernel#eval directly 2023-03-21 16:10:15 +09:00
Yukihiro "Matz" Matsumoto 1c765dc37a Merge pull request #5902 from dearblue/threadedcode
Replace `MRB_NO_DIRECT_THREADING` with `MRB_USE_VM_SWITCH_DISPATCH`
2023-03-18 23:56:04 +09:00
dearblue f6c9191cd0 Replace MRB_NO_DIRECT_THREADING with MRB_USE_VM_SWITCH_DISPATCH
The correct technique now is "Token Threading".
However, the new name was chosen because it was felt that if a different technique was added in the future, there would be no need to replace it.
2023-03-18 17:39:41 +09:00
Yukihiro "Matz" Matsumoto db11e07497 Merge pull request #5951 from dearblue/mrb_yield
Safely retrieve `self` from proc in `mrb_yield()`
2023-03-17 22:54:05 +09:00
dearblue 2675477f07 Safely retrieve self from proc in mrb_yield()
Passing a proc generated by the following method to `mrb_yield()` or `mrb_yield_argv()` no longer causes `SIGSEGV`:

- C functions made into proc objects with `mrb_proc_new_cfunc()`.
- A proc object which is the top level of a program generated by `mrb_load_string_cxt()` etc. with `mrbc_context::no_exec` enabled.

See also: #5932
2023-03-17 21:20:48 +09:00
Yukihiro "Matz" Matsumoto 800cb15fc3 limitation.md: describe mruby limitation for keyword arguments; #5952 2023-03-17 18:58:04 +09:00
Yukihiro "Matz" Matsumoto de70014643 mruby-binding/binding.c: add comment for functions from outer gems 2023-03-16 19:02:23 +09:00
Yukihiro "Matz" Matsumoto 62a8ea7113 mruby-bigint/bigint.c: mrb_bint_add_d, mrb_bint_sub_d only take int
Where mrb_bint_add and mrb_bint_sub may take float numbers.
2023-03-15 19:09:02 +09:00
Yukihiro "Matz" Matsumoto 3f7ea47ec1 Merge pull request #5917 from jbampton/remove-super-linter-folder
Remove `super-linter.report` folder
2023-03-15 19:07:30 +09:00
Yukihiro "Matz" Matsumoto 4fc69ce3bc Revert "mruby/throw.h: do not use __builtin_setjmp for GCC; close #5950"
This reverts commit 9cf49d08b4.

This change caused flaky tests on MinGW. I now remember it was introduced
for MINGW64 to address #5133. Sorry.
2023-03-14 19:50:15 +09:00
Yukihiro "Matz" Matsumoto 0d07af104b internal.h: move function prototypes to <mruby/internal.h> 2023-03-14 11:06:44 +09:00
Yukihiro "Matz" Matsumoto 2d975d59ce Merge branch 'dearblue-binding.4' 2023-03-14 11:05:53 +09:00
Yukihiro "Matz" Matsumoto 6915e75207 Merge branch 'binding.4' of https://github.com/dearblue/mruby into dearblue-binding.4 2023-03-14 11:05:10 +09:00
Yukihiro "Matz" Matsumoto da2cfa62f4 AUTHORS: update entries [ci skip] 2023-03-13 19:01:32 +09:00
Yukihiro "Matz" Matsumoto 0906cd7593 numeric.c: fix rounding function issues with big numbers
- int_ceil
- int_floor
- int_round
- int_truncate
2023-03-13 18:53:17 +09:00
Yukihiro "Matz" Matsumoto 8d1192f8a2 gc.c (mrb_field_write_barrier): change the condition
Minor GC may be suspended with the MRB_GC_STATE_SWEEP.
2023-03-13 18:52:03 +09:00
Yukihiro "Matz" Matsumoto ccca6ec458 gc.c (clear_all_old): simplify the code
The function is called only with generational mode.
2023-03-13 18:50:51 +09:00
Yukihiro "Matz" Matsumoto 9a1e6760a8 mruby-bigint: add new functions mrb_bint_add_d, mrb_bint_sub_d
Those functions do not normalize the return value to avoid repeated
conversions between Bigints and (small) Integers.
2023-03-13 16:07:17 +09:00
Yukihiro "Matz" Matsumoto f7cbb319cb mruby-bigint: remove unused mrb_bint_div_ii() function 2023-03-13 08:10:41 +09:00
Yukihiro "Matz" Matsumoto 33320b08bb mruby-data: fix uninitialized variable error 2023-03-13 08:09:26 +09:00
Yukihiro "Matz" Matsumoto 7327ca898c mruby-struct: fix uninitialized variable error 2023-03-13 08:08:30 +09:00
Yukihiro "Matz" Matsumoto dd0a9e8970 mruby-bigint/bigint.c: remove a condition to stop warnings 2023-03-13 08:06:41 +09:00
Yukihiro "Matz" Matsumoto 9cf49d08b4 mruby/throw.h: do not use __builtin_setjmp for GCC; close #5950
https://gcc.gnu.org/onlinedocs/gcc/Nonlocal-Gotos.html
2023-03-13 08:05:55 +09:00
Yukihiro "Matz" Matsumoto 924d605712 vm.c: remove redundant assignment (already done in cipush) 2023-03-13 08:05:55 +09:00
Yukihiro "Matz" Matsumoto 0edb616f51 gc.c: remove time profiling code for debugging 2023-03-13 08:05:54 +09:00
Yukihiro "Matz" Matsumoto a8d840da19 Merge pull request #5928 from dearblue/task/install
Improved `rake install`
2023-03-13 08:05:20 +09:00
Yukihiro "Matz" Matsumoto 938ad70e1e Merge pull request #5938 from dearblue/reorganize-gem-init-final
Reorganize gem init final
2023-03-13 07:52:20 +09:00
dearblue 1432baec1d Perform chores with mrb_final_mrbgems() function
The main purpose is to ignore exceptions raised by the GEMS finalizer.
2023-03-12 14:31:10 +09:00
dearblue c474ae8cc4 Perform chores with mrb_init_mrbgems() function
Make the `mrb_init_mrbgems()` function do the cleanup and error handling.
Instead, simplify processing in the `GENERATED_TMP_mrb_XXX_gem_init()` function.

Previously, `mrb_load_irep()` or `mrb_load_proc()` would kill the process when an exception occurred.
With this patch, it is now caught by `mrb_core_init_protect()`.
2023-03-12 10:25:54 +09:00
Yukihiro "Matz" Matsumoto 629d81f57b Merge pull request #5937 from dearblue/note-gem-init
Add the generator path to the `build/***/gem_init.c` file
2023-03-12 08:01:38 +09:00
Yukihiro "Matz" Matsumoto 894ce40797 Merge pull request #5946 from dearblue/const-search
Don't switch constant search path from modules to Object
2023-03-11 16:19:53 +09:00
Yukihiro "Matz" Matsumoto 90e53cad39 Merge pull request #5945 from dearblue/env-internal
Avoid exposure for `REnv` objects
2023-03-11 16:18:28 +09:00
Yukihiro "Matz" Matsumoto 7f79ca2cf6 mruby-compiler: need to adjust the line number for do_block; fix #5949 2023-03-11 15:49:35 +09:00
Yukihiro "Matz" Matsumoto 927a9df453 mruby-data/data.c: allow empty Data 2023-03-10 08:52:06 +09:00
Yukihiro "Matz" Matsumoto c212edec5f mruby-struct/struct.c: allow empty Struct when a name is not given 2023-03-10 08:52:06 +09:00
Yukihiro "Matz" Matsumoto fc4fe48a00 mruby-time/time.c: fix error message from localtime_r(3) failure 2023-03-10 08:52:06 +09:00
Yukihiro "Matz" Matsumoto 13cd0e5585 mruby-time/time.c (mrb_time_minus): specify mrb_float directly
The `typedef mrb_sec` does not improve readability at all.
2023-03-10 08:52:06 +09:00
Yukihiro "Matz" Matsumoto e62d672ef3 mruby-time/time.c (mrb_to_time_t): support Bigint if defined 2023-03-10 08:52:06 +09:00
Yukihiro "Matz" Matsumoto 01233f70bd mruby-bigint/bigint.c: add two new functions to convert to 64bit int
- mrb_bint_as_int64()
- mrb_bint_as_uint64()
2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto c71408bc0a mruby-time/time.c (mrb_to_time_t): raise error if obj is not time
Or a time-compatible object like a number.
2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto 7096d277da mruby-time/time.c: support bigint to time_t if necessary 2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto da8c23524f mruby-time/time.c (mrb_to_time_t): use floor instead of llround
Since we should generate `t=(sec+usec)` from a floating point number
`sec` should be `floor(f)` especially for negative numbers, if the place
for `usec` is specified. In contrast, we can `round` the below point
digits if we are going to ignore them. But we now use `round` instead of
`llround` which directly convert `double` to `long long`, to add
boundary check for conversion.
2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto 2f0265d078 mruby-io/io.c (check_file_descriptor): stop "unused label" warning 2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto 9a3199cadd mruby-io/file.c: atime, ctime, mtime to return Bigint if possible 2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto a3b84fbb08 mruby-bigint/bigint.c: add 2 new functions for 64 bit integer
- mrb_bint_new_int64()
- mrb_bint_new_uint64()
2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto b1d0a3d3aa etc.c (mrb_float_id): define the function only when necessary 2023-03-10 08:52:04 +09:00
Yukihiro "Matz" Matsumoto e5de08b692 mruby-time/time.c (time_mktime): should allow year before 1900
If the platform use 64 bit time_t, it is possible to represent the year
before 1903. So we should remove this check.
2023-03-10 08:52:04 +09:00
Yukihiro "Matz" Matsumoto bcd595ad1b mruby-bigint/bigint.c: add else to skip if check 2023-03-10 08:52:04 +09:00
Yukihiro "Matz" Matsumoto f1ffedc3fa vm.c: kdict may be converted to a normal argument; fix #5944 2023-03-10 08:52:04 +09:00
Yukihiro "Matz" Matsumoto 18158c96f5 Merge pull request #5948 from dearblue/cinfo
Added note to `CINFO_*` constants
2023-03-10 08:50:26 +09:00
Yukihiro "Matz" Matsumoto 840953b55a Merge pull request #5947 from dearblue/fiber-resume
Remove unreachable codes in `Fiber#resume`
2023-03-10 08:49:12 +09:00
dearblue ddaf3bdc0f Added note to CINFO_* constants 2023-03-09 22:13:52 +09:00
dearblue f4c4809750 Remove unreachable codes in Fiber#resume
ref. #5782
2023-03-09 21:40:03 +09:00
dearblue 9c9be44a98 Don't switch constant search path from modules to Object
Previously, for example, it was possible to retrieve the `String` class as follows:

```console
% bin/mruby -e 'p Comparable::Enumerable::Errno::GC::Kernel::Math::ObjectSpace::String'
String
```

Note that this patch affects the API function `mrb_const_get()`.
2023-03-05 20:32:56 +09:00
dearblue 38d5ed44e1 Avoid exposure for REnv objects
The `REnv` object is difficult to deal with, and it would be ideal if the user did not have to manipulate it directly.
In some previous situations, it was necessary to call `mrb_env_unshare()`, a non-API function, after `mrb_load_string()` or similar.

With this patch, it is no longer necessary for users to use `mrb_env_unshare()` directly, as it is now handled internally simply by using the `mrb_vm_ci_env_clear()` function.
Also, `mrb_vm_ci_env_set()` is demoted from the `MRB_API` function for the same reason.

ref. commit 1ab3da6f08
2023-03-05 17:45:47 +09:00
Yukihiro "Matz" Matsumoto 45ee9cc404 mruby-socket/socket.c: read/write should be redefined on Windows; fix #5943
Since normal file descriptors and sockets cannot be mixed on the
platform.
2023-03-04 09:27:43 +09:00
Yukihiro "Matz" Matsumoto 42d3efee1c mruby-socket/socket.c: read/write should be redefined on Windows; fix #5943
Since normal file descriptors and sockets cannot be mixed on the
platform.
2023-03-03 15:30:51 +09:00
Yukihiro "Matz" Matsumoto 011edf6e99 mruby-io/file.c: hide internal methods in backtraces 2023-03-03 14:23:10 +09:00
Yukihiro "Matz" Matsumoto 5237b2cccc mruby-io/file.c: atime, ctime, mtime check mrb_int overflow
When `sizeof(time_t)` is different from `mrb_int`, overflow may happen.
2023-03-03 14:21:05 +09:00
Yukihiro "Matz" Matsumoto 0e51da81bb mruby-io/file.rb (inspect): include path in the #inspect output 2023-03-03 13:33:30 +09:00
Yukihiro "Matz" Matsumoto a956ef35a4 mruby-io/file.c: atime, ctime, mtime should raise error
For fstat(3) failure.
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto 9c6848a594 mruby-io/io.c (check_file_descriptor): only check EBADF 2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto 0529f5fc31 mruby-io/test/file.rb: add tests for File#atime, File#ctime 2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto 321cfe9760 mruby-io/file.c: add File#atime and File#ctime 2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto 31c1b7bc78 mruby-file: File#mtime has been available for long time 2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto 84a4d340a6 mruby-io/file.c (_mtime): return nil instead of false
As a Ruby convention, a method should return nil (not false) for the
exceptional value, e.g. String#index. File#_mtime should follow the
convention too.
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto d86c4a795d mruby-io does not provide to_path method for implicit conversion
mruby does not use implicit type conversion by `to_xxx` (e.g. to_int,
to_str, etc.)
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto d7f4af04ca Merge pull request #5939 from jbampton/appveyor-add-visual-studio-2022
appveyor: add job for Visual Studio 2022
2023-03-02 15:08:50 +09:00
Yukihiro "Matz" Matsumoto bdf39fe4af Merge pull request #5940 from jbampton/remove-misspell
Remove `misspell` and update `CONTRIBUTING.md`
2023-03-01 23:47:41 +09:00
Yukihiro "Matz" Matsumoto 0d35fe072e Merge pull request #5941 from jbampton/simplify-the-editorconfig-file 2023-03-01 23:42:08 +09:00
John Bampton a874b80dae Simplify the .editorconfig file
We already have `trailing-whitespace` set globally in the `pre-commit` config
and we are also using `spaces` instead of `tabs` except for "Makefiles" which have `tab_width = 8`

Perhaps in future we can enforce line lengths.

https://github.com/mruby/mruby/blob/92ca93c885a6e6d2facd8e9ca3dbf85ac3dce8c9/.pre-commit-config.yaml#L29

https://github.com/mruby/mruby/blob/92ca93c885a6e6d2facd8e9ca3dbf85ac3dce8c9/.pre-commit-config.yaml#L33
2023-03-01 21:34:23 +10:00
John Bampton 2559c93b2b Remove misspell and update CONTRIBUTING.md
It looks like `misspell` is no longer maintained and
the last commit was on `Mar 9, 2018`.

We already run `codespell` and it is an active project
with the last commit 5 days ago.

Also updated the CONTRIBUTING guide with more
information on `pre-commit` as well as listed `codespell`
as the spell checker.

https://github.com/codespell-project/codespell
https://github.com/client9/misspell
https://github.com/client9/misspell/issues/197
2023-03-01 17:49:39 +10:00
John Bampton 47dcb393ca appveyor: add job for Visual Studio 2022
Visual Studio 2022 on Windows is now a 64-bit application.

https://www.appveyor.com/docs/build-environment/#build-worker-images

https://learn.microsoft.com/en-us/visualstudio/ide/whats-new-visual-studio-2022?view=vs-2022#visual-studio-2022-is-64-bit
2023-03-01 03:21:46 +10:00
dearblue 396ca2809f Add the generator path to the build/***/gem_init.c file 2023-02-28 22:11:14 +09:00
Yukihiro "Matz" Matsumoto 92ca93c885 Merge pull request #5936 from jbampton/remove-duplicate-method-calls
benchmark: remove duplicate method calls
2023-02-25 22:10:28 +09:00
Yukihiro "Matz" Matsumoto b59832ed26 Merge pull request #5935 from jbampton/upgrade-doxyfile
Upgrade the `Doxyfile`
2023-02-25 22:09:36 +09:00
John Bampton d86f4d220f benchmark: remove duplicate method calls
DuplicateMethodCall: Scene#render calls 'nsf * nsf' 3 times
2023-02-25 15:22:49 +10:00
John Bampton 5dd0f74ecf Upgrade the Doxyfile
```
mruby % doxygen -u
warning: Tag 'CLANG_ASSISTED_PARSING' at line 50 of file 'Doxyfile' belongs to an option that was not enabled at compile time.
         This tag has been removed.
warning: Tag 'CLANG_OPTIONS' at line 51 of file 'Doxyfile' belongs to an option that was not enabled at compile time.
         This tag has been removed.
warning: Tag 'TCL_SUBST' at line 238 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'COLS_IN_ALPHA_INDEX' at line 1075 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'FORMULA_TRANSPARENT' at line 1481 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'LATEX_SOURCE_CODE' at line 1769 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'RTF_SOURCE_CODE' at line 1851 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'DOCBOOK_PROGRAMLISTING' at line 1949 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'PERL_PATH' at line 2094 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'CLASS_DIAGRAMS' at line 2107 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'MSCGEN_PATH' at line 2116 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'DOT_FONTNAME' at line 2158 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'DOT_FONTSIZE' at line 2165 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'DOT_TRANSPARENT' at line 2391 of file 'Doxyfile' has become obsolete.
         This tag has been removed.

Configuration file 'Doxyfile' updated.
```
2023-02-25 12:55:53 +10:00
Yukihiro "Matz" Matsumoto ee599b25c1 Merge pull request #5934 from jbampton/rake-checkupdate
Run `rake checkupdate`
2023-02-25 09:26:26 +09:00
Yukihiro "Matz" Matsumoto f8a66c88b8 Merge pull request #5933 from jbampton/update-mruby-version-numbers
docs: update mruby version to `3.2.0`
2023-02-25 09:26:03 +09:00
John Bampton d4dd75b82c Run rake checkupdate
`pre-commit autoupdate`
2023-02-25 08:12:50 +10:00
John Bampton 46e42b38f0 docs: update mruby version to 3.2.0 2023-02-25 08:02:45 +10:00
Yukihiro "Matz" Matsumoto 82c67d52fc Merge pull request #5931 from mruby/stable
Merge mruby 3.2.0
2023-02-24 23:19:09 +09:00
mimaki 87260e7bb1 Update version and release date. (mruby 3.2.0 (2023-02-24)) 2023-02-24 19:51:12 +09:00
Yukihiro "Matz" Matsumoto 1ab3da6f08 vm.c (ci_env_set): inline ci_env_set()
Along with making preparing mrb_vm_ci_env_clar() as a replacement of
mrb_vm_ci_env_set(mrb, NULL).
2023-02-23 17:16:10 +09:00
Yukihiro "Matz" Matsumoto 2c046eb512 mruby.h: replace frequently used inline functions with macros
- mrb_gc_arena_save()
- mrb_gc_arena_restore()
2023-02-22 16:35:14 +09:00
Yukihiro "Matz" Matsumoto d8d1fe27f6 vm.c (stack_extend): inline mrb_stack_extend() in vm.c 2023-02-22 12:05:46 +09:00
Yukihiro "Matz" Matsumoto 43922a5bf9 vm.c (mrb_gc_arena_shrink): use local variable 2023-02-21 21:59:42 +09:00
Yukihiro "Matz" Matsumoto a21edf75ad Use mrb_get_arg1() instead of mrb_get_args() for single argument 2023-02-21 16:33:15 +09:00
Yukihiro "Matz" Matsumoto aecbdf72bf vm.c (mrb_env_unshare): remove unnecessary mrb_write_barrier() call
Since this function does not modify references from env, we don't need
to put write barrier here.
2023-02-21 09:45:17 +09:00
Yukihiro "Matz" Matsumoto d4cb136deb kernel.c (mrb_obj_ceqq): skip unnecessary mrb_ary_entry()
We have checked the boundary before the call.
2023-02-20 17:33:52 +09:00
Yukihiro "Matz" Matsumoto 76157c5f78 add inline specifier to frequently called functions
- entry_deleted_p(): hash.c
- ensure_block(): vm.c
2023-02-19 19:06:37 +09:00
Yukihiro "Matz" Matsumoto 7cbe6894b4 debug.c (mrb_debug_get_position): avoid duplicate calls to get_file() 2023-02-19 19:05:54 +09:00
Yukihiro "Matz" Matsumoto 78137f31c8 error.c (mrb_make_exception): reinvent exception creation
The arguments of mrb_make_exception() has changed. I believe no one is
using the function, but beware.
2023-02-18 11:51:33 +09:00
Yukihiro "Matz" Matsumoto 431f83eb8c error.c (mrb_make_exception): make the function internal 2023-02-17 17:04:09 +09:00
Yukihiro "Matz" Matsumoto 515b2fd144 class.c (mrb_method_added): skip mrb_funcall_id() is possible
When `method_added` is not redefined, we don't need to call it since its
default implementation does nothing.
2023-02-16 09:38:26 +09:00
Yukihiro "Matz" Matsumoto 2768fd62a0 Reduce calls to mrb_obj_is_kind_of() 2023-02-15 11:45:10 +09:00
Yukihiro "Matz" Matsumoto 235aaafef2 array.c (mrb_ary_aset): remove unnecessary ary_modify()
The `ary_modify()` is called in subsidiary functions.
2023-02-14 23:45:10 +09:00
Yukihiro "Matz" Matsumoto 4384a87516 class.c, vm.c: use loop variable declaration in for statement 2023-02-13 14:16:53 +09:00
Yukihiro "Matz" Matsumoto 58aefd6010 class.c, vm.c: use NULL instead of 0 for pointers 2023-02-13 14:16:30 +09:00
Yukihiro "Matz" Matsumoto ea0e8f7ea4 numeric.c (flo_mod): use NULL instead of 0
In C, we don't use 0 as NULL representation.
2023-02-13 00:08:40 +09:00
dearblue 7c7ed3c27a Write symbolik links or batch files in INSTALL_DIR
Since `bin/mruby-config` now points to a directory relative to itself, it is no longer possible to reach `include/` or `lib/`.
Therefore, avoid placing entities in them.
2023-02-12 23:25:05 +09:00
dearblue 11513bae43 Make bin/mruby-config output a directory based on itself 2023-02-12 23:25:01 +09:00
dearblue 3d996a84cc Takes the environment variable DESTDIR in rake install
If the environment variable `DESTDIR` is set, the writing destination is `<DESTDIR>/<PREFIX>/...`.
It is assumed to be used for package work.
2023-02-12 21:02:31 +09:00
dearblue 0e9a71e50a Install other build targets with rake install:full
Build targets other than "host" will be installed under `<PREFIX>/mruby/<build-name>`.
This can be changed with `build.install_prefix = dir`.
2023-02-12 21:02:30 +09:00
dearblue 7fd7409bf2 Files copied by task install should be from the build directory 2023-02-12 21:02:29 +09:00
dearblue aac2fd7055 Copy header files to the build directory
This is so that the build directory can be regarded as a temporary installation directory to work in.

Directories set in `MRuby::Gem::Specification#export_include_paths` are used as they are if they are subdirectories placed under `gem.dir`.
Files are placed under `<build-dir>/include/mruby/gems/<gem-name>/<gem-include_paths>` to separate each GEM.

When GEM is compiled by building `libmruby.a`, the same `include_paths` will be set as before, so it is expected that no unintended references will be made.
2023-02-12 21:02:28 +09:00
dearblue c020d8507e Separate rake install related stuff into tasks/install.rake 2023-02-12 21:02:27 +09:00
Yukihiro "Matz" Matsumoto 4f9caea891 range.c (range_num_to_a): add array entries directly
Calling `mrb_ary_push()` is slower.
2023-02-11 16:13:33 +09:00
Yukihiro "Matz" Matsumoto 2adb1043f4 array.c (mrb_ary_push_m): call mrb_ary_push() when argc == 1 2023-02-11 14:23:48 +09:00
Yukihiro "Matz" Matsumoto b4c936b533 use new E_EXCEPTION and E_STANDARD_ERROR; ref #5924 2023-02-10 15:21:38 +09:00
Yukihiro "Matz" Matsumoto 49709a65c7 AUTHORS: update entries [ci skip] 2023-02-10 15:21:38 +09:00
Yukihiro "Matz" Matsumoto bed7a79add Merge pull request #5927 from jbampton/remove-unneeded-whitespace
md/yml: remove unneeded blank lines and whitespace
2023-02-10 14:24:47 +09:00
Yukihiro "Matz" Matsumoto 7373b63919 Merge pull request #5926 from jbampton/update-license-year
Update License year to 2023
2023-02-10 14:23:32 +09:00
John Bampton 07a7d2a6cb md/yml: remove unneeded blank lines and whitespace 2023-02-10 14:02:57 +10:00
John Bampton 8af0aa4905 Update License year to 2023 2023-02-10 11:55:32 +10:00
mimaki 4ca2129889 Update version to 3.2.0RC4. 2023-02-08 10:04:29 +09:00
Yukihiro "Matz" Matsumoto fc53cd20b6 Merge pull request #5925 from jbampton/update-authors-file
AUTHORS: update "as of" info for `year`
2023-02-08 06:38:31 +09:00
Yukihiro "Matz" Matsumoto 75bdb4e0ec Merge pull request #5924 from dearblue/exception-classes
Improve consistency of how error classes are retrieved
2023-02-08 06:30:34 +09:00
Yukihiro "Matz" Matsumoto 8a2bb9eb93 Merge pull request #5923 from dearblue/mrb_f_raise
Demotion `mrb_f_raise()` from `MRB_API`
2023-02-08 06:30:17 +09:00
John Bampton 5189d73d6d AUTHORS: update "as of" info for year
The AUTHORS file was last published on January 8th 2023
2023-02-08 03:29:10 +10:00
dearblue a93807f48f Improve consistency of how error classes are retrieved 2023-02-07 22:46:56 +09:00
dearblue 0898ce982e Demotion mrb_f_raise() from MRB_API
This function is the entity of the `Kernel.#raise` or `Kernel#fail` method.
I don't think users can use it whenever they want, and I don't think there is any need to expose it as an entity of a user-defined method.
2023-02-07 22:37:58 +09:00
Yukihiro "Matz" Matsumoto 056cda72be mruby-bin-mirb: fix multi-line input issue; fix #5922
Bison changed the message for the end-of-file error. `mirb` should
be updated for the new message.
2023-02-07 17:43:14 +09:00
Yukihiro "Matz" Matsumoto 762ca43c16 mruby-bin-mirb: add bintest for multi-line input; ref #5922 2023-02-07 17:42:56 +09:00
Yukihiro "Matz" Matsumoto 78141d17f1 mruby-bin-mirb: fix multi-line input issue; fix #5922
Bison changed the message for the end-of-file error. `mirb` should
be updated for the new message.
2023-02-07 15:45:11 +09:00
Yukihiro "Matz" Matsumoto a25755060c mruby-bin-mirb: add bintest for multi-line input; ref #5922 2023-02-07 15:44:50 +09:00
Yukihiro "Matz" Matsumoto 6ca1b8e4e7 mruby-catch/catch.c: update disasm comment for new output format 2023-02-06 11:21:52 +09:00
Yukihiro "Matz" Matsumoto 7e607c67f2 codedump.c: adjust output format for ireps and literals
- I(%d:%p) -> I[%d]
- L(%d) -> L[%d]

The irep address is not useful, so just print index in reps table.
And use `[]` instead of `()` to clarify they are index.
2023-02-06 11:13:48 +09:00
Yukihiro "Matz" Matsumoto 1e122f7887 mruby-catch/catch.c: add disassembled comment for catch irep 2023-02-05 22:53:11 +09:00
Yukihiro "Matz" Matsumoto acecee0da1 mruby-print/print.c: rename __printstr__ to __printstr
As a convention other internal methods are prefixed by `__`.
2023-02-04 18:58:07 +09:00
Yukihiro "Matz" Matsumoto 1273c04e26 mruby-print/print.rb: update ISO references 2023-02-04 18:57:43 +09:00
Yukihiro "Matz" Matsumoto 8c8bbd94dc error.c: add new error handling API functions; ref #2837
- mrb_clear_error(): clear error status of mrb_state
- mrb_check_error(): check if error caused in the previous API

Note that `mrb_check_error` clears error status, so if you call
`mrb_check_error` more than once, latter calls will return FALSE.
2023-02-03 14:28:24 +09:00
Yukihiro "Matz" Matsumoto f5a7b6aad2 hash.rb: defer local variable initialization 2023-02-02 22:45:30 +09:00
Yukihiro "Matz" Matsumoto 1b299addaf mruby-hash-ext/hash.rb: implement Hash#compact! in C
Using `__compact` method defined in the core, since hash access
functions are private to `src/hash.c`.
2023-02-02 22:44:04 +09:00
Yukihiro "Matz" Matsumoto 9cda737a56 mruby-hash-ext/test: test Hash#compact! returns nil if unmodified 2023-02-02 22:42:36 +09:00
Yukihiro "Matz" Matsumoto 0a1fd07910 mruby-time/time.c: implement weekday methods in C 2023-02-01 14:33:46 +09:00
Yukihiro "Matz" Matsumoto ecd2d8c11e wrap method arguments by parentheses as convention 2023-02-01 14:33:46 +09:00
Yukihiro "Matz" Matsumoto caac15e8e1 Merge pull request #5919 from jbampton/make-rake-add-target
Makefile/Rakefile add target/task for `pre-commit install`
2023-02-01 14:29:40 +09:00
Yukihiro "Matz" Matsumoto 2dcc7346b4 Merge pull request #5918 from jbampton/actions-checkout-name-info
gha: full details for `actions/checkout` name
2023-02-01 14:28:40 +09:00
John Bampton 2bb6eeb7c0 Makefile/Rakefile add target/task for pre-commit install 2023-02-01 13:14:23 +10:00
John Bampton 5532d176e1 gha: full details for actions/checkout name 2023-02-01 02:00:56 +10:00
John Bampton 7d4200df84 Remove super-linter.report folder
The `super-linter.report` folder does not seem to be listed anymore on https://github.com/github/super-linter
2023-01-31 22:46:39 +10:00
Yukihiro "Matz" Matsumoto d41ea96c2a string.c: fix boundary check in String#bytesplice
It should be able to append to the receiver.
2023-01-29 17:10:15 +09:00
Yukihiro "Matz" Matsumoto a2e2e83012 string.c: move String#bytesplice to the core 2023-01-28 16:43:40 +09:00
Yukihiro "Matz" Matsumoto 12e232c006 mruby-string-ext/string.rb: add test for String#bytesplice 2023-01-28 16:41:40 +09:00
Yukihiro "Matz" Matsumoto 52746479a3 mruby-string-ext/string.c: new method String#byteslice 2023-01-27 23:22:02 +09:00
Yukihiro "Matz" Matsumoto 7b27346386 mruby-os-memsize/memsize.c: avoid mrb_get_args() 2023-01-26 11:14:10 +09:00
Yukihiro "Matz" Matsumoto 78bbf75981 mruby-random/random.c: avoid mrb_get_args() 2023-01-26 11:13:48 +09:00
Yukihiro "Matz" Matsumoto 4e85e855cf numeric.c: avoid mrb_get_args() if possible 2023-01-25 14:10:43 +09:00
Yukihiro "Matz" Matsumoto 4e5be5a288 array.c: avoid slower mrb_get_args() if possible 2023-01-25 14:10:03 +09:00
Yukihiro "Matz" Matsumoto 37da677cc8 numeric.c (mrb_int_pow): avoid unnecessary calls to mrb_get_args() 2023-01-24 15:25:06 +09:00
Yukihiro "Matz" Matsumoto d1449c2622 array.c (mrb_ary_times): avoid multiple calls to mrb_get_args() 2023-01-24 15:23:30 +09:00
Yukihiro "Matz" Matsumoto d9bf3235d2 mruby-math/math.c: avoid mrb_get_args() if possible
When a method takes single argument, we can use lighter `mrb_get_arg1()`
instead of `mrb_get_args()`.
2023-01-24 09:15:20 +09:00
mimaki 6b82843e72 Update version to 3.2.0RC3. 2023-01-23 10:16:15 +09:00
mimaki b40ab7bfee Merge branch 'master' into stable 2023-01-23 09:54:02 +09:00
Yukihiro "Matz" Matsumoto aefc5befbd mruby-io/io.c: fix issues with gets; fix #5913
- gets with RS multiple times
- gets with RS with limit
- gets with limit bigger than buffer size
2023-01-23 07:30:40 +09:00
Yukihiro "Matz" Matsumoto be5266fbe6 mruby-io/test: test gets with RS multiple times; ref #5913 2023-01-23 07:26:40 +09:00
Yukihiro "Matz" Matsumoto 4d5aadfc84 class.c (create_method_value): refactor mrb_method_t creation 2023-01-23 00:17:32 +09:00
Yukihiro "Matz" Matsumoto 079244c36a src/class.c: add new function mrb_vm_find_method
The function skips `cp` dereference, and improve performance of method
calls slightly.
2023-01-23 00:17:32 +09:00
Yukihiro "Matz" Matsumoto 6b0efd43da NEWS: copy entries from doc/mruby3.2.md 2023-01-23 00:17:32 +09:00
Yukihiro "Matz" Matsumoto 2e9f62b12c Merge pull request #5914 from dearblue/doc/mruby3.2.md
Update mruby3.2.md for changes behavior of `mrb_vm_run()`
2023-01-22 22:49:57 +09:00
Yukihiro "Matz" Matsumoto 3c02c517ca Merge pull request #5915 from dearblue/doc/mruby3.2.md.1
Update mruby3.2.md for new `mruby-data` gem
2023-01-22 22:49:05 +09:00
dearblue 998ef1711a Update mruby3.2.md for new mruby-data gem 2023-01-22 20:52:09 +09:00
dearblue a223778ee8 Update mruby3.2.md for changes behavior of mrb_vm_run() 2023-01-22 20:45:57 +09:00
Yukihiro "Matz" Matsumoto 882bb0662a Merge pull request #5912 from dearblue/io-popen
Replaced `NO_IO_POPEN` with `MRB_NO_IO_POPEN`
2023-01-22 13:37:39 +09:00
dearblue b0e537c05c Replaced NO_IO_POPEN with MRB_NO_IO_POPEN
ref. commit 9deb52c7b2
2023-01-22 09:20:10 +09:00
Yukihiro "Matz" Matsumoto 97fe582d41 Merge pull request #5911 from dearblue/eval+binding
Fixed `Kernel#.eval` crash when given a custom defined `Binding` instance
2023-01-20 22:44:28 +09:00
dearblue 36f822d9af Fixed Kernel#.eval crash when given a custom defined Binding instance
```console
% bin/mruby -e 'class Binding; end; eval "1", Binding.new'
zsh: segmentation fault (core dumped)  bin/mruby -e 'class Binding; end; eval "1", Binding.new'
```
2023-01-20 21:26:21 +09:00
mimaki b4f36b1ad9 Merge branch 'master' into stable 2023-01-18 10:45:35 +09:00
Yukihiro "Matz" Matsumoto 3a7e138c05 mruby/internal.h: add mrb_env_new to the internal function header 2023-01-18 10:37:48 +09:00
Yukihiro "Matz" Matsumoto e6cf932d38 fixup! mruby/internal.h: add codedump functions to the internal function header 2023-01-18 10:37:48 +09:00
Yukihiro "Matz" Matsumoto 55eea005c8 mruby/internal.h: add codedump functions to the internal function header
ref #5906
2023-01-18 10:37:48 +09:00
mimaki 23aa5f91bc Update version to 3.2.0RC2. 2023-01-18 10:26:58 +09:00
mimaki 830f88c5a0 Merge commit '9deb52c7b2ba6028d996172bfdd6cf8a0405ce1c' into stable 2023-01-18 09:45:23 +09:00
Yukihiro "Matz" Matsumoto 3639feb047 Merge pull request #5908 from dearblue/env-unshare.2
Make `mrb_env_unshare()` call in `mrb_vm_run()`
2023-01-18 08:05:00 +09:00
Yukihiro "Matz" Matsumoto 63597cbbd1 Merge pull request #5910 from mruby/dependabot/github_actions/github/super-linter-4.10.1
build(deps): bump github/super-linter from 4.10.0 to 4.10.1
2023-01-18 07:53:11 +09:00
Yukihiro "Matz" Matsumoto faa6a5cb4f Merge pull request #5906 from AlexDenisov/codedump-to-file
Add ability to dump bytecode into an arbitrary file
2023-01-18 07:37:12 +09:00
AlexDenisov e15288e460 Add ability to dump bytecode into an arbitrary file 2023-01-17 19:01:55 +01:00
dependabot[bot] 823b8e4148 build(deps): bump github/super-linter from 4.10.0 to 4.10.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.10.0 to 4.10.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.10.0...v4.10.1)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-17 14:01:22 +00:00
Yukihiro "Matz" Matsumoto 9deb52c7b2 mruby-io/io.c: allow disabling popen
When `MRB_NO_IO_POPEN` is defined (or iPhone is target), `IO#popen`
will be disabled.
2023-01-17 18:25:23 +09:00
Yukihiro "Matz" Matsumoto 6b87aae757 doc/guides/compile.md: update compilation example
Show usage of multiple command-line options to `mruby-config`.
2023-01-17 18:23:29 +09:00
Yukihiro "Matz" Matsumoto 10768c1191 LEGAL: add entries for non-MIT licensed files. 2023-01-17 18:23:29 +09:00
Yukihiro "Matz" Matsumoto 2c261503b5 doc/internal/boxing.md: remove an extra double quote sign. 2023-01-16 19:01:11 +09:00
Yukihiro "Matz" Matsumoto 7a6d03f869 vm.c: transferred fiber termination should kick root fiber; fix #5907 2023-01-16 18:25:50 +09:00
Yukihiro "Matz" Matsumoto 3f6fd994f0 README.md: mruby is not Ruby 3.x compatible (for syntax at least)
With pattern matching as an exception.
2023-01-16 14:39:47 +09:00
dearblue 365c151df0 Make mrb_env_unshare() call in mrb_vm_run()
Move the detachment of the "env" object, now done by `mrb_top_run()` by #5904, to `mrb_vm_run()`.
This is because `mrb_vm_run()` can remove `mrb_env_unshare()` which is called from `bin/mirb`.

Also, even if the mruby VM is already running, either of the following conditions should be used to detach "env":
  - If the `stack_keep` variable is 0.
  - If the stack length of "env" is longer than `irep->nlocals`.

The reason for the change is that the stack beyond `irep->nlocals` is used inside the called method, and previously it was possible to reference and manipulate the state inside the method via "env".

    env stack       |                           |

    main stack      | top |  m1  |    m2    |
                          |<--------------->|
                            operable via env stack (including self)

If the problematic block is called from the `m2` method above, it is possible to replace `self` in `m1` and `m2` as well as the internal variables.

This change may cause compatibility problems, but I believe it is better to make `MRB_API`, `mrb_vm_run()` safe.
If a dangerous procedure is absolutely necessary, `mrb_vm_exec()` can still be called as before.
2023-01-15 18:16:42 +09:00
dearblue e5108a6291 Fixed local variables not separated between copied binding objects
This is because I forgot to implement the `Binding#initialize_copy` method.
2021-08-03 23:20:34 +09:00
234 changed files with 10167 additions and 6960 deletions
+14
View File
@@ -0,0 +1,14 @@
.DS_Store
.idea
.vscode
*.bak
*.iml
*.ipr
*.swp
*.tmp
/.yardoc
/bin
/build
/doc/api
/doc/capi
+8 -18
View File
@@ -8,37 +8,27 @@ root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 8
indent_style = tab
indent_size = 2
indent_style = space
insert_final_newline = true
tab_width = 8
trim_trailing_whitespace = true
[{Makefile,Makefile.*,makefile,*.mk}]
trim_trailing_whitespace = true
indent_style = tab
#max_line_length = 80
[*.{c,cc,C,cxx,cpp,h,hh,H,hxx,hpp,inc,y}]
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
#[*.{c,cc,C,cxx,cpp,h,hh,H,hxx,hpp,inc,y}]
#max_line_length = 120
[{*.rb,Rakefile,rakefile,*.rake,*.gemspec,*.gembox}]
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
#[{*.rb,Rakefile,rakefile,*.rake,*.gemspec,*.gembox}]
#max_line_length = 120
# limitation to US-ASCII
[*.bat]
end_of_line = crlf
indent_style = space
#max_line_length = 80
[*.{yaml,yml}]
indent_size = 2
indent_style = space
#[*.{yaml,yml}]
[*.md]
indent_size = 2
indent_style = space
#[*.md]
+4
View File
@@ -0,0 +1,4 @@
* text=auto eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.png binary
+5 -2
View File
@@ -1,8 +1,11 @@
# Basic set up
version: 2
updates:
# Maintain dependencies for Ruby
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "daily"
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
+50
View File
@@ -0,0 +1,50 @@
benchmark:
- any:
- changed-files:
- any-glob-to-any-file:
- benchmark/**/*
build:
- any:
- changed-files:
- any-glob-to-any-file:
- Makefile
- Rakefile
- build_config/**/*
- lib/**/*
- tasks/**/*
core:
- any:
- changed-files:
- any-glob-to-any-file:
- include/**/*
- mrblib/**/*
- src/**/*
- test/**/*
doc:
- any:
- changed-files:
- any-glob-to-any-file:
- CONTRIBUTING.md
- LEGAL
- LICENSE
- NEWS
- README.md
- SECURITY.md
- TODO.md
- doc/**/*
- examples/**/*
github:
- any:
- changed-files:
- any-glob-to-any-file:
- .github/**/*
mrbgems:
- any:
- changed-files:
- any-glob-to-any-file:
- mrbgems/**/*
oss-fuzz:
- any:
- changed-files:
- any-glob-to-any-file:
- oss-fuzz/**/*
+6
View File
@@ -19,5 +19,11 @@ MD025: false
# MD026 no-trailing-punctuation - Trailing punctuation in heading
MD026: false
# MD033/no-inline-html - Inline HTML
MD033: false
# MD040 fenced-code-language - Fenced code blocks should have a language specified
MD040: false
# MD041 first-line-heading/first-line-h1 - First line in a file should be a top-level heading
MD041: false
+2
View File
@@ -4,6 +4,8 @@
extends: default
rules:
comments:
min-spaces-from-content: 1
document-start: disable
line-length: disable
truthy: false
+4 -2
View File
@@ -27,7 +27,8 @@ jobs:
CXX: ${{ matrix.cxx }}
LD: ${{ matrix.cc }}
steps:
- uses: actions/checkout@v3
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
- name: Ruby version
run: ruby -v
- name: Compiler version
@@ -41,7 +42,8 @@ jobs:
env:
MRUBY_CONFIG: ci/msvc
steps:
- uses: actions/checkout@v3
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
- name: Ruby version
run: ruby -v
- name: Build and test
-53
View File
@@ -1,53 +0,0 @@
name: Code scanning - action
on:
push:
branches-ignore:
- dependabot/**
pull_request:
schedule:
- cron: '0 19 * * 4'
permissions:
contents: read
jobs:
CodeQL-Build:
permissions:
actions: read # for github/codeql-action/init to get workflow details
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/autobuild to send a status report
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# - run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
+15
View File
@@ -0,0 +1,15 @@
# https://github.com/actions/labeler
name: Pull Request Labeler
on:
- pull_request_target
jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true
+3 -12
View File
@@ -1,3 +1,4 @@
# https://pre-commit.com/
name: Lint
on: [pull_request]
@@ -6,22 +7,12 @@ permissions:
contents: read
jobs:
misspell:
name: Check spelling with misspell
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v3
- name: Install
run: wget -O - -q https://git.io/misspell | sh -s -- -b .
- name: Run misspell
run: git ls-files --empty-directory | xargs ./misspell -error
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v3
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
- name: Install
run: |
python -m pip install --upgrade pip
+4 -3
View File
@@ -1,3 +1,4 @@
# https://github.com/google/oss-fuzz
name: CIFuzz
on: [pull_request]
permissions:
@@ -10,16 +11,16 @@ jobs:
- name: Build Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'mruby'
oss-fuzz-project-name: "mruby"
dry-run: false
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'mruby'
oss-fuzz-project-name: "mruby"
fuzz-seconds: 600
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: artifacts
+6 -5
View File
@@ -1,3 +1,4 @@
# https://github.com/super-linter/super-linter
name: Super-Linter
on: [pull_request]
@@ -8,18 +9,18 @@ permissions:
jobs:
build:
permissions:
contents: read # for actions/checkout to fetch code
statuses: write # for github/super-linter/slim to mark status of each linter run
contents: read # for actions/checkout to fetch code
statuses: write # for github/super-linter/slim to mark status of each linter run
name: Lint Code Base
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- name: Lint Code Base
uses: github/super-linter/slim@v4.10.0
uses: super-linter/super-linter/slim@v5.7.2
env:
ERROR_ON_MISSING_EXEC_BIT: true
VALIDATE_BASH: true
+12 -13
View File
@@ -1,8 +1,8 @@
*.lock
*.bak
*.bc
*.d
*.i
*.lock
*.o
*.orig
*.pdb
@@ -13,25 +13,24 @@
*.tmp
*~
.DS_Store
.ccls*
.ccmalloc
.svn
.vscode
.yardoc
.ccls*
compile_flags.txt
compile_commands.json
cscope.files
cscope.out
tags
/.git
/bin
/build
/mruby-source-*.gem
/benchmark/**/*.dat
/benchmark/*.pdf
/benchmark/*.png
/bin
/build
/doc/api
/doc/capi
/mruby-source-*.gem
compile_commands.json
compile_flags.txt
cscope.files
cscope.out
node_modules
tags
!Gemfile.lock
+23 -7
View File
@@ -3,14 +3,14 @@ default_stages: [commit, push]
default_language_version:
# force all unspecified Python hooks to run python3
python: python3
minimum_pre_commit_version: '2.18.1'
minimum_pre_commit_version: "2.18.1"
repos:
- repo: meta
hooks:
- id: identity
- id: check-hooks-apply
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
@@ -23,20 +23,22 @@ repos:
- id: detect-private-key
- id: end-of-file-fixer
- id: file-contents-sorter
args: [--unique]
files: ^codespell\.txt$
- id: fix-byte-order-marker
- id: forbid-submodules
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.3.1
rev: v1.5.4
hooks:
- id: forbid-tabs
exclude: Makefile$|Makefile\..+$|makefile$|\.mk$
- id: remove-tabs
args: [--whitespaces-count, '2']
args: [--whitespaces-count, "2"]
exclude: Makefile$|Makefile\..+$|makefile$|\.mk$
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.6
hooks:
- id: codespell
name: Run codespell
@@ -48,8 +50,13 @@ repos:
- id: script-must-not-have-extension
name: Local policy is to exclude extension from all shell files
types: [shell]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
exclude: ^doc/internal/opcode\.md$
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
rev: v0.38.0
hooks:
- id: markdownlint
name: Run markdownlint
@@ -57,8 +64,17 @@ repos:
entry: markdownlint -c .github/linters/.markdown-lint.yml .
types: [markdown]
files: \.(md|mdown|markdown)$
- repo: https://github.com/tcort/markdown-link-check
rev: v3.11.2
hooks:
- id: markdown-link-check
name: Run markdown-link-check
description: Checks hyperlinks in Markdown files
args: [-q]
types: [markdown]
files: \.(md|mdown|markdown)$
- repo: https://github.com/adrienverge/yamllint
rev: v1.28.0
rev: v1.33.0
hooks:
- id: yamllint
name: Run yamllint
+3
View File
@@ -0,0 +1,3 @@
{
"bracketSpacing": false
}
+15 -11
View File
@@ -1,10 +1,10 @@
# Authors of mruby (mruby developers)
## The List of Contributors sorted by number of commits (as of 2022-01-08 4462e3d)
## The List of Contributors sorted by number of commits (as of 2023-12-28 67cb987)
8860 Yukihiro "Matz" Matsumoto (@matz)*
9477 Yukihiro "Matz" Matsumoto (@matz)*
586 KOBAYASHI Shuji (@shuujii)
441 dearblue (@dearblue)*
533 dearblue (@dearblue)*
378 Daniel Bovensiepen (@bovi)*
346 Takeshi Watanabe (@take-cheeze)*
334 Masaki Muranaka (@monaka)
@@ -12,15 +12,15 @@
234 Jun Hiroe (@suzukaze)
220 Cremno (@cremno)*
209 Yuki Kurihara (@ksss)+
166 John Bampton (@jbampton)
151 Yasuhiro Matsumoto (@mattn)*
113 Carson McDonald (@carsonmcdonald)
113 John Bampton (@jbampton)
103 Tomasz Dąbrowski (@dabroz)*
84 Akira Yumiyama (@akiray03)*
84 skandhas (@skandhas)
81 Hiroshi Mimaki (@mimaki)*
80 Masamitsu MURASE (@masamitsu-murase)
74 Yuichiro MASUI (@masuidrive)
73 Hiroshi Mimaki (@mimaki)*
71 Tatsuhiko Kubo (@cubicdaiya)*
65 Yuichiro Kaneko (@yui-knk)+
64 Paolo Bosetti (@pbosetti)*
@@ -63,6 +63,7 @@
12 Kouki Ooyatsu (kaishuu0123)*
12 NAKAMURA Usaku (@unak)*
12 RIZAL Reckordp (@Reckordp)+
12 Ray Chason (@chasonr)*
12 Takashi Sawanaka (@sdottaka)*
12 Ukrainskiy Sergey (@ukrainskiysergey)
12 Xuejie "Rafael" Xiao (@xxuejie)*
@@ -73,7 +74,6 @@
11 takkaw (@takkaw)
10 Miura Hideki (@miura1729)
10 Narihiro Nakamura (@authorNari)
10 Ray Chason (@chasonr)*
10 Yuichi Nishiwaki (@nyuichi)
9 Akira Mitsui (@murasesyuka)*
9 Frank Celler (@fceller)
@@ -82,6 +82,7 @@
7 Bhargava Shastry (@bshastry)*
7 Kouichi Nakanishi (@keizo042)
7 Rubyist (@expeditiousRubyist)
7 SiZiOUS (@sizious)
7 Simon Génier (@simon-shopify)
7 Terence Lee (@hone)
7 Wataru Ashihara (@wataash)*
@@ -96,6 +97,7 @@
6 Kenji Okimoto (@okkez)+
6 Selman ULUG (@selman)
6 Yusuke Endoh (@mame)*
6 masahino (@masahino)
5 Chris Reuter (@suetanvil)
5 Davide D'Agostino (@DAddYE)
5 Eric Hodel (@drbrain)
@@ -104,20 +106,20 @@
5 Keita Obo (@ktaobo)*
5 Max Anselm (@silverhammermba)
5 Rodrigo Malizia (@rmalizia44)+
5 SiZiOUS (@sizious)
5 Syohei YOSHIDA (@syohex)
5 TOMITA Masahiro (@tmtm)
5 Yurie Yamane (@yurie)+
5 dreamedge (@dreamedge)
5 masahino (@masahino)
5 nkshigeru (@nkshigeru)
5 xuejianqing (@joans321)
4 Dante Catalfamo (@dantecatalfamo)
4 Goro Kikuchi (@gorogit)
4 Herwin Weststrate (@herwinw)
4 Horimoto Yasuhiro (@komainu8)
4 Jon Moss (@maclover7)
4 Ken Muramatsu (@ken-mu)+
4 Kohei Suzuki (@eagletmt)
4 Lanza (@LanzaSchneider)
4 Li Yazhou (@flaneur2020)
4 Marcus Stollsteimer (@stomar)
4 NARUSE, Yui (@nurse)
@@ -132,7 +134,6 @@
3 David Turnbull (@AE9RB)
3 Franck Verrot (@franckverrot)
3 HASUMI Hitoshi (@hasumikin)
3 Horimoto Yasuhiro (@komainu8)
3 J. Mutua (@katmutua)+
3 Jan Berdajs (@mrbrdo)
3 Jonas Minnberg (@sasq64)
@@ -141,6 +142,7 @@
3 Nobuhiro Iwamatsu (@iwamatsu)
3 Per Lundberg (@perlun)*
3 Rob Fors (@robfors)*
3 Robert Rowe (@CaptainJet)
3 Sebastián Katzer (@katzer)*
3 Shouji Kuboyama (@Shokuji)*
3 Shuta Kimura (@kimushu)+
@@ -173,7 +175,6 @@
2 Kazuhiko Yamashita (@pyama86)+
2 Kazuhiro Sera (@seratch)
2 Kuroda Daisuke (@dycoon)+
2 Lanza (@LanzaSchneider)
2 Lothar Scholz (@llothar)
2 Lukas Joeressen (@kext)
2 Masahiro Wakame (@vvkame)+
@@ -196,11 +197,13 @@
1 A-Sat (@asatou)+
1 Abinoam Praxedes Marques Junior (@abinoam)
1 Alex Wang (@nanamiwang)+
1 AlexDenisov (@AlexDenisov)
1 Andrew Nordman (@cadwallion)
1 Ashish Kurmi (@boahc077)
1 Atsushi Morimoto (@mynz)
1 Ben A Morgan (@BenMorganIO)
1 Benoit Daloze (@eregon)
1 Colin MacKenzie IV (@sinisterchipmunk)
1 Daehyub Kim (@lateau)
1 Daniel Varga (@vargad)
1 Edgar Boda-Majer (@eboda)
@@ -257,7 +260,6 @@
1 Prayag Verma (@pra85)
1 Ranmocy (@ranmocy)
1 Robert McNally (@wolfmcnally)
1 Robert Rowe (@CaptainJet)
1 Ryan Scott Lewis (@RyanScottLewis)
1 Ryo Okubo (@syucream)
1 SAkira a.k.a. Akira Suzuki (@sakisakira)
@@ -281,10 +283,12 @@
1 Yevhen Viktorov (@yevgenko)
1 Yoji SHIDARA (@darashi)
1 Yoshiori SHOJI (@yoshiori)
1 Yuji Yokoo (@yujiyokoo)
1 Yukang (@chenyukang)
1 Yurii Nakonechnyi (@inobelar)
1 Yusuke Suzuki (@Constellation)+
1 Yusuke Tanaka (@csouls)
1 alpha.netzilla (@alpha-netzilla)
1 arton (@arton)
1 duangsuse (@duangsuse)
1 fl0l0u (@fl0l0u)
+70 -14
View File
@@ -26,8 +26,8 @@ A framework for managing and maintaining multi-language `pre-commit` hooks.
You need to first install `pre-commit` and then install the `pre-commit` hooks with `pre-commit install`.
Now `pre-commit` will run automatically on git commit!
It's usually a good idea to run the hooks against all the files when adding new hooks (usually `pre-commit` will only run on the changed files during git hooks).
Use `pre-commit run --all-files` to check all files.
It's usually a good idea to run the hooks against all the files when adding new hooks (usually `pre-commit`
will only run on the changed files during git hooks). Use `pre-commit run --all-files` to check all files.
To run a single hook use `pre-commit run --all-files <hook_id>`
@@ -37,12 +37,16 @@ Sometimes you might need to skip one or more hooks which can be done with the `S
`$ SKIP=yamllint git commit -m "foo"`
For convenience, we have added `pre-commit run --all-files` and `pre-commit autoupdate`
For convenience, we have added `pre-commit run --all-files`, `pre-commit install` and `pre-commit autoupdate`
to both the Makefile and the Rakefile. Run them with:
- `make check` or `rake check`
- `make checkinstall` or `rake checkinstall`
- `make checkupdate` or `rake checkupdate`
To configure `pre-commit` you can modify the config file [.pre-commit-config.yaml](.pre-commit-config.yaml).
We use [GitHub Actions](.github/workflows/lint.yml) to run `pre-commit` on every pull request.
### pre-commit quick links
- [Quick start](https://pre-commit.com/#quick-start)
@@ -50,21 +54,73 @@ to both the Makefile and the Rakefile. Run them with:
- [pre-commit autoupdate](https://pre-commit.com/#pre-commit-autoupdate)
- [Temporarily disabling hooks](https://pre-commit.com/#temporarily-disabling-hooks)
## Spell Checking
## Docker
We are running [misspell](https://github.com/client9/misspell) which is mainly written in
[Golang](https://golang.org/) to check spelling with [GitHub Actions](.github/workflows/lint.yml).
Correct commonly misspelled English words quickly with `misspell`. You can run `misspell` locally
against all files with:
We have both a `Dockerfile` and `docker-compose.yml` files in the repository root.
You can run these with the command line or use
[Docker Desktop](https://www.docker.com/products/docker-desktop/).
```bash
find . -type f | xargs ./misspell -error
The Docker image is running Debian bullseye with Ruby and Python installed.
You can build the Docker image with:
`$ docker-compose build test`
So far we just have one service: `test`. Running the default `docker-compose`
command will create the Docker image, spin up a container and then build and
run all mruby tests.
The default `docker-compose` command is:
`$ docker-compose -p mruby run test`
You can also use Make or Rake to run the default `docker-compose`
command from above:
- `make composetest`
- `rake composetest`
List your Docker images with:
```console
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mruby-test latest ec60f9536948 29 seconds ago 1.29GB
```
Notable `misspell` help options or flags are:
You can also run any custom `docker-compose` command which will override
the default. For example to run `pre-commit run --all-files` type:
- `-i` string: ignore the following corrections, comma separated
- `-w`: Overwrite file with corrections (default is just to display)
`$ docker-compose -p mruby run test pre-commit run --all-files`
For convenience, you can also run `pre-commit` with:
- `make composecheck`
- `rake composecheck`
The bonus of running `pre-commit` with `docker-compose` is that you won't need
to install `pre-commit` and the hooks on your local machine. And that also
means you won't need to install `brew`, `conda` or `pip`.
Note limitation: currently running `pre-commit` with `docker-compose` we
skip the `check-executables-have-shebangs` hook.
Two more examples of custom `docker-compose` commands are:
- `$ docker-compose -p mruby run test ls`
- `$ docker-compose -p mruby run test rake doc:api`
If you want to test using a different `docker-compose` YAML config file you
can use the `-f` flag:
`$ docker-compose -p mruby -f docker-compose.test.yml run test`
- <https://docs.docker.com/compose/>
- <https://docs.docker.com/engine/reference/commandline/cli/>
## Spell Checking
We are using `pre-commit` to run [codespell](https://github.com/codespell-project/codespell)
to check code for common misspellings. We have a small custom dictionary file [codespell.txt](codespell.txt).
## Coding conventions
@@ -120,7 +176,7 @@ unless there's a clear reason, e.g. the latest Ruby has changed behavior from IS
### mruby API
- [YARD](https://yardoc.org/) - YARD is a documentation generation tool for the Ruby programming language
- [yard-mruby](https://rubygems.org/gems/yard-mruby) - Document MRuby sources with YARD
- [yard-mruby](https://rubygems.org/gems/yard-mruby) - Document mruby sources with YARD
- [yard-coderay](https://rubygems.org/gems/yard-coderay) - Adds coderay syntax highlighting to YARD docs
### C API
+13
View File
@@ -0,0 +1,13 @@
FROM ruby:3.2.2-bullseye
RUN apt-get update && apt-get install --no-install-recommends -y python3-pip shellcheck \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY Gemfile Gemfile.lock .pre-commit-config.yaml ./
RUN bundle install && pip3 install pre-commit && git init . && pre-commit install-hooks
COPY . .
+653 -320
View File
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
# frozen_string_literal: true
source 'https://rubygems.org'
gem 'rake'
gem 'yard'
gem 'yard-coderay'
gem 'yard-mruby'
+27
View File
@@ -0,0 +1,27 @@
GEM
remote: https://rubygems.org/
specs:
coderay (1.1.3)
rake (13.0.6)
webrick (1.7.0)
yard (0.9.28)
webrick (~> 1.7.0)
yard-coderay (0.1.0)
coderay
yard
yard-mruby (0.3.0)
yard (~> 0.9.0)
PLATFORMS
ruby
x86_64-darwin-21
x86_64-linux
DEPENDENCIES
rake
yard
yard-coderay
yard-mruby
BUNDLED WITH
2.4.10
+35
View File
@@ -3,3 +3,38 @@ LEGAL NOTICE INFORMATION
All the files in this distribution are covered under the MIT license
(see the file LICENSE) except some files mentioned below:
- src/readfloat.c: public domain by Yasuhiro Matsumoto (@mattn)
- src/fmt_fp.c: public domain by Dave Hylands (@dhylands)
- mrbgems/mruby-dir/src/Win/dirent.c: MIT-like license by Kevlin Henney
[src/readfloat.c]
strtod implementation.
author: Yasuhiro Matsumoto (@mattn)
license: public domain
The original code can be found in https://github.com/mattn/strtod
[src/fmt_fp.c]
The code in this function was inspired from Fred Bayer's pdouble.c.
Since pdouble.c was released as Public Domain, I'm releasing this
code as public domain as well.
Dave Hylands
The original code can be found in https://github.com/dhylands/format-float
[mrbgems/mruby-dir/src/Win/dirent.c] used only for Windows platform
Copyright Kevlin Henney, 1997, 2003, 2012. All rights reserved.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose is hereby granted without fee, provided
that this copyright and permissions notice appear in all copies and
derivatives.
This software is supplied "as is" without express or implied warranty.
But that said, if there are any problems please get in touch.
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2010-2022 mruby developers
Copyright (c) 2010- mruby developers
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
+12
View File
@@ -18,6 +18,18 @@ check :
pre-commit run --all-files
.PHONY : check
checkinstall :
pre-commit install
.PHONY : checkinstall
checkupdate :
pre-commit autoupdate
.PHONY : checkupdate
composecheck :
docker-compose -p mruby run test pre-commit run --all-files
.PHONY : composecheck
composetest :
docker-compose -p mruby run test
.PHONY : composetest
+87 -6
View File
@@ -1,12 +1,93 @@
NEWS
----
This document is a list of user visible feature changes made between
releases except for bug fixes.
# User visible changes in `mruby3.3` from `mruby3.2`
Note that each entry is kept so brief that no reason behind or
reference information is supplied with. For a full list of changes
with all sufficient information, see the ChangeLog file.
# The language
- aliases work properly with `super`
- `callee` method work differently with aliases in mruby
- define `Kernel#respond_to_missing?` method
- `_inspect` method (`inspect` with recursive check) is removed
- `__printstr` method is removed; use `print` instead
** Information about first release v1.0.0
# Configuration
- mruby can be built using Docker now. Try `docker-compose build` for example.
- New Platform: Nintendo Wii
- Improved Platforms: Android, Dreamcast
# mruby memory API
- `mrb_default_allocf` can be overridden by the application
- `mrb_open_allocf` will be deprecated
# mruby VM and bytecode
- [#5870](https://github.com/mruby/mruby/issues/5870) Use OP_LOADINEG instead of OP_LOADI
# Changes in mrbgems
- mruby-bin-config: new options --cxx,--cxxflags,--as,--asflags,--objc,--objcflags
- mruby-binding-eval (merged with mruby-eval) #5989
- mruby-binding: renamed from mruby-binding-core
- mruby-enumerator: remove internal attribute methods obj, args, kwd, meth, fib.
- mruby-fiber: Add a new mrb_fiber_new() with MRB_API
- mruby-fiber: Allows calling `Fiber#resume` from C
- mruby-fiber: `Fiber#to_s` format changed
- mruby-io: Add "x" mode option for IO.open
- mruby-method: `Method#to_s` format changed
- mruby-pack: support new directives j,J,b,B
- mruby-range-ext: new method `Range#overlap?`
- mruby-string-ext: Add `String#valid_encoding?` method
# Bugs Fixed
- [#5712](https://github.com/mruby/mruby/issues/5712) No "make install"
- [#5724](https://github.com/mruby/mruby/issues/5724) Rational#** is missing
- [#5725](https://github.com/mruby/mruby/issues/5725) weird const_missing exceptions in mrblib code
- [#5789](https://github.com/mruby/mruby/issues/5789) No memory release of backtrace information due to stack error
- [#5943](https://github.com/mruby/mruby/issues/5943) TCPSocket#write is failed
- [#5944](https://github.com/mruby/mruby/issues/5944) Behavior of calling method with a hash variable
- [#5949](https://github.com/mruby/mruby/issues/5949) Caller appears to report wrong line when block passed and brackets omitted
- [#5974](https://github.com/mruby/mruby/issues/5974) Invalid escape sequences in gem_init.c on windows
- [#5975](https://github.com/mruby/mruby/issues/5975) Equals comparison fails on extreme ends of 64-bit integers
- [#5985](https://github.com/mruby/mruby/issues/5985) Sign extension with OP_LOADI32 in get_int_operand()
- [#5986](https://github.com/mruby/mruby/issues/5986) Fix bugs in String#bytesplice
- [#5987](https://github.com/mruby/mruby/issues/5987) ~(-1 << 64) is incorrect
- [#5991](https://github.com/mruby/mruby/issues/5991) 'gets' method not working in mruby-3.2.0
- [#5995](https://github.com/mruby/mruby/issues/5995) One seemingly unnecessary parameter is passed in the block parameters
- [#6029](https://github.com/mruby/mruby/issues/6029) mruby build fails under mrbgems directory
- [#6041](https://github.com/mruby/mruby/issues/6041) GC Performance may have degraded
- [#6051](https://github.com/mruby/mruby/issues/6051) Null pointer dereference in mrb_addrinfo_unix_path
- [#6052](https://github.com/mruby/mruby/issues/6052) Null pointer dereference while handling the Proc class
- [#6065](https://github.com/mruby/mruby/issues/6065) Null pointer dereference while handling the Proc class
- [#6066](https://github.com/mruby/mruby/issues/6066) Null pointer dereference involving Struct.new()
- [#6067](https://github.com/mruby/mruby/issues/6067) Null pointer dereference in mrb_string_value_cstr
- [#6068](https://github.com/mruby/mruby/issues/6068) Stack overflow in mrb_vm_exec
- [#6087](https://github.com/mruby/mruby/issues/6087) 'Remote branch HEAD not found in upstream origin' error on build
- [#6089](https://github.com/mruby/mruby/issues/6089) binding.eval() handles def expressions differently from CRuby
- [#6098](https://github.com/mruby/mruby/issues/6098) Fails to call superclass of wrapped method
- [#6108](https://github.com/mruby/mruby/issues/6108) VM crashes with break
- [#6134](https://github.com/mruby/mruby/issues/6134) String#unpack1 returns an array instead of a single string
# Pull Requests (User Visible Ones)
- [#5870](https://github.com/mruby/mruby/pull/5870) Use OP_LOADINEG instead of OP_LOADI
- [#5966](https://github.com/mruby/mruby/pull/5966) Update default.gembox add mruby debugger mrdb
- [#5979](https://github.com/mruby/mruby/pull/5979) Allow Class#allocate to be prohibited
- [#5989](https://github.com/mruby/mruby/pull/5989) Integrate mruby-binding-eval into mruby-eval
- [#5961](https://github.com/mruby/mruby/pull/5961) Add Docker to build and run all mruby tests. Run pre-commit and generate YARD docs with Docker
- [#6008](https://github.com/mruby/mruby/pull/6008) Make "bintest" independent of directory
- [#6009](https://github.com/mruby/mruby/pull/6009) Avoid adding <MRUBY_ROOT>/bintest which does not exist
- [#6012](https://github.com/mruby/mruby/pull/6012) Allow tests to be disabled for specific gems; warn about disabled tests
- [#6013](https://github.com/mruby/mruby/pull/6013) Fix Android toolchain
- [#6032](https://github.com/mruby/mruby/pull/6032) Rake: update task clean to remove bin and build folders
- [#6045](https://github.com/mruby/mruby/pull/6045) Fixes escape sequence bug and enhancements in Presym scanning
- [#6076](https://github.com/mruby/mruby/pull/6076) Fixed unwinding block that could point to invalid PC
- [#6081](https://github.com/mruby/mruby/pull/6081) Add "x" mode option for IO.open
- [#6086](https://github.com/mruby/mruby/pull/6086) Add build config for Nintendo Wii
- [#6097](https://github.com/mruby/mruby/pull/6097) Add a new mrb_fiber_new() with MRB_API
- [#6106](https://github.com/mruby/mruby/pull/6106) Ease fiber limitations
- [#6118](https://github.com/mruby/mruby/pull/6118) Fixed IO#read with buf
- [#6120](https://github.com/mruby/mruby/pull/6120) Set EBADF if check_file_descriptor() fails
+40 -28
View File
@@ -1,40 +1,53 @@
# mruby
[![GitHub Super-Linter](https://github.com/mruby/mruby/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter)
<div align="center">
<p>
<a href="https://mruby.org/">
<img src="https://avatars.githubusercontent.com/u/1796512?s=200&v=4"
alt="The mruby programming language" title="mruby">
</a>
</p>
<h1>mruby</h1>
<a href="https://github.com/marketplace/actions/super-linter">
<img src="https://github.com/mruby/mruby/actions/workflows/super-linter.yml/badge.svg"
alt="GitHub Super-Linter">
</a>
</div>
## What is mruby
mruby is the lightweight implementation of the Ruby language complying to (part
of) the [ISO standard][ISO-standard]. Its syntax is Ruby 2.x compatible.
of) the [ISO standard][ISO-standard] with more recent features provided by Ruby 3.x.
Also, its syntax is Ruby 3.x compatible except for pattern matching.
mruby can be linked and embedded within your application. We provide the
interpreter program "mruby", and the interactive mruby shell "mirb" as examples.
You can also compile Ruby programs into compiled byte code using the mruby
compiler "mrbc". All those tools reside in the "bin" directory. "mrbc" is
also able to generate compiled byte code in a C source file, see the "mrbtest"
program under the "test" directory for an example.
You can link and embed mruby within your application. The "mruby" interpreter
program and the interactive "mirb" shell are provided as examples. You can also
compile Ruby programs into compiled byte code using the "mrbc" compiler. All
these tools are located in the "bin" directory. "mrbc" can also generate
compiled byte code in a C source file. See the "mrbtest" program under the
"test" directory for an example.
This achievement was sponsored by the Regional Innovation Creation R&D Programs
of the Ministry of Economy, Trade and Industry of Japan.
## How to get mruby
The release candidate version 3.2.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/3.2.0-rc.zip](https://github.com/mruby/mruby/archive/3.2.0-rc.zip)
To get mruby, you can download the stable version 3.2.0 from the official mruby
GitHub repository or clone the trunk of the mruby source tree with the "git
clone" command. You can also install and compile mruby using [ruby-install](https://github.com/postmodern/ruby-install), [ruby-build](https://github.com/rbenv/ruby-build) or [rvm](https://github.com/rvm/rvm).
The release candidate version 3.3.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/3.3.0-rc2.zip](https://github.com/mruby/mruby/archive/3.3.0-rc2.zip)
The latest development version of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/zipball/master](https://github.com/mruby/mruby/zipball/master)
The trunk of the mruby source tree can be checked out with the
following command:
```
```console
$ git clone https://github.com/mruby/mruby.git
```
You can also install and compile mruby using [ruby-install](https://github.com/postmodern/ruby-install), [ruby-build](https://github.com/rbenv/ruby-build) or [rvm](https://github.com/rvm/rvm).
## mruby homepage
## mruby home-page
The URL of the mruby home-page is: <https://mruby.org>.
The URL of the mruby homepage is: <https://mruby.org>.
## Mailing list
@@ -44,7 +57,7 @@ We don't have a mailing list, but you can use [GitHub issues](https://github.com
For the simplest case, type
```
```console
rake all test
```
@@ -52,27 +65,27 @@ See the [compile.md](doc/guides/compile.md) file for the detail.
## Building documentation
There are two sets of documentation in mruby: the mruby API (generated by yard) and C API (Doxygen and Graphviz)
There are two sets of documentation in mruby: the mruby API (generated by YARD) and C API (Doxygen and Graphviz)
To build both of them, simply go
```
```console
rake doc
```
You can also view them in your browser
```
```console
rake view_api
rake view_capi
```
## How to customize mruby (mrbgems)
mruby contains a package manager called *mrbgems*. To create extensions
in C and/or Ruby you should create a *GEM*. For a documentation of how to
use mrbgems consult the file [mrbgems.md](doc/guides/mrbgems.md).
For example code of how to use mrbgems look into the folder [examples/mrbgems/](examples/mrbgems).
mruby contains a package manager called "mrbgems" that you can use to create
extensions in C and/or Ruby. For a guide on how to use mrbgems, consult the
[mrbgems.md](doc/guides/mrbgems.md) file, and for example code, refer to the
[examples/mrbgems/](examples/mrbgems) folder.
## License
@@ -97,9 +110,8 @@ Please ask us if you want to distribute your code under another license.
## How to Contribute
See the [contribution guidelines][contribution-guidelines], and then send a pull
request to <https://github.com/mruby/mruby>. We consider you have granted
non-exclusive right to your contributed code under MIT license.
To contribute to mruby, please refer to the [contribution guidelines][contribution-guidelines] and send a pull request to the [mruby GitHub repository](https://github.com/mruby/mruby).
By contributing, you grant non-exclusive rights to your code under the MIT License.
[ISO-standard]: https://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579
[contribution-guidelines]: https://github.com/mruby/mruby/blob/master/CONTRIBUTING.md
[contribution-guidelines]: CONTRIBUTING.md
+20 -30
View File
@@ -31,6 +31,7 @@ load "#{MRUBY_ROOT}/tasks/presym.rake"
load "#{MRUBY_ROOT}/tasks/test.rake"
load "#{MRUBY_ROOT}/tasks/benchmark.rake"
load "#{MRUBY_ROOT}/tasks/doc.rake"
load "#{MRUBY_ROOT}/tasks/install.rake"
##############################
# generic build targets, rules
@@ -56,7 +57,7 @@ task :clean do
rm_rf build.build_dir
rm_f build.products
end
puts "Cleaned up target build folder"
puts "Cleaned up target build directory"
end
desc "clean everything!"
@@ -64,35 +65,9 @@ task :deep_clean => %w[clean doc:clean] do
MRuby.each_target do |build|
rm_rf build.gem_clone_dir
end
puts "Cleaned up mrbgems build folder"
end
PREFIX = ENV['PREFIX'] || ENV['INSTALL_PREFIX'] || '/usr/local'
desc "install compiled products"
task :install => :install_bin do
if host = MRuby.targets['host']
install_D host.libmruby_static, File.join(PREFIX, "lib", File.basename(host.libmruby_static))
# install mruby.h and mrbconf.h
Dir.glob(File.join(MRUBY_ROOT, "include", "*.h")) do |src|
install_D src, File.join(PREFIX, "include", File.basename(src))
end
Dir.glob(File.join(MRUBY_ROOT, "include", "mruby", "*.h")) do |src|
install_D src, File.join(PREFIX, "include", "mruby", File.basename(src))
end
Dir.glob(File.join(File.join(MRUBY_ROOT, "build", "host", "include", "mruby", "presym", "*.h"))) do |src|
install_D src, File.join(PREFIX, "include", "mruby", "presym", File.basename(src))
end
end
end
desc "install compiled executable (on host)"
task :install_bin => :all do
if host = MRuby.targets['host']
Dir.glob(File.join(MRUBY_ROOT, "bin", "*")) do |src|
install_D src, File.join(PREFIX, "bin", File.basename(src))
end
end
rm_rf "#{MRUBY_ROOT}/bin"
rm_rf "#{MRUBY_ROOT}/build"
puts "Cleaned up mrbgems build directory"
end
desc "run all pre-commit hooks against all files"
@@ -100,7 +75,22 @@ task :check do
sh "pre-commit run --all-files"
end
desc "install the pre-commit hooks"
task :checkinstall do
sh "pre-commit install"
end
desc "check the pre-commit hooks for updates"
task :checkupdate do
sh "pre-commit autoupdate"
end
desc "run all pre-commit hooks against all files with docker-compose"
task :composecheck do
sh "docker-compose -p mruby run test pre-commit run --all-files"
end
desc "build and run all mruby tests with docker-compose"
task :composetest do
sh "docker-compose -p mruby run test"
end
+1 -1
View File
@@ -11,7 +11,7 @@ We consider the following issues as vulnerabilities:
- Remote code execution
- Crash caused by a valid Ruby script
We *don't* consider the following issues as vulnerabilities:
We _don't_ consider the following issues as vulnerabilities:
- Runtime C undefined behavior (including integer overflow)
- Crash caused by misused API
+4 -1
View File
@@ -4,6 +4,10 @@ shallow_clone: true
environment:
matrix:
- job_name: Visual Studio 2022 64bit
visualcpp: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat
appveyor_build_worker_image: Visual Studio 2022
- job_name: Visual Studio 2019 64bit
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat
appveyor_build_worker_image: Visual Studio 2019
@@ -38,7 +42,6 @@ init:
- set PATH=C:\Ruby26-x64\bin;%PATH%
- ruby --version
build_script:
- set MRUBY_CONFIG=ci/msvc
- rake -m test:build
+4 -3
View File
@@ -253,6 +253,7 @@ class Scene
def render(w, h, nsubsamples)
nsf = nsubsamples.to_f
nsfs = nsf * nsf
h.times do |y|
w.times do |x|
rad = Vec.new(0.0, 0.0, 0.0)
@@ -288,9 +289,9 @@ class Scene
end
end
r = rad.x / (nsf * nsf)
g = rad.y / (nsf * nsf)
b = rad.z / (nsf * nsf)
r = rad.x / nsfs
g = rad.y / nsfs
b = rad.z / nsfs
printf("%c", clamp(r))
printf("%c", clamp(g))
printf("%c", clamp(b))
+2 -2
View File
@@ -2,8 +2,8 @@
MRuby::CrossBuild.new('android-arm64-v8a') do |conf|
params = {
:arch => 'arm64-v8a',
:sdk_version => 26,
:toolchain => :clang,
:sdk_version => 33,
:toolchain => :clang
}
toolchain :android, params
-11
View File
@@ -1,11 +0,0 @@
# Requires Android NDK r13 or later.
MRuby::CrossBuild.new('android-armeabi') do |conf|
params = {
:arch => 'armeabi',
:sdk_version => 26,
:toolchain => :clang,
}
toolchain :android, params
conf.gembox 'default'
end
@@ -4,8 +4,8 @@ MRuby::CrossBuild.new('android-armeabi-v7a-neon-hard') do |conf|
:arch => 'armeabi-v7a',
:mfpu => 'neon',
:mfloat_abi => 'hard',
:sdk_version => 26,
:toolchain => :clang,
:sdk_version => 33,
:toolchain => :clang
}
toolchain :android, params
+29 -63
View File
@@ -4,31 +4,31 @@
# Requires KallistiOS (KOS)
# http://gamedev.allusion.net/softprj/kos/
#
# Tested on GNU/Linux, macOS and Windows (through MinGW-w64/MSYS2, Cygwin and DreamSDK).
# This configuration has been improved to be used as KallistiOS Port (kos-ports)
# Updated: 2023-12-24
#
# Tested on GNU/Linux, macOS and Windows (MinGW-w64/MSYS2, Cygwin, DreamSDK)
# DreamSDK is based on MinGW/MSYS: https://dreamsdk.org/
#
# Input this command on the directory where mruby is installed:
# make MRUBY_CONFIG=dreamcast_shelf
# Install mruby for Sega Dreamcast using the "mruby" kos-port.
#
MRuby::CrossBuild.new("dreamcast") do |conf|
toolchain :gcc
# Support for DreamSDK (based on MinGW/MSYS)
# To compile mruby with DreamSDK, RubyInstaller for Windows should be installed
DREAMSDK_HOME = ENV["DREAMSDK_HOME"]
MSYS_ROOT = !(DREAMSDK_HOME.nil? || DREAMSDK_HOME.empty?) ? "#{DREAMSDK_HOME}/msys/1.0" : ""
# Getting critical environment variables
KOS_BASE = ENV["KOS_BASE"]
KOS_CC_BASE = ENV["KOS_CC_BASE"]
# Setting paths
DREAMCAST_PATH = "#{MSYS_ROOT}/opt/toolchains/dc"
KOS_PATH = "#{DREAMCAST_PATH}/kos"
BIN_PATH = "#{DREAMCAST_PATH}/sh-elf/bin"
if (KOS_BASE.nil? || KOS_BASE.empty? || KOS_CC_BASE.nil? || KOS_CC_BASE.empty?)
raise "Error: KallistiOS is required; KOS_BASE/KOS_CC_BASE needs to be declared; Stop."
end
# C compiler
# Flags were extracted from KallistiOS environment files
# All flags and settings below were extracted from KallistiOS environment files
conf.cc do |cc|
cc.command = "#{BIN_PATH}/sh-elf-gcc"
cc.include_paths << ["#{KOS_PATH}/include", "#{KOS_PATH}/kernel/arch/dreamcast/include", "#{KOS_PATH}/addons/include", "#{KOS_PATH}/../kos-ports/include"]
cc.flags << ["-O2", "-fomit-frame-pointer", "-ml", "-m4-single-only", "-ffunction-sections", "-fdata-sections", "-Wall", "-g", "-fno-builtin", "-ml", "-m4-single-only", "-Wl,-Ttext=0x8c010000", "-Wl,--gc-sections", "-T#{KOS_PATH}/utils/ldscripts/shlelf.xc", "-nodefaultlibs"]
cc.command = "#{KOS_CC_BASE}/bin/sh-elf-gcc"
cc.include_paths << ["#{KOS_BASE}/include", "#{KOS_BASE}/kernel/arch/dreamcast/include", "#{KOS_BASE}/addons/include", "#{KOS_BASE}/../kos-ports/include"]
cc.flags << ["-O2", "-fomit-frame-pointer", "-fno-builtin", "-ml", "-m4-single-only", "-ffunction-sections", "-fdata-sections", "-matomic-model=soft-imask", "-ftls-model=local-exec", "-Wall", "-g"]
cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"]
cc.defines << %w(_arch_dreamcast)
cc.defines << %w(_arch_sub_pristine)
@@ -39,79 +39,45 @@ MRuby::CrossBuild.new("dreamcast") do |conf|
cxx.command = conf.cc.command.dup
cxx.include_paths = conf.cc.include_paths.dup
cxx.flags = conf.cc.flags.dup
cxx.flags << %w(-fno-rtti -fno-exceptions)
cxx.flags << %w(-fno-operator-names)
cxx.defines = conf.cc.defines.dup
cxx.compile_options = conf.cc.compile_options.dup
end
# Linker
# There is an issue when making the mruby library with KallistiOS:
# 'newlib_kill.o' and 'newlib_getpid.o' aren't found so they are explicitly
# specified here at least for now.
conf.linker do |linker|
linker.command="#{BIN_PATH}/sh-elf-gcc"
linker.flags << ["#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_kill.o", "#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_getpid.o", "-Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group"]
linker.library_paths << ["#{KOS_PATH}/lib/dreamcast", "#{KOS_PATH}/addons/lib/dreamcast", "#{KOS_PATH}/../kos-ports/lib"]
linker.command = "#{KOS_CC_BASE}/bin/sh-elf-gcc"
linker.flags << ["-Wl,-Ttext=0x8c010000", "-Wl,--gc-sections", "-T#{KOS_BASE}/utils/ldscripts/shlelf.xc", "-nodefaultlibs", "-Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group"]
linker.library_paths << ["#{KOS_BASE}/lib/dreamcast", "#{KOS_BASE}/addons/lib/dreamcast", "#{KOS_BASE}/../kos-ports/lib"]
end
# Archiver
conf.archiver do |archiver|
archiver.command = "#{BIN_PATH}/sh-elf-ar"
archiver.command = "#{KOS_CC_BASE}/bin/sh-elf-ar"
archiver.archive_options = 'rcs "%{outfile}" %{objs}'
end
# No executables
# No executables needed for KallistiOS
conf.bins = []
# Do not build executable test
# Do not build test binaries
conf.build_mrbtest_lib_only
# Disable C++ exception
conf.disable_cxx_exception
# Gemboxes
conf.gembox "default-no-stdio"
conf.gembox "stdlib-ext"
conf.gembox "metaprog"
# Gems from core
# Some Gems are incompatible and were disabled.
conf.gem :core => "mruby-array-ext"
# Additional Gems
# Currently unsupported on KallistiOS: "mruby-io", "mruby-dir", "mruby-socket"
conf.gem :core => "mruby-binding"
conf.gem :core => "mruby-catch"
conf.gem :core => "mruby-class-ext"
conf.gem :core => "mruby-cmath"
conf.gem :core => "mruby-compar-ext"
conf.gem :core => "mruby-compiler"
conf.gem :core => "mruby-complex"
conf.gem :core => "mruby-enum-chain"
conf.gem :core => "mruby-enum-ext"
conf.gem :core => "mruby-enum-lazy"
conf.gem :core => "mruby-enumerator"
conf.gem :core => "mruby-errno"
conf.gem :core => "mruby-error"
conf.gem :core => "mruby-eval"
conf.gem :core => "mruby-exit"
conf.gem :core => "mruby-fiber"
conf.gem :core => "mruby-hash-ext"
# conf.gem :core => "mruby-io"
conf.gem :core => "mruby-kernel-ext"
conf.gem :core => "mruby-math"
conf.gem :core => "mruby-metaprog"
conf.gem :core => "mruby-method"
conf.gem :core => "mruby-numeric-ext"
conf.gem :core => "mruby-object-ext"
conf.gem :core => "mruby-objectspace"
conf.gem :core => "mruby-os-memsize"
conf.gem :core => "mruby-pack"
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-proc-binding"
conf.gem :core => "mruby-proc-ext"
conf.gem :core => "mruby-random"
conf.gem :core => "mruby-range-ext"
conf.gem :core => "mruby-rational"
conf.gem :core => "mruby-sleep"
# conf.gem :core => "mruby-socket"
conf.gem :core => "mruby-sprintf"
conf.gem :core => "mruby-string-ext"
conf.gem :core => "mruby-struct"
conf.gem :core => "mruby-symbol-ext"
# conf.gem :core => "mruby-test"
# conf.gem :core => "mruby-time"
conf.gem :core => "mruby-toplevel-ext"
end
+10 -10
View File
@@ -1,23 +1,20 @@
# NOTE: Currently, this configuration file does not support VisualC++!
# Your help is needed!
MRuby::Build.new do |conf|
# load specific toolchain settings
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
conf.toolchain
# include the GEM box
conf.gembox 'default'
# C compiler settings
conf.cc do |cc|
cc.flags = '-fPIC'
conf.compilers.each do |cc|
cc.flags << '-fPIC'
end
conf.archiver do |archiver|
archiver.command = 'gcc'
archiver.command = cc.command
archiver.archive_options = '-shared -o %{outfile} %{objs}'
end
@@ -29,6 +26,9 @@ MRuby::Build.new do |conf|
# file separator
# conf.file_separator = '/'
# enable this if better compatibility with C++ is desired
#conf.enable_cxx_exception
# Turn on `enable_debug` for better debugging
conf.enable_debug
conf.enable_bintest
+77
View File
@@ -0,0 +1,77 @@
# Cross Compiling configuration for MS-DOS
#
# Requires DJGPP cross-compiler, see
# https://github.com/andrewwutw/build-djgpp/releases
MRuby::CrossBuild.new("i586-pc-msdosdjgpp") do |conf|
toolchain :gcc
# If DJGPP is not in the PATH, set this to the bin directory
DJGPP_PATH = nil
GCC = 'i586-pc-msdosdjgpp-gcc'
GXX = 'i586-pc-msdosdjgpp-g++'
AR = 'i586-pc-msdosdjgpp-ar'
conf.cc do |cc|
cc.command = DJGPP_PATH ? File.join(DJGPP_PATH, GCC) : GCC
cc.defines << 'MRB_WITHOUT_IO_PREAD_PWRITE'
cc.defines << 'MRB_UTF8_STRING'
end
conf.cxx do |cxx|
cxx.command = DJGPP_PATH ? File.join(DJGPP_PATH, GXX) : GXX
cxx.defines << 'MRB_WITHOUT_IO_PREAD_PWRITE'
cxx.defines << 'MRB_UTF8_STRING'
end
conf.linker do |linker|
linker.command = DJGPP_PATH ? File.join(DJGPP_PATH, GXX) : GXX
linker.libraries = %w(m)
end
conf.archiver do |archiver|
archiver.command = DJGPP_PATH ? File.join(DJGPP_PATH, AR) : AR
end
# All provided gems that can be reasonably made to compile:
# default.gembox, minus mruby-socket and replacing mruby-cmath with mruby-cmath-alt
conf.gembox "stdlib"
conf.gembox "stdlib-ext"
conf.gem :core => 'mruby-io' # stdlib-io.gembox <- default.gembox
# No socket support in DJGPP
# conf.gem :core => 'mruby-socket' # stdlib-io.gembox <- default.gembox
conf.gem :core => 'mruby-print' # stdlib-io.gembox <- default.gembox
conf.gem :core => 'mruby-errno' # stdlib-io.gembox <- default.gembox
conf.gem :core => 'mruby-dir' # stdlib-io.gembox <- default.gembox
conf.gem :core => 'mruby-bigint' # math.gembox <- default.gembox
conf.gem :core => 'mruby-complex' # math.gembox <- default.gembox
conf.gem :core => 'mruby-math' # math.gembox <- default.gembox
conf.gem :core => 'mruby-rational' # math.gembox <- default.gembox
# Alternative implementation of cmath, not requiring <complex.h>
# conf.gem :github => 'chasonr/mruby-cmath-alt' # math.gembox <- default.gembox
conf.gembox "metaprog"
conf.gem :core => 'mruby-bin-mrbc' # default.gembox
conf.gem :core => 'mruby-bin-debugger' # default.gembox
conf.gem :core => 'mruby-bin-mirb' # default.gembox
conf.gem :core => 'mruby-bin-mruby' # default.gembox
conf.gem :core => 'mruby-bin-strip' # default.gembox
conf.gem :core => 'mruby-bin-config' # default.gembox
# Other compilable gems
conf.gem :core => 'mruby-binding'
conf.gem :core => 'mruby-catch'
conf.gem :core => 'mruby-enum-chain'
conf.gem :core => 'mruby-error'
conf.gem :core => 'mruby-exit'
conf.gem :core => 'mruby-os-memsize'
conf.gem :core => 'mruby-proc-binding'
conf.gem :core => 'mruby-sleep'
# For Onigmo regular expression support
conf.gem :github => 'mattn/mruby-onig-regexp'
end
+96
View File
@@ -0,0 +1,96 @@
# Cross Compiling configuration for the Nintendo Wii
# This configuration requires devkitPPC
# https://devkitpro.org/wiki/Getting_Started
#
#
MRuby::CrossBuild.new("wii") do |conf|
toolchain :gcc
DEVKITPRO_PATH = "/opt/devkitpro"
BIN_PATH = "#{DEVKITPRO_PATH}/devkitPPC/bin"
# C compiler
conf.cc do |cc|
cc.command = "#{BIN_PATH}/powerpc-eabi-gcc"
cc.compile_options = %(%{flags} -o "%{outfile}" -c "%{infile}")
end
# C++ compiler
conf.cxx do |cxx|
cxx.command = "#{BIN_PATH}/powerpc-eabi-g++"
cxx.include_paths = conf.cc.include_paths.dup
cxx.flags = conf.cc.flags.dup
cxx.defines = conf.cc.defines.dup
cxx.compile_options = conf.cc.compile_options.dup
end
# Linker
conf.linker do |linker|
linker.command = "#{BIN_PATH}/powerpc-eabi-gcc"
end
# No executables
conf.bins = []
# Do not build executable test
conf.build_mrbtest_lib_only
# Disable C++ exception
conf.disable_cxx_exception
# All current core gems with ones with build issues commented out
conf.gem 'mrbgems/mruby-array-ext/'
conf.gem 'mrbgems/mruby-bigint/'
conf.gem 'mrbgems/mruby-bin-config/'
conf.gem 'mrbgems/mruby-bin-debugger/'
conf.gem 'mrbgems/mruby-bin-mirb/'
conf.gem 'mrbgems/mruby-bin-mrbc/'
conf.gem 'mrbgems/mruby-bin-mruby/'
conf.gem 'mrbgems/mruby-bin-strip/'
conf.gem 'mrbgems/mruby-binding/'
conf.gem 'mrbgems/mruby-catch/'
conf.gem 'mrbgems/mruby-class-ext/'
conf.gem 'mrbgems/mruby-cmath/'
conf.gem 'mrbgems/mruby-compar-ext/'
conf.gem 'mrbgems/mruby-compiler/'
conf.gem 'mrbgems/mruby-complex/'
conf.gem 'mrbgems/mruby-data/'
#conf.gem 'mrbgems/mruby-dir/'
conf.gem 'mrbgems/mruby-enum-chain/'
conf.gem 'mrbgems/mruby-enum-ext/'
conf.gem 'mrbgems/mruby-enum-lazy/'
conf.gem 'mrbgems/mruby-enumerator/'
conf.gem 'mrbgems/mruby-errno/'
conf.gem 'mrbgems/mruby-error/'
conf.gem 'mrbgems/mruby-eval/'
conf.gem 'mrbgems/mruby-exit/'
conf.gem 'mrbgems/mruby-fiber/'
conf.gem 'mrbgems/mruby-hash-ext/'
#conf.gem 'mrbgems/mruby-io/'
conf.gem 'mrbgems/mruby-kernel-ext/'
conf.gem 'mrbgems/mruby-math/'
conf.gem 'mrbgems/mruby-metaprog/'
conf.gem 'mrbgems/mruby-method/'
conf.gem 'mrbgems/mruby-numeric-ext/'
conf.gem 'mrbgems/mruby-object-ext/'
conf.gem 'mrbgems/mruby-objectspace/'
conf.gem 'mrbgems/mruby-os-memsize/'
conf.gem 'mrbgems/mruby-pack/'
conf.gem 'mrbgems/mruby-print/'
conf.gem 'mrbgems/mruby-proc-binding/'
conf.gem 'mrbgems/mruby-proc-ext/'
conf.gem 'mrbgems/mruby-random/'
conf.gem 'mrbgems/mruby-range-ext/'
conf.gem 'mrbgems/mruby-rational/'
conf.gem 'mrbgems/mruby-set/'
conf.gem 'mrbgems/mruby-sleep/'
#conf.gem 'mrbgems/mruby-socket/'
conf.gem 'mrbgems/mruby-sprintf/'
conf.gem 'mrbgems/mruby-string-ext/'
conf.gem 'mrbgems/mruby-struct/'
conf.gem 'mrbgems/mruby-symbol-ext/'
conf.gem 'mrbgems/mruby-test-inline-struct/'
#conf.gem 'mrbgems/mruby-test/'
conf.gem 'mrbgems/mruby-time/'
conf.gem 'mrbgems/mruby-toplevel-ext/'
end
+3 -7
View File
@@ -1,20 +1,16 @@
ans
ba
celler
clen
creat
delet
disabl
falsy
filetest
fo
hel
hist
ist
methid
nd
quitt
remore
ro
runn
sting
upto
strin
wronly
+57 -7
View File
@@ -80,7 +80,7 @@ conf.toolchain :clang
#### Visual Studio 2010, 2012 and 2013
Toolchain configuration for Visual Studio on Windows. If you use the
[Visual Studio Command Prompt](https://msdn.microsoft.com/en-us/library/ms229859\(v=vs.110\).aspx),
[Visual Studio Command Prompt](<https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx>),
you normally do not have to specify this manually, since it gets automatically detected by our build process.
```ruby
@@ -177,7 +177,7 @@ conf.linker do |linker|
linker.flags_before_libraries = ...
linker.libraries = ...
linker.flags_after_libraries = ...
linker.library_paths = ....
linker.library_paths = ...
linker.option_library = ...
linker.option_library_path = ...
linker.link_options = ...
@@ -265,7 +265,7 @@ There is a `RubyGem` (gem for CRuby) named `mgem` that help you to
manage `mrbgems`. Try `gem install mgem`. `mgem` can show you the list
of registered `mrbgems`.
See doc/mrbgems/README.md for more option about mrbgems.
See [doc/guides/mrbgems.md](mrbgems.md) for more option about mrbgems.
### Mrbtest
@@ -376,7 +376,7 @@ end
## Build process
During the build process the directory `build` will be created in the
During the build process the `build` directory will be created in the
root directory. The structure of this directory will look like this:
```
@@ -460,7 +460,7 @@ compile for `i386` a directory called `i386` is created under the
build directory.
The cross compilation workflow starts in the same way as the normal
compilation by compiling all *native* libraries and binaries, except
compilation by compiling all _native_ libraries and binaries, except
for we don't have `host/mrbc` directory (`host` directory itself works
as placeholder for `mrbc`). Afterwards the cross compilation process
proceeds like this:
@@ -527,7 +527,7 @@ After the build, you will get `libmruby.a`. You can link it to your application.
For compiler options and library path, you can use `mruby-config` command for
convenience. `mruby-config` command prints the configuration used for `libmruby.a`.
```
```console
$ mruby-config --help
Usage: mruby-config [switches]
switches:
@@ -545,7 +545,7 @@ For example, when you have a C source file (`c.c`) and try to
compile and link it with `libmruby.a`, you can run the following command,
```
gcc `mruby-config --cflags` c.c `mruby-config --ldflags` `mruby-config --libs`
`mruby-config --cc --cflags` c.c `mruby-config --ldflags --libs`
```
When you use `make`, add following lines in `Makefile`
@@ -557,6 +557,56 @@ LDFLAGS = `$(MRB_CONFIG) --ldflags`
LIBS = `$(MRB_CONFIG) --libs`
```
## Install
To install the files in the `bin`, `include` and `lib` directories generated by the "host" build target into a system directory, do the following:
```console
$ rake install
```
If there are multiple build targets in the build configuration file, to install the products of all build targets, do the following:
```console
$ rake install:full
```
To install only one of several build targets, e.g., the "its-mine" build target, do the following:
```console
$ rake install:full:its-mine
```
To install only the executable files, do the following:
```console
$ rake install_bin # only "host" build target
$ rake install:bin # all build targets
$ rake install:bin:its-mine # only "its-mine" build target
```
### Installation Directory
The installation directory is `/usr/local` for the "host" build target and `/usr/local/mruby/<build-name>` for the others.
To change them, you can set the environment variable `PREFIX` or use `MRuby::Build#install_prefix = dir` in your build configuration file.
The `PREFIX` environment variable affects all build targets and changes the `/usr/local` part.
The `MRuby::Build#install_prefix` can be set for each individual build target.
In this case, the environment variable `PREFIX` is ignored.
Also, if the environment variable `DESTDIR` is set, it will prepend to the path obtained by `install_prefix` to determine the final write directory.
This is intended for temporary file expansion by the user's package work.
---
To summarize:
- The default value of the environment variable `PREFIX` is `/usr/local`.
- For the "host" build target, the default value of `MRuby::Build#install_prefix` is `<PREFIX>`.
- For a build target other than "host", the default value of `MRuby::Build#install_prefix` is `<PREFIX>/mruby/<build-name>`.
- If the environment variable `DESTDIR` is set, the actual write directory is `<DESTDIR>/<MRuby::Build#install_prefix>`.
## Tips
- If you see compilation troubles, try `rake clean` first.
+16 -16
View File
@@ -38,7 +38,7 @@ To confirm mrdb was installed properly, run mrdb with the `--version` option:
```bash
$ mrdb --version
mruby 3.1.0 (2022-05-12)
mruby 3.2.0 (2023-02-24)
```
## 2.2 Basic Operation
@@ -61,20 +61,20 @@ $ mrdb sample.rb
You can execute the shell commands listed below:
|command|description|
|:-:|:--|
|run|execute programs|
|step|execute stepping|
|continue|execute continuing program|
|break|configure the breaking point|
|delete|deleting the breaking points|
|disable|disabling the breaking points|
|enable|enabling the breaking points|
|info breakpoints|showing list of the breaking points|
|print|evaluating and printing the values of the mruby expressions in the script|
|list|displaying the source cords|
|help|showing help|
|quit|terminating the mruby debugger|
| command | description |
| :--------------: | :------------------------------------------------------------------------ |
| run | execute programs |
| step | execute stepping |
| continue | execute continuing program |
| break | configure the breaking point |
| delete | deleting the breaking points |
| disable | disabling the breaking points |
| enable | enabling the breaking points |
| info breakpoints | showing list of the breaking points |
| print | evaluating and printing the values of the mruby expressions in the script |
| list | displaying the source cords |
| help | showing help |
| quit | terminating the mruby debugger |
### 2.2.2 Debugging mruby Binary Files (mrb file) with mrdb
@@ -83,7 +83,7 @@ You can debug the mruby binary files.
#### 2.2.2.1 Debugging the binary files
- notice
To debug mruby binary files, you need to compile mruby files with option `-g`.
To debug mruby binary files, you need to compile mruby files with option `-g`.
```bash
$ mrbc -g sample.rb
+5 -4
View File
@@ -3,7 +3,8 @@
_This is an English translation of [Matz's blog post][matz blog post]
written in Japanese._
_Some parts are updated to reflect recent changes._
[matz blog post]: <https://www.rubyist.net/~matz/20130731.html>
[matz blog post]: https://www.rubyist.net/~matz/20130731.html
When you are extending mruby using C language, you may encounter
mysterious "arena overflow error" or memory leak or very slow
@@ -62,7 +63,7 @@ memory leak.
As of this writing, mruby automatically extend arena to remember
objects (See `MRB_GC_FIXED_ARENA` and `MRB_GC_ARENA_SIZE` in
doc/guides/mrbconf.md).
[doc/guides/mrbconf.md](mrbconf.md)).
If you create many objects in C functions, memory usage will increase, since
GC never kicks in. This memory usage may look like memory leaks, but will also
@@ -106,7 +107,7 @@ inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list)
char tail[] = { ']' };
/* check recursive */
for(i=0; i<RARRAY_LEN(list); i++) {
for (i=0; i<RARRAY_LEN(list); i++) {
if (mrb_obj_equal(mrb, ary, RARRAY_PTR(list)[i])) {
return mrb_str_new(mrb, "[...]", 5);
}
@@ -117,7 +118,7 @@ inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list)
arystr = mrb_str_new_capa(mrb, 64);
mrb_str_cat(mrb, arystr, head, sizeof(head));
for(i=0; i<RARRAY_LEN(ary); i++) {
for (i=0; i<RARRAY_LEN(ary); i++) {
int ai = mrb_gc_arena_save(mrb);
if (i > 0) {
+8 -8
View File
@@ -51,10 +51,10 @@ for example:
To retrieve compiler options used to build `mruby`, you can use `mruby-config`
command with following options:
- `--cc` compiler name
- `--cflags` options passed to compiler
- `--cc` compiler name
- `--cflags` options passed to compiler
```
```console
$ mruby-config --cflags
-std=gnu99 -g -O3 -Wall -DMRB_GC_FIXED_ARENA -I/home/matz/work/mruby/include -I/home/matz/work/mruby/build/host/include
```
@@ -66,12 +66,12 @@ compatible to mruby configuration.
To retrieve linker options, you can use `mruby-config` with following options:
- `--ld` linker name
- `--ldflags` options passed to linker
- `--ldflags-before-libs` options passed to linker before linked libraries
- `--libs` linked libraries
- `--ld` linker name
- `--ldflags` options passed to linker
- `--ldflags-before-libs` options passed to linker before linked libraries
- `--libs` linked libraries
```
```console
$ mruby-config --ldflags
-L/home/matz/work/mruby/build/host/lib
+21
View File
@@ -0,0 +1,21 @@
# Memory Allocation
There are three methods to customize memory allocation in mruby.
1. Provide your own `realloc()`/`free()`
2. Redefine `mrb_default_allocf()`
3. Specify a function with `mrb_open_allocf()`
## Provide your own `realloc()`/`free()`
On some platforms, especially on microcontrollers, the standard library may not provide `malloc()`, `realloc()`, and `free()`. In such cases, it may be necessary to define memory allocation functions for the specific platform. mruby uses `realloc()` and `free()` from the standard C library for memory management. By defining these two functions of your own, you can make mruby work. However, note the following two points:
First, `realloc(NULL, size)` behaves the same as malloc(size). Second, `free(NULL)` exits without doing anything.
## Redefine `mrb_default_allocf()`
The only function in mruby that uses the standard C library's memory allocation functions is `mrb_default_allocf()`, defined in `alloc.c`. By defining this function within your application, you can customize the memory management of your application.
## Specify a function with `mrb_open_allocf()`
If you want to perform different memory management for each `mrb_state` within your application, you can use the `mrb_open_allocf()` function to create the `mrb_state` structure. This allows you to specify a memory allocation function (which is compatible with `mrb_default_allocf`) for each `mrb_state`. Although this scheme is not recommended. It may become obsolete in the future, since I have never seen per mrb_state memory management use-case.
+8 -8
View File
@@ -18,14 +18,14 @@ This is the same for `MRuby::CrossBuild`.
# build_config.rb
MRuby::Build.new do |conf|
.....
...
conf.defines << 'MRB_GC_FIXED_ARENA'
conf.defines << 'MRB_NO_METHOD_CACHE'
.....
...
end
```
***NOTE***
**_NOTE_**
- Use common definitions (`conf.defines`) instead of per-compiler definitions (e.g., `conf.cc.defines`) unless there is a special reason not to.
- It is now deprecated to edit the `include/mruby/mrbconf.h` file or give it directly as a compiler flag, as was the case before.
@@ -123,7 +123,7 @@ end
- Defines value is `1024`.
- Specifies number of `RBasic` per each heap page.
- To calculate the number of bytes per heap page, it is "(size of management data per heap page) + (size per object) * `MRB_HEAP_PAGE_SIZE`".
- To calculate the number of bytes per heap page, it is "(size of management data per heap page) + (size per object) \* `MRB_HEAP_PAGE_SIZE`".
In mruby 3.1.0, the "size of management data per heap page" is 6 words, also "size per object" is 6 words.
For a 32-bit CPU, `(6 * 4) + (6 * 4) * MRB_HEAP_PAGE_SIZE` gives the bytes of size per heap page.
Conversely, for example, to keep the size per heap page to 4 Ki bytes,
@@ -135,7 +135,7 @@ end
- Default value is `4`.
- If you're allocating data types that requires alignment more than default value define the
largest value of required alignment.
largest value of required alignment.
`POOL_PAGE_SIZE`
@@ -149,7 +149,7 @@ largest value of required alignment.
- If defined enables fixed size `mrb_state` atexit stack.
- Raises `RuntimeError` when `mrb_state_atexit` call count to same `mrb_state` exceeds
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`'s value.
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`'s value.
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`
@@ -247,6 +247,6 @@ largest value of required alignment.
- Make it available `Symbol.all_symbols` in `mrbgems/mruby-symbol-ext`
- Increase heap memory usage.
`MRB_NO_DIRECT_THREADING`
`MRB_USE_VM_SWITCH_DISPATCH`
- Turn off direct threading optimization in VM loop
- Turn on switch dispatch in VM loop
+24 -9
View File
@@ -1,6 +1,6 @@
# mrbgems
mrbgems is a library manager to integrate C and Ruby extension in an easy and
mrbgems is a library manager to integrate C and Ruby extensions in an easy and
standardised way into mruby. Conventionally, each mrbgem name is prefixed by
`mruby-`, e.g. `mruby-time` for a gem that provides `Time` class functionality.
@@ -92,6 +92,21 @@ end
However, it should be used with caution, as it may deviate from the intent
of the gem's author.
### Gem Testing
If you enable unit tests in your build with `enable_test`, tests will be
generated for all gems and their dependencies by default. If necessary, it is
possible to suppress tests for a specific gem like so:
```ruby
conf.gem 'mruby-noisygem' do |g|
g.skip_test = true
end
```
However, it is considered best practice to leave all tests enabled whenever
possible. A warning message will be generated for each gem with disabled tests.
## GemBox
There are instances when you wish to add a collection of mrbgems into mruby at
@@ -160,9 +175,9 @@ The maximal GEM structure looks like this:
+- test/ <- Test code (Ruby)
```
The folder `mrblib` contains pure Ruby files to extend mruby. The folder `src`
contains C/C++ files to extend mruby. The folder `include` contains C/C++ header
files. The folder `test` contains C/C++ and pure Ruby files for testing purposes
The `mrblib` directory contains pure Ruby files to extend mruby. The `src` directory
contains C/C++ files to extend mruby. The `include` directory contains C/C++ header
files. The `test` directory contains C/C++ and pure Ruby files for testing purposes
which will be used by `mrbtest`. `mrbgem.rake` contains the specification
to compile C and Ruby files. `README.md` is a short description of your GEM.
@@ -233,7 +248,7 @@ Version requirement supports following operators:
- '<=': is equal or lesser
- '~>': is equal or greater and is lesser than the next major version
- example 1: '~> 2.2.2' means '>= 2.2.2' and '< 2.3.0'
- example 2: '~> 2.2' means '>= 2.2.0' and '< 3.0.0'
- example 2: '~> 2.2' means '>= 2.2.0' and '< 3.0.0'
When more than one version requirements is passed, the dependency must satisfy all of it.
@@ -349,7 +364,7 @@ mrb_c_extension_example_gem_final(mrb_state* mrb) {
mruby can be extended with pure Ruby. It is possible to override existing
classes or add new ones in this way. Put all Ruby files into the `mrblib`
folder.
directory.
### Pre-Conditions
@@ -377,11 +392,11 @@ none
mruby can be extended with C and Ruby at the same time. It is possible to
override existing classes or add new ones in this way. Put all Ruby files
into the `mrblib` folder and all C files into the `src` folder.
into the `mrblib` directory and all C files into the `src` directory.
mruby codes under `mrblib` directory would be executed after gem init C
function is called. Make sure *mruby script* depends on *C code* and
*C code* doesn't depend on *mruby script*.
function is called. Make sure _mruby script_ depends on _C code_ and
_C code_ doesn't depend on _mruby script_.
### Pre-Conditions
+7 -7
View File
@@ -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
+5 -5
View File
@@ -15,7 +15,7 @@ Some values (called immediate values, e.g. integers, booleans, symbols, etc.) ar
The Word boxing packing bit patterns are like following:
| Types | Bit Pattern |
|--------|---------------------------------------|
| ------ | ------------------------------------- |
| object | `xxxxxxxx xxxxxxxx xxxxxxxx xxxxx000` |
| fixnum | `xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxx1` |
| nil | `00000000 00000000 00000000 00000000` |
@@ -24,17 +24,17 @@ The Word boxing packing bit patterns are like following:
| undef | `00000000 00000000 00000000 00010100` |
| symbol | `xxxxxxxx xxxxxxxx xxxxxxxx xxxxxx10` |
On 64 bit platform (unless `MRB_WORDBOX_NO_FLOAT_TRUNCATE`), float values are also packed in the `mrb_value`. In that case, we drop least significant 2 bits from mantissa.
On 64-bit platforms (unless `MRB_WORDBOX_NO_FLOAT_TRUNCATE`), float values are also packed in the `mrb_value`. In that case, we drop least significant 2 bits from mantissa.
If you need full precision for floating-point numbers, define `MRB_WORDBOX_NO_FLOAT_TRUNCATE`.
## NaN Boxing
NaN boxing packs the Ruby data in a floating-point numbers, which represent NaN (Not a Number) values. Under IEEE753 definitions every value that exponent is all set are considered as NaN. That means NaN can represent `2^51` values. NaN boxing is a teaching to pack the values in those NaN representation. In theory, 64 bits pointers are too big to fit in NaN, but practically most OS uses only 48 bits at most for pointers (except for some OS e.g. Solaris).
NaN boxing packs the Ruby data in a floating-point numbers, which represent NaN (Not a Number) values. Under IEEE753 definitions every value that exponent is all set are considered as NaN. That means NaN can represent `2^51` values. NaN boxing is a teaching to pack the values in those NaN representation. In theory, 64 bit pointers are too big to fit in NaN, but practically most OS use only 48 bits at most for pointers (except for some OS e.g. Solaris).
The NaN boxing packing bit patterns are like following:
| Types | Bit Pattern |
|--------|---------------------------------------------------------------------------|
| ------ | ------------------------------------------------------------------------- |
| float | `SEEEEEEE EEEEFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF` |
| +/-inf | `S1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000` |
| nan | `01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000` |
@@ -45,7 +45,7 @@ The NaN boxing packing bit patterns are like following:
| ptr | `01111111 11111100 PPPPPPPP PPPPPPPP PPPPPPPP PPPPPPPP PPPPPPPP PPPPPP01` |
| nil | `00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000` |
The object values appear far more frequently than floating-point numbers, so we offset the value so that object pointers are unchanged. This technique is called "favor pointer"".
The object values appear far more frequently than floating-point numbers, so we offset the value so that object pointers are unchanged. This technique is called "favor pointer".
## No Boxing
+14 -20
View File
@@ -64,7 +64,7 @@ p Liste.new "foobar"
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
` [] `
`[]`
#### mruby [3.1.0 (2022-05-12)]
@@ -114,7 +114,7 @@ The declaration form of following visibility methods are not implemented.
Especially, `module_function` method is not dummy, but no declaration form.
```
```ruby
module TestModule
module_function
def test_func
@@ -170,7 +170,7 @@ alias $a $__a__
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
` nil `
`nil`
#### mruby [3.1.0 (2022-05-12)]
@@ -196,7 +196,7 @@ The re-defined `+` operator does not accept any arguments.
#### mruby [3.1.0 (2022-05-12)]
` 'ab' `
`'ab'`
Behavior of the operator wasn't changed.
## `Kernel#binding` is not supported until [3.0.0 (2021-03-05)]
@@ -205,26 +205,11 @@ Behavior of the operator wasn't changed.
#### Ruby [ruby 2.5.1p57 (2018-03-29 revision 63029)]
```
```shell
$ ruby -e 'puts Proc.new {}.binding'
#<Binding:0x00000e9deabb9950>
```
#### mruby [3.0.0 (2021-03-05)]
```
$ ./bin/mruby -e 'puts Proc.new {}.binding'
trace (most recent call last):
[0] -e:1
-e:1: undefined method 'binding' (NoMethodError)
```
#### mruby [3.1.0 (2022-05-12)]
`binding` has been supported since 3.1.0.
See also [mrbgems/mruby-binding](https://github.com/mruby/mruby/tree/master/mrbgems/mruby-binding) and [mrbgems/mruby-binding-core](https://github.com/mruby/mruby/tree/master/mrbgems/mruby-binding-core).
## `nil?` redefinition in conditional expressions
Redefinition of `nil?` is ignored in conditional expressions.
@@ -259,3 +244,12 @@ f(1,[2,3])
```
CRuby gives `[1,2,3,nil]`. mruby raises `NoMethodError` for `b`.
Keyword argument expansion has similar restrictions. The following example, gives `[1, 1]` for CRuby, mruby raises `NoMethodError` for `b`.
```ruby
def g(a: 1, b: a)
p [a,b]
end
g(a:1)
```
+6 -5
View File
@@ -42,10 +42,10 @@ We have ported some new syntax from CRuby.
## Renamed for consistency
Some configuration macro names are changed for consistency (use `MRB_USE_XXX`
or `MRB_NO_XXX`).
or `MRB_NO_XXX`).
| mruby2 | mruby3 |
|--------------------------------|---------------------------|
| mruby2 | mruby3 |
| ------------------------------ | ------------------------- |
| `MRB_ENABLE_ALL_SYMBOLS` | `MRB_USE_ALL_SYMBOLS` |
| `MRB_ENABLE_CXX_ABI` | `MRB_USE_CXX_ABI` |
| `MRB_ENABLE_CXX_EXCEPTION` | `MRB_USE_CXX_EXCEPTION` |
@@ -149,7 +149,8 @@ No more operand extension
## Changed Instructions
Jump addresses used to be specified by absolute offset from the start of `iseq`. Now they are relative offset from the address of the next instruction.
Jump addresses used to be specified by absolute offset from the start of `iseq`. Now they are relative offset from the
address of the next instruction.
## `Random` now use `xoshiro128++`.
@@ -159,4 +160,4 @@ For better and faster random number generation.
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).
See [Symbols](guides/symbol.md).
+25 -25
View File
@@ -141,8 +141,8 @@ Method calling instructions are unified. Now `OP_SEND` and `OP_SENDB` (method ca
The brief description of the instructions:
|`OP_SEND` | BBB | `R[a] = R[a].call(Syms[b],R[a+1..n],R[a+n+1],R[a+n+2]..nk) c=n|nk<<4` |
|`OP_SENDB` | BBB | `R[a] = R[a].call(Syms[b],R[a+1..n],R[a+n+1..nk],R[a+n+2..nk],&R[a+n+2*nk+2]) c=n|nk<<4` |
|`OP_SEND` | BBB | `R[a] = R[a].call(Syms[b],R[a+1..n],R[a+n+1],R[a+n+2]..nk) c=n|nk<<4` |
|`OP_SENDB` | BBB | `R[a] = R[a].call(Syms[b],R[a+1..n],R[a+n+1..nk],R[a+n+2..nk],&R[a+n+2*nk+2]) c=n|nk<<4` |
Operand C specifies the number of arguments. Lower 4 bits (`n`) represents the number of ordinal arguments, and higher 4 bits (`nk`) represents the number of keyword arguments.
When `n == 15`, the method takes arguments packed in an array. When `nk == 15`, the method takes keyword arguments are packed in a hash.
@@ -225,31 +225,31 @@ For better and faster hash values.
Following CVEs are fixed in this release.
- [CVE-2021-4110](https://nvd.nist.gov/vuln/detail/CVE-2021-4110)
- [CVE-2021-4188](https://nvd.nist.gov/vuln/detail/CVE-2021-4188)
- [CVE-2022-0080](https://nvd.nist.gov/vuln/detail/CVE-2022-0080)
- [CVE-2022-0240](https://nvd.nist.gov/vuln/detail/CVE-2022-0240)
- [CVE-2022-0326](https://nvd.nist.gov/vuln/detail/CVE-2022-0326)
- [CVE-2022-0481](https://nvd.nist.gov/vuln/detail/CVE-2022-0481)
- [CVE-2022-0631](https://nvd.nist.gov/vuln/detail/CVE-2022-0631)
- [CVE-2022-0632](https://nvd.nist.gov/vuln/detail/CVE-2022-0632)
- [CVE-2022-0890](https://nvd.nist.gov/vuln/detail/CVE-2022-0890)
- [CVE-2022-1071](https://nvd.nist.gov/vuln/detail/CVE-2022-1071)
- [CVE-2022-1106](https://nvd.nist.gov/vuln/detail/CVE-2022-1106)
- [CVE-2022-1201](https://nvd.nist.gov/vuln/detail/CVE-2022-1201)
- [CVE-2022-1427](https://nvd.nist.gov/vuln/detail/CVE-2022-1427)
- [CVE-2021-4110](https://www.cve.org/CVERecord?id=CVE-2021-4110)
- [CVE-2021-4188](https://www.cve.org/CVERecord?id=CVE-2021-4188)
- [CVE-2022-0080](https://www.cve.org/CVERecord?id=CVE-2022-0080)
- [CVE-2022-0240](https://www.cve.org/CVERecord?id=CVE-2022-0240)
- [CVE-2022-0326](https://www.cve.org/CVERecord?id=CVE-2022-0326)
- [CVE-2022-0481](https://www.cve.org/CVERecord?id=CVE-2022-0481)
- [CVE-2022-0631](https://www.cve.org/CVERecord?id=CVE-2022-0631)
- [CVE-2022-0632](https://www.cve.org/CVERecord?id=CVE-2022-0632)
- [CVE-2022-0890](https://www.cve.org/CVERecord?id=CVE-2022-0890)
- [CVE-2022-1071](https://www.cve.org/CVERecord?id=CVE-2022-1071)
- [CVE-2022-1106](https://www.cve.org/CVERecord?id=CVE-2022-1106)
- [CVE-2022-1201](https://www.cve.org/CVERecord?id=CVE-2022-1201)
- [CVE-2022-1427](https://www.cve.org/CVERecord?id=CVE-2022-1427)
## Unaffected CVEs
Following CVEs do not cause problems in this release. They are fixed in the later release.
- [CVE-2022-0481](https://nvd.nist.gov/vuln/detail/CVE-2022-0481)
- [CVE-2022-0525](https://nvd.nist.gov/vuln/detail/CVE-2022-0525)
- [CVE-2022-0570](https://nvd.nist.gov/vuln/detail/CVE-2022-0570)
- [CVE-2022-0614](https://nvd.nist.gov/vuln/detail/CVE-2022-0614)
- [CVE-2022-0623](https://nvd.nist.gov/vuln/detail/CVE-2022-0623)
- [CVE-2022-0630](https://nvd.nist.gov/vuln/detail/CVE-2022-0630)
- [CVE-2022-0717](https://nvd.nist.gov/vuln/detail/CVE-2022-0817)
- [CVE-2022-1212](https://nvd.nist.gov/vuln/detail/CVE-2022-1212)
- [CVE-2022-1276](https://nvd.nist.gov/vuln/detail/CVE-2022-1276)
- [CVE-2022-1286](https://nvd.nist.gov/vuln/detail/CVE-2022-1286)
- [CVE-2022-0481](https://www.cve.org/CVERecord?id=CVE-2022-0481)
- [CVE-2022-0525](https://www.cve.org/CVERecord?id=CVE-2022-0525)
- [CVE-2022-0570](https://www.cve.org/CVERecord?id=CVE-2022-0570)
- [CVE-2022-0614](https://www.cve.org/CVERecord?id=CVE-2022-0614)
- [CVE-2022-0623](https://www.cve.org/CVERecord?id=CVE-2022-0623)
- [CVE-2022-0630](https://www.cve.org/CVERecord?id=CVE-2022-0630)
- [CVE-2022-0717](https://www.cve.org/CVERecord?id=CVE-2022-0817)
- [CVE-2022-1212](https://www.cve.org/CVERecord?id=CVE-2022-1212)
- [CVE-2022-1276](https://www.cve.org/CVERecord?id=CVE-2022-1276)
- [CVE-2022-1286](https://www.cve.org/CVERecord?id=CVE-2022-1286)
+40 -22
View File
@@ -32,30 +32,48 @@
## New bundled gems
- mruby-errno from [https://github.com/iij/mruby-errno.git]
- mruby-set from [https://github.com/yui-knk/mruby-set.git]
- mruby-dir from [https://github.com/iij/mruby-dir.git]
- mruby-errno from <https://github.com/iij/mruby-errno.git>
- mruby-set from <https://github.com/yui-knk/mruby-set.git>
- mruby-dir from <https://github.com/iij/mruby-dir.git>
- mruby-data
# Breaking Changes
## `mrb_vm_run()` may detach top-level local variables referenced from blocks
When the `mrb_vm_run()` function (including `mrb_top_run()`) is called,
the previous top-level local variables referenced from blocks is detached under either of the following conditions.
- If the `stack_keep` parameter is given as 0.
- If the number of variables in `irep` to be executed is less than the number of previous top-level local variables.
This change also affects API functions such as `mrb_load_string()` and `mrb_load_file()`.
The conditions under which the previous top-level local variables referenced from blocks is detached in these functions are as follows:
- If the function has no `mrbc_context` pointer parameter, or the `mrbc_context` pointer parameter is set to `NULL`.
- If the number of variables held in the `mrbc_context` pointer is less than the number of previous top-level local variables.
Intentional reliance on previous behavior may cause compatibility problems in your application.
# CVEs
Following CVEs are fixed.
- [CVE-2022-0080](https://nvd.nist.gov/vuln/detail/CVE-2022-0080)
- [CVE-2022-0240](https://nvd.nist.gov/vuln/detail/CVE-2022-0240)
- [CVE-2022-0326](https://nvd.nist.gov/vuln/detail/CVE-2022-0326)
- [CVE-2022-0631](https://nvd.nist.gov/vuln/detail/CVE-2022-0631)
- [CVE-2022-0481](https://nvd.nist.gov/vuln/detail/CVE-2022-0481)
- [CVE-2022-0525](https://nvd.nist.gov/vuln/detail/CVE-2022-0525)
- [CVE-2022-0570](https://nvd.nist.gov/vuln/detail/CVE-2022-0570)
- [CVE-2022-0614](https://nvd.nist.gov/vuln/detail/CVE-2022-0614)
- [CVE-2022-0623](https://nvd.nist.gov/vuln/detail/CVE-2022-0623)
- [CVE-2022-0630](https://nvd.nist.gov/vuln/detail/CVE-2022-0630)
- [CVE-2022-0631](https://nvd.nist.gov/vuln/detail/CVE-2022-0631)
- [CVE-2022-0632](https://nvd.nist.gov/vuln/detail/CVE-2022-0632)
- [CVE-2022-0717](https://nvd.nist.gov/vuln/detail/CVE-2022-0717)
- [CVE-2022-0890](https://nvd.nist.gov/vuln/detail/CVE-2022-0890)
- [CVE-2022-1106](https://nvd.nist.gov/vuln/detail/CVE-2022-1106)
- [CVE-2022-1212](https://nvd.nist.gov/vuln/detail/CVE-2022-1212)
- [CVE-2022-1276](https://nvd.nist.gov/vuln/detail/CVE-2022-1276)
- [CVE-2022-1286](https://nvd.nist.gov/vuln/detail/CVE-2022-1286)
- [CVE-2022-1934](https://nvd.nist.gov/vuln/detail/CVE-2022-1934)
- [CVE-2022-0080](https://www.cve.org/CVERecord?id=CVE-2022-0080)
- [CVE-2022-0240](https://www.cve.org/CVERecord?id=CVE-2022-0240)
- [CVE-2022-0326](https://www.cve.org/CVERecord?id=CVE-2022-0326)
- [CVE-2022-0481](https://www.cve.org/CVERecord?id=CVE-2022-0481)
- [CVE-2022-0525](https://www.cve.org/CVERecord?id=CVE-2022-0525)
- [CVE-2022-0570](https://www.cve.org/CVERecord?id=CVE-2022-0570)
- [CVE-2022-0614](https://www.cve.org/CVERecord?id=CVE-2022-0614)
- [CVE-2022-0623](https://www.cve.org/CVERecord?id=CVE-2022-0623)
- [CVE-2022-0630](https://www.cve.org/CVERecord?id=CVE-2022-0630)
- [CVE-2022-0631](https://www.cve.org/CVERecord?id=CVE-2022-0631)
- [CVE-2022-0632](https://www.cve.org/CVERecord?id=CVE-2022-0632)
- [CVE-2022-0717](https://www.cve.org/CVERecord?id=CVE-2022-0717)
- [CVE-2022-0890](https://www.cve.org/CVERecord?id=CVE-2022-0890)
- [CVE-2022-1106](https://www.cve.org/CVERecord?id=CVE-2022-1106)
- [CVE-2022-1212](https://www.cve.org/CVERecord?id=CVE-2022-1212)
- [CVE-2022-1276](https://www.cve.org/CVERecord?id=CVE-2022-1276)
- [CVE-2022-1286](https://www.cve.org/CVERecord?id=CVE-2022-1286)
- [CVE-2022-1934](https://www.cve.org/CVERecord?id=CVE-2022-1934)
+90
View File
@@ -0,0 +1,90 @@
# User visible changes in `mruby3.3` from `mruby3.2`
# The language
- aliases work properly with `super`
- `callee` method work differently with aliases in mruby
- define `Kernel#respond_to_missing?` method
- `_inspect` method (`inspect` with recursive check) is removed
- `__printstr` method is removed; use `print` instead
# Configuration
- mruby can be built using Docker now. Try `docker-compose build` for example.
- New Platform: Nintendo Wii
- Improved Platforms: Android, Dreamcast
# mruby memory API
- `mrb_default_allocf` can be overridden by the application
- `mrb_open_allocf` will be deprecated
# mruby VM and bytecode
- [#5870](https://github.com/mruby/mruby/issues/5870) Use OP_LOADINEG instead of OP_LOADI
# Changes in mrbgems
- mruby-bin-config: new options --cxx,--cxxflags,--as,--asflags,--objc,--objcflags
- mruby-binding-eval (merged with mruby-eval) #5989
- mruby-binding: renamed from mruby-binding-core
- mruby-enumerator: remove internal attribute methods obj, args, kwd, meth, fib.
- mruby-fiber: Add a new mrb_fiber_new() with MRB_API
- mruby-fiber: Allows calling `Fiber#resume` from C
- mruby-fiber: `Fiber#to_s` format changed
- mruby-io: Add "x" mode option for IO.open
- mruby-method: `Method#to_s` format changed
- mruby-pack: support new directives j,J,b,B
- mruby-range-ext: new method `Range#overlap?`
- mruby-string-ext: Add `String#valid_encoding?` method
# Bugs Fixed
- [#5712](https://github.com/mruby/mruby/issues/5712) No "make install"
- [#5724](https://github.com/mruby/mruby/issues/5724) Rational#\*\* is missing
- [#5725](https://github.com/mruby/mruby/issues/5725) weird const_missing exceptions in mrblib code
- [#5789](https://github.com/mruby/mruby/issues/5789) No memory release of backtrace information due to stack error
- [#5943](https://github.com/mruby/mruby/issues/5943) TCPSocket#write is failed
- [#5944](https://github.com/mruby/mruby/issues/5944) Behavior of calling method with a hash variable
- [#5949](https://github.com/mruby/mruby/issues/5949) Caller appears to report wrong line when block passed and brackets omitted
- [#5974](https://github.com/mruby/mruby/issues/5974) Invalid escape sequences in gem_init.c on windows
- [#5975](https://github.com/mruby/mruby/issues/5975) Equals comparison fails on extreme ends of 64-bit integers
- [#5985](https://github.com/mruby/mruby/issues/5985) Sign extension with OP_LOADI32 in get_int_operand()
- [#5986](https://github.com/mruby/mruby/issues/5986) Fix bugs in String#bytesplice
- [#5987](https://github.com/mruby/mruby/issues/5987) ~(-1 << 64) is incorrect
- [#5991](https://github.com/mruby/mruby/issues/5991) 'gets' method not working in mruby-3.2.0
- [#5995](https://github.com/mruby/mruby/issues/5995) One seemingly unnecessary parameter is passed in the block parameters
- [#6029](https://github.com/mruby/mruby/issues/6029) mruby build fails under mrbgems directory
- [#6041](https://github.com/mruby/mruby/issues/6041) GC Performance may have degraded
- [#6051](https://github.com/mruby/mruby/issues/6051) Null pointer dereference in mrb_addrinfo_unix_path
- [#6052](https://github.com/mruby/mruby/issues/6052) Null pointer dereference while handling the Proc class
- [#6065](https://github.com/mruby/mruby/issues/6065) Null pointer dereference while handling the Proc class
- [#6066](https://github.com/mruby/mruby/issues/6066) Null pointer dereference involving Struct.new()
- [#6067](https://github.com/mruby/mruby/issues/6067) Null pointer dereference in mrb_string_value_cstr
- [#6068](https://github.com/mruby/mruby/issues/6068) Stack overflow in mrb_vm_exec
- [#6087](https://github.com/mruby/mruby/issues/6087) 'Remote branch HEAD not found in upstream origin' error on build
- [#6089](https://github.com/mruby/mruby/issues/6089) binding.eval() handles def expressions differently from CRuby
- [#6098](https://github.com/mruby/mruby/issues/6098) Fails to call superclass of wrapped method
- [#6108](https://github.com/mruby/mruby/issues/6108) VM crashes with break
- [#6134](https://github.com/mruby/mruby/issues/6134) String#unpack1 returns an array instead of a single string
# Pull Requests (User Visible Ones)
- [#5870](https://github.com/mruby/mruby/pull/5870) Use OP_LOADINEG instead of OP_LOADI
- [#5966](https://github.com/mruby/mruby/pull/5966) Update default.gembox add mruby debugger mrdb
- [#5979](https://github.com/mruby/mruby/pull/5979) Allow Class#allocate to be prohibited
- [#5989](https://github.com/mruby/mruby/pull/5989) Integrate mruby-binding-eval into mruby-eval
- [#5961](https://github.com/mruby/mruby/pull/5961) Add Docker to build and run all mruby tests. Run pre-commit and generate YARD docs with Docker
- [#6008](https://github.com/mruby/mruby/pull/6008) Make "bintest" independent of directory
- [#6009](https://github.com/mruby/mruby/pull/6009) Avoid adding <MRUBY_ROOT>/bintest which does not exist
- [#6012](https://github.com/mruby/mruby/pull/6012) Allow tests to be disabled for specific gems; warn about disabled tests
- [#6013](https://github.com/mruby/mruby/pull/6013) Fix Android toolchain
- [#6032](https://github.com/mruby/mruby/pull/6032) Rake: update task clean to remove bin and build folders
- [#6045](https://github.com/mruby/mruby/pull/6045) Fixes escape sequence bug and enhancements in Presym scanning
- [#6076](https://github.com/mruby/mruby/pull/6076) Fixed unwinding block that could point to invalid PC
- [#6081](https://github.com/mruby/mruby/pull/6081) Add "x" mode option for IO.open
- [#6086](https://github.com/mruby/mruby/pull/6086) Add build config for Nintendo Wii
- [#6097](https://github.com/mruby/mruby/pull/6097) Add a new mrb_fiber_new() with MRB_API
- [#6106](https://github.com/mruby/mruby/pull/6106) Ease fiber limitations
- [#6118](https://github.com/mruby/mruby/pull/6118) Fixed IO#read with buf
- [#6120](https://github.com/mruby/mruby/pull/6120) Set EBADF if check_file_descriptor() fails
+13
View File
@@ -0,0 +1,13 @@
version: "3.8"
services:
test:
build:
context: .
command: sh -c 'rake deep_clean && rake -m test:build && rake test:run'
environment:
- MRUBY_CONFIG=ci/gcc-clang
- CC=gcc
- CXX=g++
- LD=gcc
- SKIP=check-executables-have-shebangs
working_dir: /app
@@ -35,7 +35,7 @@ mrb_foo_get_bar(mrb_state *mrb, mrb_value self)
struct Foo *f;
f = (struct Foo*)mrb_data_get_ptr(mrb, self, &mrb_foo_type);
if(f == NULL) {
if (f == NULL) {
mrb_raise(mrb, E_RUNTIME_ERROR, "uninitialized data");
}
@@ -49,7 +49,7 @@ mrb_foo_set_bar(mrb_state *mrb, mrb_value self)
int v;
f = (struct Foo*)mrb_data_get_ptr(mrb, self, &mrb_foo_type);
if(f == NULL) {
if (f == NULL) {
mrb_raise(mrb, E_RUNTIME_ERROR, "uninitialized data");
}
@@ -10,7 +10,7 @@ The file structure in this example is as follows:
+- mruby-YOUR-bigint/ <- Make this directory public if necessary.
| Change the name of copied directory.
|
+- TODO-HINT.md <- This file is currently viewing by you.
+- TODO-HINT.md <- You are currently viewing this file.
| Remove this from copied directory.
|
+- core/
@@ -21,19 +21,19 @@ The file structure in this example is as follows:
May be depended on by other GEMs.
```
Implementors of own bigints should copy below this directory to another directory and do the following:
Implementers of their own bigints should copy below this directory to another directory and do the following:
- Rewrite `spec.author`, `spec.license`, `spec.homepage` and `spec.summary` in `<gem-dir>/mrbgem.rake` file to those of your own implementors.
- Rewrite `spec.author`, `spec.license`, `spec.homepage` and `spec.summary` in `<gem-dir>/mrbgem.rake` file to those of your own implementers.
- Implement the respective functions in `<gem-dir>/core/bigint.c`.
- Define and use an object structure for `MRB_TT_BIGINT` type-tag.
It is recommended to use `mrb_static_assert_object_size()` to ensure that the size of the object structure is within 6 words.
It is recommended to use `mrb_static_assert_object_size()` to ensure that the size of the object structure is within six words.
- Delete this file from the destination of the copy.
If you wish to use it as an alternative to the `mruby-bigint` provided by mruby, please leave the GEM name in `<gem-dir>/mrbgem.rake` as it is.
This is an important factor when it is depended from other GEMs with `spec.add_dependency 'mruby-bigint'`.
The name of the top directory of GEM can be changed arbitrarily.
The name of the git repository can also be changed arbitrarily.
The name of the top directory of the GEM can be changed arbitrarily.
The name of the Git repository can also be changed arbitrarily.
Note that there is no need for an initialization function as there is in normal GEM.
Note that there is no need for an initialization function as there is in a normal GEM.
If you need it, create a file `<gem-dir>/src/bigint.c` for example, and implement the `mrb_mruby_bigint_gem_init()` function.
+2 -2
View File
@@ -176,8 +176,8 @@
#if defined(DISABLE_STDIO) || defined(MRB_DISABLE_STDIO)
# define MRB_NO_STDIO
#endif
#ifdef MRB_DISABLE_DIRECT_THREADING
# define MRB_NO_DIRECT_THREADING
#if defined(MRB_DISABLE_DIRECT_THREADING) || defined(MRB_NO_DIRECT_THREADING)
# define MRB_USE_VM_SWITCH_DISPATCH
#endif
#if defined(ENABLE_DEBUG) || defined(MRB_ENABLE_DEBUG_HOOK)
# define MRB_USE_DEBUG_HOOK
+26 -32
View File
@@ -1,7 +1,7 @@
/*
** mruby - An embeddable Ruby implementation
**
** Copyright (c) mruby developers 2010-2022
** Copyright (c) mruby developers 2010-
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
@@ -139,7 +139,7 @@
#endif
/**
* MRuby C API entry point
* mruby C API entry point
*/
MRB_BEGIN_DECL
@@ -162,11 +162,11 @@ struct mrb_state;
*
* The function pointing it must behave similarly as realloc except:
* - If ptr is NULL it must allocate new space.
* - If s is NULL, ptr must be freed.
* - If size is zero, ptr must be freed.
*
* See @see mrb_default_allocf for the default implementation.
*/
typedef void* (*mrb_allocf) (struct mrb_state *mrb, void*, size_t, void *ud);
typedef void* (*mrb_allocf) (struct mrb_state *mrb, void *ptr, size_t size, void *ud);
#ifndef MRB_FIXED_STATE_ATEXIT_STACK_SIZE
#define MRB_FIXED_STATE_ATEXIT_STACK_SIZE 5
@@ -420,7 +420,7 @@ MRB_API void mrb_prepend_module(mrb_state *mrb, struct RClass *cla, struct RClas
* mrb_define_method(mrb, mrb->kernel_module, "example_method", example_method, MRB_ARGS_NONE());
* }
*
* @param mrb The MRuby state reference.
* @param mrb The mruby state reference.
* @param cla The class pointer where the method will be defined.
* @param name The name of the method being defined.
* @param func The function pointer to the method definition.
@@ -448,7 +448,7 @@ MRB_API void mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid,
* foo = mrb_define_class(mrb, "Foo", mrb->object_class);
* mrb_define_class_method(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
* }
* @param mrb The MRuby state reference.
* @param mrb The mruby state reference.
* @param cla The class where the class method will be defined.
* @param name The name of the class method being defined.
* @param fun The function pointer to the class method definition.
@@ -484,7 +484,7 @@ MRB_API void mrb_define_singleton_method_id(mrb_state *mrb, struct RObject *cla,
* foo = mrb_define_module(mrb, "Foo");
* mrb_define_module_function(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
* }
* @param mrb The MRuby state reference.
* @param mrb The mruby state reference.
* @param cla The module where the module function will be defined.
* @param name The name of the module function being defined.
* @param fun The function pointer to the module function definition.
@@ -514,7 +514,7 @@ MRB_API void mrb_define_module_function_id(mrb_state *mrb, struct RClass *cla, m
* mrb_value
* mrb_example_gem_final(mrb_state* mrb){
* }
* @param mrb The MRuby state reference.
* @param mrb The mruby state reference.
* @param cla A class or module the constant is defined in.
* @param name The name of the constant being defined.
* @param val The value for the constant.
@@ -1017,7 +1017,7 @@ struct mrb_kwargs
/**
* Retrieve arguments from mrb_state.
*
* @param mrb The current MRuby state.
* @param mrb The current mruby state.
* @param format is a list of format specifiers
* @param ... The passing variadic arguments must be a pointer of retrieving type.
* @return the number of arguments retrieved.
@@ -1248,7 +1248,7 @@ MRB_API mrb_state* mrb_open(void);
MRB_API mrb_state* mrb_open_allocf(mrb_allocf f, void *ud);
/**
* Create new mrb_state with just the MRuby core
* Create new mrb_state with just the mruby core
*
* @param f
* Reference to the allocation function.
@@ -1303,26 +1303,17 @@ MRB_API mrb_bool mrb_eql(mrb_state *mrb, mrb_value obj1, mrb_value obj2);
/* mrb_cmp(mrb, obj1, obj2): 1:0:-1; -2 for error */
MRB_API mrb_int mrb_cmp(mrb_state *mrb, mrb_value obj1, mrb_value obj2);
MRB_INLINE int
mrb_gc_arena_save(mrb_state *mrb)
{
return mrb->gc.arena_idx;
}
MRB_INLINE void
mrb_gc_arena_restore(mrb_state *mrb, int idx)
{
mrb->gc.arena_idx = idx;
}
#define mrb_gc_arena_save(mrb) ((mrb)->gc.arena_idx)
#define mrb_gc_arena_restore(mrb, idx) ((mrb)->gc.arena_idx = (idx))
MRB_API void mrb_garbage_collect(mrb_state*);
MRB_API void mrb_full_gc(mrb_state*);
MRB_API void mrb_incremental_gc(mrb_state *);
MRB_API void mrb_incremental_gc(mrb_state*);
MRB_API void mrb_gc_mark(mrb_state*,struct RBasic*);
#define mrb_gc_mark_value(mrb,val) do {\
if (!mrb_immediate_p(val)) mrb_gc_mark((mrb), mrb_basic_ptr(val)); \
} while (0)
MRB_API void mrb_field_write_barrier(mrb_state *, struct RBasic*, struct RBasic*);
MRB_API void mrb_field_write_barrier(mrb_state*, struct RBasic*, struct RBasic*);
#define mrb_field_write_barrier_value(mrb, obj, val) do{\
if (!mrb_immediate_p(val)) mrb_field_write_barrier((mrb), (obj), mrb_basic_ptr(val)); \
} while (0)
@@ -1366,7 +1357,7 @@ MRB_API mrb_noreturn void mrb_name_error(mrb_state *mrb, mrb_sym id, const char
MRB_API mrb_noreturn void mrb_frozen_error(mrb_state *mrb, void *frozen_obj);
MRB_API mrb_noreturn void mrb_argnum_error(mrb_state *mrb, mrb_int argc, int min, int max);
MRB_API void mrb_warn(mrb_state *mrb, const char *fmt, ...);
MRB_API mrb_noreturn void mrb_bug(mrb_state *mrb, const char *fmt, ...);
MRB_API mrb_noreturn void mrb_bug(mrb_state *mrb, const char *mesg);
MRB_API void mrb_print_backtrace(mrb_state *mrb);
MRB_API void mrb_print_error(mrb_state *mrb);
/* function for `raisef` formatting */
@@ -1378,6 +1369,8 @@ MRB_API mrb_value mrb_vformat(mrb_state *mrb, const char *format, va_list ap);
+ exception objects obtained from those macros are local to mrb
*/
#define MRB_ERROR_SYM(sym) mrb_intern_lit(mrb, #sym)
#define E_EXCEPTION mrb->eException_class
#define E_STANDARD_ERROR mrb->eStandardError_class
#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))
@@ -1436,12 +1429,8 @@ MRB_API mrb_value mrb_ensure_int_type(mrb_state *mrb, mrb_value val);
/* string type checking (contrary to the name, it doesn't convert) */
MRB_API void mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t);
MRB_INLINE void mrb_check_frozen(mrb_state *mrb, void *o)
{
if (mrb_frozen_p((struct RBasic*)o)) mrb_frozen_error(mrb, o);
}
MRB_API void mrb_check_frozen(mrb_state *mrb, void *);
MRB_API void mrb_check_frozen_value(mrb_state *mrb, mrb_value v);
MRB_API void mrb_define_alias(mrb_state *mrb, struct RClass *c, const char *a, const char *b);
MRB_API void mrb_define_alias_id(mrb_state *mrb, struct RClass *c, mrb_sym a, mrb_sym b);
MRB_API const char *mrb_class_name(mrb_state *mrb, struct RClass* klass);
@@ -1456,14 +1445,19 @@ MRB_API mrb_bool mrb_func_basic_p(mrb_state *mrb, mrb_value obj, mrb_sym mid, mr
/* obsolete function(s); will be removed */
#define mrb_int(mrb, val) mrb_as_int(mrb, val)
/**
* Create a new Fiber from proc object
*
* Implemented in mruby-fiber
*/
MRB_API mrb_value mrb_fiber_new(mrb_state *mrb, const struct RProc *proc);
/**
* Resume a Fiber
*
* Implemented in mruby-fiber
*
* Switches to the specified fiber and executes. Like the `Fiber#resume` method.
*
* @note It can only be called before entering the mruby VM (e.g. in the `main()` function).
*/
MRB_API mrb_value mrb_fiber_resume(mrb_state *mrb, mrb_value fib, mrb_int argc, const mrb_value *argv);
+17 -10
View File
@@ -26,6 +26,10 @@ struct RClass {
MRB_INLINE struct RClass*
mrb_class(mrb_state *mrb, mrb_value v)
{
if (!mrb_immediate_p(v)) {
return mrb_obj_ptr(v)->c;
}
switch (mrb_type(v)) {
case MRB_TT_FALSE:
if (mrb_fixnum(v))
@@ -43,20 +47,19 @@ mrb_class(mrb_state *mrb, mrb_value v)
#endif
case MRB_TT_CPTR:
return mrb->object_class;
case MRB_TT_ENV:
return NULL;
default:
return mrb_obj_ptr(v)->c;
return NULL;
}
}
/* flags:
20: frozen
19: is_prepended
18: is_origin
17: is_inherited (used by method cache)
16: unused
0-15: instance type
20: frozen
19: is_prepended
18: is_origin
17: is_inherited (used by method cache)
7-16: unused
6: prohibit Class#allocate
0-5: instance type
*/
#define MRB_FL_CLASS_IS_PREPENDED (1 << 19)
#define MRB_FL_CLASS_IS_ORIGIN (1 << 18)
@@ -69,9 +72,13 @@ mrb_class(mrb_state *mrb, mrb_value v)
}\
} while (0)
#define MRB_FL_CLASS_IS_INHERITED (1 << 17)
#define MRB_INSTANCE_TT_MASK (0xFF)
#define MRB_INSTANCE_TT_MASK (0x1F)
#define MRB_SET_INSTANCE_TT(c, tt) ((c)->flags = (((c)->flags & ~MRB_INSTANCE_TT_MASK) | (char)(tt)))
#define MRB_INSTANCE_TT(c) (enum mrb_vtype)((c)->flags & MRB_INSTANCE_TT_MASK)
#define MRB_FL_UNDEF_ALLOCATE (1 << 6)
#define MRB_UNDEF_ALLOCATOR(c) (mrb_assert((c)->tt == MRB_TT_CLASS), (c)->flags |= MRB_FL_UNDEF_ALLOCATE)
#define MRB_UNDEF_ALLOCATOR_P(c) ((c)->flags & MRB_FL_UNDEF_ALLOCATE)
#define MRB_DEFINE_ALLOCATOR(c) ((c)->flags &= ~MRB_FL_UNDEF_ALLOCATE)
MRB_API void mrb_define_method_raw(mrb_state*, struct RClass*, mrb_sym, mrb_method_t);
MRB_API void mrb_alias_method(mrb_state*, struct RClass *c, mrb_sym a, mrb_sym b);
+1 -1
View File
@@ -67,7 +67,7 @@ MRB_BEGIN_DECL
#endif
#define MRB_INLINE static inline
/** Declare a public MRuby API function. */
/** Declare a public mruby API function. */
#ifndef MRB_API
#if defined(MRB_BUILD_AS_DLL)
#if defined(MRB_CORE) || defined(MRB_LIB)
+26 -18
View File
@@ -10,7 +10,7 @@
#include "common.h"
/**
* MRuby Compiler
* mruby Compiler
*/
MRB_BEGIN_DECL
@@ -18,7 +18,7 @@ MRB_BEGIN_DECL
struct mrb_parser_state;
/* load context */
typedef struct mrbc_context {
typedef struct mrb_ccontext {
mrb_sym *syms;
int slen;
char *filename;
@@ -35,13 +35,21 @@ typedef struct mrbc_context {
const struct RProc *upper;
size_t parser_nerr;
} mrbc_context;
} mrb_ccontext; /* compiler context */
MRB_API mrbc_context* mrbc_context_new(mrb_state *mrb);
MRB_API void mrbc_context_free(mrb_state *mrb, mrbc_context *cxt);
MRB_API const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s);
MRB_API void mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*partial_hook)(struct mrb_parser_state*), void*data);
MRB_API void mrbc_cleanup_local_variables(mrb_state *mrb, mrbc_context *c);
MRB_API mrb_ccontext* mrb_ccontext_new(mrb_state *mrb);
MRB_API void mrb_ccontext_free(mrb_state *mrb, mrb_ccontext *cxt);
MRB_API const char *mrb_ccontext_filename(mrb_state *mrb, mrb_ccontext *c, const char *s);
MRB_API void mrb_ccontext_partial_hook(mrb_state *mrb, mrb_ccontext *c, int (*partial_hook)(struct mrb_parser_state*), void*data);
MRB_API void mrb_ccontext_cleanup_local_variables(mrb_state *mrb, mrb_ccontext *c);
/* compatibility macros */
#define mrbc_context mrb_ccontext
#define mrbc_context_new mrb_ccontext_new
#define mrbc_context_free mrb_ccontext_free
#define mrbc_filename mrb_ccontext_filename
#define mrbc_partial_hook mrb_ccontext_partial_hook
#define mrbc_cleanup_local_variables mrb_ccontext_cleanup_local_variables
/* AST node structure */
typedef struct mrb_ast_node {
@@ -121,7 +129,7 @@ struct mrb_parser_state {
/* If both f and s are non-null, it will be taken preferentially from s until s < send. */
FILE *f;
#endif
mrbc_context *cxt;
mrb_ccontext *cxt;
mrb_sym filename_sym;
uint16_t lineno;
int column;
@@ -168,19 +176,19 @@ struct mrb_parser_state {
MRB_API struct mrb_parser_state* mrb_parser_new(mrb_state*);
MRB_API void mrb_parser_free(struct mrb_parser_state*);
MRB_API void mrb_parser_parse(struct mrb_parser_state*,mrbc_context*);
MRB_API void mrb_parser_parse(struct mrb_parser_state*,mrb_ccontext*);
MRB_API void mrb_parser_set_filename(struct mrb_parser_state*, char const*);
MRB_API mrb_sym mrb_parser_get_filename(struct mrb_parser_state*, uint16_t idx);
/* utility functions */
#ifndef MRB_NO_STDIO
MRB_API struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrbc_context*);
MRB_API struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrb_ccontext*);
#endif
MRB_API struct mrb_parser_state* mrb_parse_string(mrb_state*,const char*,mrbc_context*);
MRB_API struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,size_t,mrbc_context*);
MRB_API struct mrb_parser_state* mrb_parse_string(mrb_state*,const char*,mrb_ccontext*);
MRB_API struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,size_t,mrb_ccontext*);
MRB_API struct RProc* mrb_generate_code(mrb_state*, struct mrb_parser_state*);
MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c);
MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrb_ccontext *c);
/** program load functions
* Please note! Currently due to interactions with the GC calling these functions will
@@ -193,13 +201,13 @@ MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc
*/
#ifndef MRB_NO_STDIO
MRB_API mrb_value mrb_load_file(mrb_state*,FILE*);
MRB_API mrb_value mrb_load_file_cxt(mrb_state*,FILE*, mrbc_context *cxt);
MRB_API mrb_value mrb_load_detect_file_cxt(mrb_state *mrb, FILE *fp, mrbc_context *c);
MRB_API mrb_value mrb_load_file_cxt(mrb_state*,FILE*, mrb_ccontext *cxt);
MRB_API mrb_value mrb_load_detect_file_cxt(mrb_state *mrb, FILE *fp, mrb_ccontext *c);
#endif
MRB_API mrb_value mrb_load_string(mrb_state *mrb, const char *s);
MRB_API mrb_value mrb_load_nstring(mrb_state *mrb, const char *s, size_t len);
MRB_API mrb_value mrb_load_string_cxt(mrb_state *mrb, const char *s, mrbc_context *cxt);
MRB_API mrb_value mrb_load_nstring_cxt(mrb_state *mrb, const char *s, size_t len, mrbc_context *cxt);
MRB_API mrb_value mrb_load_string_cxt(mrb_state *mrb, const char *s, mrb_ccontext *cxt);
MRB_API mrb_value mrb_load_nstring_cxt(mrb_state *mrb, const char *s, size_t len, mrb_ccontext *cxt);
/** @} */
MRB_END_DECL
+2 -2
View File
@@ -41,12 +41,12 @@ MRB_API struct RData *mrb_data_object_alloc(mrb_state *mrb, struct RClass* klass
#define Data_Make_Struct(mrb,klass,strct,type,sval,data_obj) do { \
(data_obj) = Data_Wrap_Struct(mrb,klass,type,NULL);\
(sval) = (strct *)mrb_malloc(mrb, sizeof(strct)); \
(sval) = (strct*)mrb_malloc(mrb, sizeof(strct)); \
{ static const strct zero = { 0 }; *(sval) = zero; };\
(data_obj)->data = (sval);\
} while (0)
#define RDATA(obj) ((struct RData *)(mrb_ptr(obj)))
#define RDATA(obj) ((struct RData*)(mrb_ptr(obj)))
#define DATA_PTR(d) (RDATA(d)->data)
#define DATA_TYPE(d) (RDATA(d)->type)
MRB_API void mrb_data_check_type(mrb_state *mrb, mrb_value, const mrb_data_type*);
+8 -2
View File
@@ -10,7 +10,7 @@
#include "common.h"
/**
* MRuby Debugging.
* mruby Debugging.
*/
MRB_BEGIN_DECL
@@ -46,7 +46,7 @@ typedef struct mrb_irep_debug_info {
} mrb_irep_debug_info;
/*
* get line from irep's debug info and program counter
* get filename from irep's debug info and program counter
* @return returns NULL if not found
*/
MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep, uint32_t pc);
@@ -57,6 +57,12 @@ MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep,
*/
MRB_API int32_t mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, uint32_t pc);
/*
* get line and filename from irep's debug info and program counter
* @return returns FALSE if not found
*/
MRB_API mrb_bool mrb_debug_get_position(mrb_state *mrb, const mrb_irep *irep, uint32_t pc, int32_t *lp, const char **fp);
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
mrb_state *mrb, mrb_irep_debug_info *info,
+1 -1
View File
@@ -23,7 +23,7 @@ MRB_BEGIN_DECL
#ifndef MRB_NO_STDIO
MRB_API mrb_value mrb_load_irep_file(mrb_state*,FILE*);
MRB_API mrb_value mrb_load_irep_file_cxt(mrb_state*, FILE*, mrbc_context*);
MRB_API mrb_value mrb_load_irep_file_cxt(mrb_state*, FILE*, mrb_ccontext*);
mrb_irep *mrb_read_irep_file(mrb_state*, FILE*);
int mrb_dump_irep_binary(mrb_state*, const mrb_irep*, uint8_t, FILE*);
#endif
+1 -1
View File
@@ -34,7 +34,7 @@ static inline int
check_little_endian(void)
{
unsigned int n = 1;
return (*(unsigned char *)&n == 1);
return (*(unsigned char*)&n == 1);
}
# define littleendian check_little_endian()
#endif
+28 -14
View File
@@ -10,7 +10,7 @@
#include "common.h"
/**
* MRuby error handling.
* mruby error handling.
*/
MRB_BEGIN_DECL
@@ -34,26 +34,33 @@ struct RException {
MRB_API mrb_noreturn void mrb_sys_fail(mrb_state *mrb, const char *mesg);
MRB_API mrb_value mrb_exc_new_str(mrb_state *mrb, struct RClass* c, mrb_value str);
#define mrb_exc_new_lit(mrb, c, lit) mrb_exc_new_str(mrb, c, mrb_str_new_lit(mrb, lit))
MRB_API mrb_value mrb_make_exception(mrb_state *mrb, mrb_int argc, const mrb_value *argv);
MRB_API mrb_noreturn void mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_value args, const char *fmt, ...);
/* declaration for `fail` method */
MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value);
#if defined(MRB_64BIT) || defined(MRB_USE_FLOAT32) || defined(MRB_NAN_BOXING) || defined(MRB_WORD_BOXING)
#undef MRB_USE_RBREAK_VALUE_UNION
#else
#define MRB_USE_RBREAK_VALUE_UNION 1
#endif
/*
* flags:
* 0..7: enum mrb_vtype (only when defined MRB_USE_RBREAK_VALUE_UNION)
* 8..10: RBREAK_TAGs in src/vm.c (otherwise, set to 0)
*/
struct RBreak {
MRB_OBJECT_HEADER;
const struct RProc *proc;
uintptr_t ci_break_index; // The top-level ci index to break. One before the return destination.
#ifndef MRB_USE_RBREAK_VALUE_UNION
mrb_value val;
#else
union mrb_value_union value;
#endif
};
#ifndef MRB_USE_RBREAK_VALUE_UNION
#define mrb_break_value_get(brk) ((brk)->val)
#define mrb_break_value_set(brk, v) ((brk)->val = v)
#else
struct RBreak {
MRB_OBJECT_HEADER;
const struct RProc *proc;
union mrb_value_union value;
};
#define RBREAK_VALUE_TT_MASK ((1 << 8) - 1)
static inline mrb_value
mrb_break_value_get(struct RBreak *brk)
@@ -70,9 +77,16 @@ mrb_break_value_set(struct RBreak *brk, mrb_value val)
brk->flags &= ~RBREAK_VALUE_TT_MASK;
brk->flags |= val.tt;
}
#endif /* MRB_64BIT || MRB_USE_FLOAT32 || MRB_NAN_BOXING || MRB_WORD_BOXING */
#define mrb_break_proc_get(brk) ((brk)->proc)
#define mrb_break_proc_set(brk, p) ((brk)->proc = p)
#endif /* MRB_USE_RBREAK_VALUE_UNION */
/**
* Error check
*
*/
/* clear error status in the mrb_state structure */
MRB_API void mrb_clear_error(mrb_state *mrb);
/* returns TRUE if error in the previous call; internally calls mrb_clear_error() */
MRB_API mrb_bool mrb_check_error(mrb_state *mrb);
/**
* Protect
+20 -31
View File
@@ -41,48 +41,37 @@ typedef enum {
#pragma warning(disable : 4200)
#endif
typedef struct mrb_heap_page {
struct RBasic *freelist;
struct mrb_heap_page *prev;
struct mrb_heap_page *next;
struct mrb_heap_page *free_next;
struct mrb_heap_page *free_prev;
mrb_bool old:1;
/* Flexible array members area a C99 feature, not C++ compatible */
/* void* objects[]; */
} mrb_heap_page;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
typedef struct mrb_gc {
mrb_heap_page *heaps; /* heaps for GC */
mrb_heap_page *sweeps;
mrb_heap_page *free_heaps;
size_t live; /* count of live objects */
struct mrb_heap_page *heaps; /* all heaps pages */
struct mrb_heap_page *free_heaps;/* heaps for allocation */
struct mrb_heap_page *sweeps; /* page where sweep starts */
struct RBasic *gray_list; /* list of gray objects to be traversed incrementally */
struct RBasic *atomic_gray_list; /* list of objects to be traversed atomically */
size_t live; /* count of live objects */
size_t live_after_mark; /* old generation objects */
size_t threshold; /* threshold to start GC */
size_t oldgen_threshold; /* threshold to kick major GC */
mrb_gc_state state; /* current state of gc */
int interval_ratio;
int step_ratio;
int current_white_part :2; /* make white object by white_part */
mrb_bool iterating :1; /* currently iterating over objects */
mrb_bool disabled :1; /* GC disabled */
mrb_bool generational :1; /* generational GC mode */
mrb_bool full :1; /* major GC mode */
mrb_bool out_of_memory :1; /* out-of-memory error occurred */
#ifdef MRB_GC_FIXED_ARENA
struct RBasic *arena[MRB_GC_ARENA_SIZE]; /* GC protection array */
#else
struct RBasic **arena; /* GC protection array */
int arena_capa;
int arena_capa; /* size of protection array */
#endif
int arena_idx;
mrb_gc_state state; /* state of gc */
int current_white_part; /* make white object by white_part */
struct RBasic *gray_list; /* list of gray objects to be traversed incrementally */
struct RBasic *atomic_gray_list; /* list of objects to be traversed atomically */
size_t live_after_mark;
size_t threshold;
int interval_ratio;
int step_ratio;
mrb_bool iterating :1;
mrb_bool disabled :1;
mrb_bool full :1;
mrb_bool generational :1;
mrb_bool out_of_memory :1;
size_t majorgc_old_threshold;
} mrb_gc;
MRB_API mrb_bool mrb_object_dead_p(struct mrb_state *mrb, struct RBasic *object);
+41 -3
View File
@@ -12,6 +12,8 @@ void mrb_ary_decref(mrb_state*, mrb_shared_array*);
mrb_value mrb_ary_subseq(mrb_state *mrb, mrb_value ary, mrb_int beg, mrb_int len);
#endif
mrb_bool mrb_inspect_recursive_p(mrb_state *mrb, mrb_value self);
#ifdef MRUBY_CLASS_H
struct RClass *mrb_vm_define_class(mrb_state*, mrb_value, mrb_value, mrb_sym);
struct RClass *mrb_vm_define_module(mrb_state*, mrb_value, mrb_sym);
@@ -22,11 +24,17 @@ mrb_value mrb_class_find_path(mrb_state*, struct RClass*);
mrb_value mrb_mod_to_s(mrb_state *, mrb_value);
void mrb_method_added(mrb_state *mrb, struct RClass *c, mrb_sym mid);
mrb_noreturn void mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args);
mrb_method_t mrb_vm_find_method(mrb_state *mrb, struct RClass *c, struct RClass **cp, mrb_sym mid);
mrb_value mrb_mod_const_missing(mrb_state *mrb, mrb_value mod);
mrb_value mrb_const_missing(mrb_state *mrb, mrb_value mod, mrb_sym sym);
size_t mrb_class_mt_memsize(mrb_state*, struct RClass*);
#endif
mrb_value mrb_obj_equal_m(mrb_state *mrb, mrb_value);
/* debug */
size_t mrb_packed_int_len(uint32_t num);
size_t mrb_packed_int_encode(uint32_t num, uint8_t *p, uint8_t *pend);
size_t mrb_packed_int_encode(uint32_t num, uint8_t *p);
uint32_t mrb_packed_int_decode(const uint8_t *p, const uint8_t **newpos);
/* dump */
@@ -38,12 +46,20 @@ int mrb_dump_irep_cstruct(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *
#endif
#endif
/* codedump */
void mrb_codedump_all(mrb_state *mrb, struct RProc *proc);
#ifndef MRB_NO_STDIO
void mrb_codedump_all_file(mrb_state *mrb, struct RProc *proc, FILE *out);
#endif
/* error */
mrb_value mrb_exc_inspect(mrb_state *mrb, mrb_value exc);
mrb_value mrb_exc_backtrace(mrb_state *mrb, mrb_value exc);
mrb_value mrb_get_backtrace(mrb_state *mrb);
void mrb_exc_mesg_set(mrb_state *mrb, struct RException *exc, mrb_value mesg);
mrb_value mrb_exc_mesg_get(mrb_state *mrb, struct RException *exc);
mrb_value mrb_f_raise(mrb_state*, mrb_value);
mrb_value mrb_make_exception(mrb_state *mrb, mrb_value exc, mrb_value mesg);
/* gc */
void mrb_gc_mark_mt(mrb_state*, struct RClass*);
@@ -82,6 +98,9 @@ mrb_value mrb_int_sub(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_int_mul(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_noreturn void mrb_int_zerodiv(mrb_state *mrb);
mrb_noreturn void mrb_int_overflow(mrb_state *mrb, const char *reason);
#ifndef MRB_NO_FLOAT
void mrb_check_num_exact(mrb_state *mrb, mrb_float num);
#endif
#ifdef MRB_USE_COMPLEX
mrb_value mrb_complex_new(mrb_state *mrb, mrb_float x, mrb_float y);
@@ -104,6 +123,12 @@ void mrb_rational_copy(mrb_state *mrb, mrb_value x, mrb_value y);
struct RProc *mrb_closure_new(mrb_state*, const mrb_irep*);
void mrb_proc_copy(mrb_state *mrb, struct RProc *a, struct RProc *b);
mrb_int mrb_proc_arity(const struct RProc *p);
struct REnv *mrb_env_new(mrb_state *mrb, struct mrb_context *c, mrb_callinfo *ci, int nstacks, mrb_value *stack, struct RClass *tc);
void mrb_proc_merge_lvar(mrb_state *mrb, mrb_irep *irep, struct REnv *env, int num, const mrb_sym *lv, const mrb_value *stack);
mrb_value mrb_proc_local_variables(mrb_state *mrb, const struct RProc *proc);
const struct RProc *mrb_proc_get_caller(mrb_state *mrb, struct REnv **env);
mrb_value mrb_proc_get_self(mrb_state *mrb, struct RProc *p, struct RClass **target_class_p);
mrb_bool mrb_proc_eql(mrb_state *mrb, mrb_value self, mrb_value other);
#endif
/* range */
@@ -163,21 +188,28 @@ mrb_value mrb_f_send(mrb_state *mrb, mrb_value self);
#ifdef MRB_USE_BIGINT
mrb_value mrb_bint_new_int(mrb_state *mrb, mrb_int x);
#ifdef MRB_INT64
#define mrb_bint_new_int64(mrb,x) mrb_bint_new_int((mrb),(mrb_int)(x))
#else
mrb_value mrb_bint_new_int64(mrb_state *mrb, int64_t x);
#endif
mrb_value mrb_bint_new_uint64(mrb_state *mrb, uint64_t x);
mrb_value mrb_bint_new_str(mrb_state *mrb, const char *x, mrb_int len, mrb_int base);
mrb_value mrb_as_bint(mrb_state *mrb, mrb_value x);
mrb_value mrb_bint_add(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_sub(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_add_d(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_sub_d(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_mul(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_div(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_divmod(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_add_ii(mrb_state *mrb, mrb_int x, mrb_int y);
mrb_value mrb_bint_sub_ii(mrb_state *mrb, mrb_int x, mrb_int y);
mrb_value mrb_bint_mul_ii(mrb_state *mrb, mrb_int x, mrb_int y);
mrb_value mrb_bint_div_ii(mrb_state *mrb, mrb_int x, mrb_int y);
mrb_value mrb_bint_mod(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_rem(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_pow(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_powm(mrb_state *mrb, mrb_value x, mrb_int y, mrb_value z);
mrb_value mrb_bint_powm(mrb_state *mrb, mrb_value x, mrb_value y, mrb_value z);
mrb_value mrb_bint_and(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_or(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_xor(mrb_state *mrb, mrb_value x, mrb_value y);
@@ -190,6 +222,12 @@ mrb_value mrb_bint_new_float(mrb_state *mrb, mrb_float x);
mrb_float mrb_bint_as_float(mrb_state *mrb, mrb_value x);
#endif
mrb_int mrb_bint_as_int(mrb_state *mrb, mrb_value x);
#ifdef MRB_INT64
#define mrb_bint_as_int64(mrb, x) mrb_bint_as_int((mrb), (x))
#else
int64_t mrb_bint_as_int64(mrb_state *mrb, mrb_value x);
#endif
uint64_t mrb_bint_as_uint64(mrb_state *mrb, mrb_value x);
mrb_int mrb_bint_cmp(mrb_state *mrb, mrb_value x, mrb_value y);
void mrb_gc_free_bint(mrb_state *mrb, struct RBasic *x);
void mrb_bint_copy(mrb_state *mrb, mrb_value x, mrb_value y);
+2 -2
View File
@@ -104,13 +104,13 @@ MRB_API mrb_value mrb_load_irep(mrb_state*, const uint8_t*);
MRB_API mrb_value mrb_load_irep_buf(mrb_state*, const void*, size_t);
/* @param [const uint8_t*] irep code, expected as a literal */
MRB_API mrb_value mrb_load_irep_cxt(mrb_state*, const uint8_t*, mrbc_context*);
MRB_API mrb_value mrb_load_irep_cxt(mrb_state*, const uint8_t*, mrb_ccontext*);
/*
* @param [const void*] irep code
* @param [size_t] size of irep buffer.
*/
MRB_API mrb_value mrb_load_irep_buf_cxt(mrb_state*, const void*, size_t, mrbc_context*);
MRB_API mrb_value mrb_load_irep_buf_cxt(mrb_state*, const void*, size_t, mrb_ccontext*);
struct mrb_insn_data {
uint8_t insn;
+4 -4
View File
@@ -102,8 +102,8 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
uint8_t *p = (uint8_t*)mrb_malloc_simple(mrb, sizeof(uint8_t)*sz/4+len*sz); \
if (!p) { return 1; } \
h->size = 0; \
h->keys = (khkey_t *)p; \
h->vals = kh_is_map ? (khval_t *)(p+sizeof(khkey_t)*sz) : NULL; \
h->keys = (khkey_t*)p; \
h->vals = kh_is_map ? (khval_t*)(p+sizeof(khkey_t)*sz) : NULL; \
h->ed_flags = p+len*sz; \
kh_fill_flags(h->ed_flags, 0xaa, sz/4); \
return 0; \
@@ -171,7 +171,7 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
hh.n_buckets = new_n_buckets; \
kh_alloc_##name(mrb, &hh); \
/* relocate */ \
for (i=0 ; i<old_n_buckets ; i++) { \
for (i=0; i<old_n_buckets; i++) { \
if (!__ac_iseither(old_ed_flags, i)) { \
khint_t k = kh_put_##name(mrb, &hh, old_keys[i], NULL); \
if (kh_is_map) kh_value(&hh,k) = old_vals[i]; \
@@ -271,7 +271,7 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
static inline khint_t __ac_X31_hash_string(const char *s)
{
khint_t h = *s;
if (h) for (++s ; *s; ++s) h = (h << 5) - h + *s;
if (h) for (++s; *s; ++s) h = (h << 5) - h + *s;
return h;
}
#define kh_str_hash_func(mrb,key) __ac_X31_hash_string(key)
-4
View File
@@ -19,10 +19,6 @@ enum mrb_insn {
#define OP_L_LAMBDA (OP_L_STRICT|OP_L_CAPTURE)
#define OP_L_BLOCK OP_L_CAPTURE
#define OP_R_NORMAL 0
#define OP_R_BREAK 1
#define OP_R_RETURN 2
#define PEEK_B(pc) (*(pc))
#define PEEK_S(pc) ((pc)[0]<<8|(pc)[1])
#define PEEK_W(pc) ((pc)[0]<<16|(pc)[1]<<8|(pc)[2])
+38
View File
@@ -44,6 +44,7 @@ struct RProc {
union {
const mrb_irep *irep;
mrb_func_t func;
mrb_sym mid;
} body;
const struct RProc *upper;
union {
@@ -86,6 +87,8 @@ struct RProc {
#define MRB_PROC_SCOPE_P(p) (((p)->flags & MRB_PROC_SCOPE) != 0)
#define MRB_PROC_NOARG 4096 /* for MRB_PROC_CFUNC_FL, it would be something like MRB_ARGS_NONE() or MRB_METHOD_NOARG_FL */
#define MRB_PROC_NOARG_P(p) (((p)->flags & MRB_PROC_NOARG) != 0)
#define MRB_PROC_ALIAS 8192
#define MRB_PROC_ALIAS_P(p) (((p)->flags & MRB_PROC_ALIAS) != 0)
#define mrb_proc_ptr(v) ((struct RProc*)(mrb_ptr(v)))
@@ -136,6 +139,41 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
MRB_API mrb_value mrb_load_proc(mrb_state *mrb, const struct RProc *proc);
/**
* It can be used to isolate top-level scopes referenced by blocks generated by
* `mrb_load_string_cxt()` or similar called before entering the mruby VM (e.g. from `main()`).
* In that case, the `ci` parameter should be `mrb->c->cibase`.
*
* #include <mruby.h>
* #include <mruby/compile.h>
* #include <mruby/proc.h>
*
* int
* main(int argc, char **argv)
* {
* mrb_state *mrb;
* mrb_ccontext *cxt;
* mrb_value blk, ret;
*
* mrb = mrb_open();
* cxt = mrb_ccontext_new(mrb);
* blk = mrb_load_string_cxt(mrb, "x, y, z = 1, 2, 3; proc { [x, y, z] }", cxt);
* mrb_vm_ci_env_clear(mrb, mrb->c->cibase);
* mrb_load_string_cxt(mrb, "x, y, z = 4, 5, 6", cxt);
* ret = mrb_funcall(mrb, blk, "call", 0);
* mrb_p(mrb, ret); // => [1, 2, 3]
* // => [4, 5, 6] if `mrb_vm_ci_env_clear()` is commented out
* mrb_ccontext_free(mrb, cxt);
* mrb_close(mrb);
*
* return 0;
* }
*
* The top-level local variable names stored in `mrb_ccontext` are retained.
* Use also `mrb_ccontext_cleanup_local_variables()` at the same time, if necessary.
*/
MRB_API void mrb_vm_ci_env_clear(mrb_state *mrb, mrb_callinfo *ci);
void mrb_vm_ci_proc_set(mrb_callinfo *ci, const struct RProc *p);
struct RClass * mrb_vm_ci_target_class(const mrb_callinfo *ci);
void mrb_vm_ci_target_class_set(mrb_callinfo *ci, struct RClass *tc);
+3 -3
View File
@@ -10,7 +10,7 @@
#include "common.h"
/*
* MRuby Value definition functions and macros.
* mruby Value definition functions and macros.
*/
MRB_BEGIN_DECL
@@ -125,7 +125,7 @@ MRB_API int mrb_msvc_snprintf(char *s, size_t n, const char *format, ...);
# define isinf(n) (!_finite(n) && !_isnan(n))
# define signbit(n) (_copysign(1.0, (n)) < 0.0)
static const unsigned int IEEE754_INFINITY_BITS_SINGLE = 0x7F800000;
# define INFINITY (*(float *)&IEEE754_INFINITY_BITS_SINGLE)
# define INFINITY (*(float*)&IEEE754_INFINITY_BITS_SINGLE)
# define NAN ((float)(INFINITY - INFINITY))
# endif
#endif
@@ -186,7 +186,7 @@ MRB_VTYPE_FOREACH(MRB_VTYPE_TYPEDEF)
/**
* @abstract
* MRuby value boxing.
* mruby value boxing.
*
* Actual implementation depends on configured boxing type.
*
+6 -6
View File
@@ -27,7 +27,7 @@ MRB_BEGIN_DECL
/*
* The version of Ruby used by mruby.
*/
#define MRUBY_RUBY_VERSION "3.2"
#define MRUBY_RUBY_VERSION "3.3"
/*
* Ruby engine.
@@ -42,7 +42,7 @@ MRB_BEGIN_DECL
/*
* Minor release version number.
*/
#define MRUBY_RELEASE_MINOR 2
#define MRUBY_RELEASE_MINOR 3
/*
* Tiny release version number.
@@ -57,7 +57,7 @@ MRB_BEGIN_DECL
/*
* Patch level string. (optional)
*/
#define MRUBY_PATCHLEVEL_STR "RC"
#define MRUBY_PATCHLEVEL_STR "RC2"
#ifndef MRUBY_PATCHLEVEL_STR
# if MRUBY_PATCHLEVEL < 0
@@ -80,7 +80,7 @@ MRB_BEGIN_DECL
/*
* Release year.
*/
#define MRUBY_RELEASE_YEAR 2023
#define MRUBY_RELEASE_YEAR 2024
/*
* Release month.
@@ -90,7 +90,7 @@ MRB_BEGIN_DECL
/*
* Release day.
*/
#define MRUBY_RELEASE_DAY 13
#define MRUBY_RELEASE_DAY 4
/*
* Release date as a string.
@@ -117,7 +117,7 @@ MRB_BEGIN_DECL
#define MRUBY_BIRTH_YEAR 2010
/*
* MRuby's authors.
* mruby's authors.
*/
#define MRUBY_AUTHOR "mruby developers"
+57 -10
View File
@@ -1,12 +1,16 @@
require "mruby/core_ext"
require "mruby/build/load_gems"
require "mruby/build/command"
autoload :Find, "find"
module MRuby
autoload :Gem, "mruby/gem"
autoload :Lockfile, "mruby/lockfile"
autoload :Presym, "mruby/presym"
INSTALL_PREFIX = ENV['PREFIX'] || ENV['INSTALL_PREFIX'] || '/usr/local'
INSTALL_DESTDIR = ENV['DESTDIR'] || ''
class << self
def targets
@targets ||= {}
@@ -97,6 +101,7 @@ module MRuby
@file_separator = '/'
@build_dir = "#{build_dir}/#{@name}"
@gem_clone_dir = "#{build_dir}/repos/#{@name}"
@install_prefix = nil
@defines = []
@cc = Command::Compiler.new(self, %w(.c), label: "CC")
@cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp), label: "CXX")
@@ -162,9 +167,7 @@ module MRuby
def enable_debug
compilers.each do |c|
c.defines += %w(MRB_DEBUG)
if toolchains.any? { |toolchain| toolchain == "gcc" }
c.flags += %w(-g3 -O0)
end
c.setup_debug(self)
end
@mrbc.compile_options += ' -g'
@@ -370,14 +373,35 @@ EOS
end
end
def define_installer(src)
dst = "#{self.class.install_dir}/#{File.basename(src)}"
def define_installer_outline(src, dst)
file dst => src do
install_D src, dst
_pp "GEN", src.relative_path, dst.relative_path
mkdir_p(File.dirname(dst))
yield dst
end
dst
end
if ENV['OS'] == 'Windows_NT'
def define_installer(src)
dst = "#{self.class.install_dir}/#{File.basename(src)}".pathmap("%X.bat")
define_installer_outline(src, dst) do
File.write dst, <<~BATCHFILE
@echo off
call "#{File.expand_path(src)}" %*
BATCHFILE
end
end
else
def define_installer(src)
dst = "#{self.class.install_dir}/#{File.basename(src)}"
define_installer_outline(src, dst) do
File.unlink(dst) rescue nil
File.symlink(src.relative_path_from(self.class.install_dir), dst)
end
end
end
def define_installer_if_needed(bin)
exe = exefile("#{build_dir}/bin/#{bin}")
host? ? define_installer(exe) : exe
@@ -440,10 +464,10 @@ EOS
def run_bintest
puts ">>> Bintest #{name} <<<"
targets = @gems.select { |v| File.directory? "#{v.dir}/bintest" }.map { |v| filename v.dir }
targets << filename(".") if File.directory? "./bintest"
mrbc = @gems["mruby-bin-mrbc"] ? exefile("#{@build_dir}/bin/mrbc") : mrbcfile
env = {"BUILD_DIR" => @build_dir, "MRBCFILE" => mrbc}
sh env, "ruby test/bintest.rb#{verbose_flag} #{targets.join ' '}"
bintest = File.join(MRUBY_ROOT, "test/bintest.rb")
sh env, "ruby #{bintest}#{verbose_flag} #{targets.join ' '}"
end
def print_build_summary
@@ -485,6 +509,29 @@ EOS
@internal
end
def each_header_files(&block)
return to_enum(__method__) unless block
basedir = File.join(MRUBY_ROOT, "include")
Find.find(basedir) do |d|
next unless File.file? d
yield d
end
@gems.each { |g| g.each_header_files(&block) }
self
end
def install_prefix
@install_prefix || (self.name == "host" ? MRuby::INSTALL_PREFIX :
File.join(MRuby::INSTALL_PREFIX, "mruby/#{self.name}"))
end
def install_prefix=(dir)
@install_prefix = dir&.to_s
end
protected
attr_writer :presym
@@ -554,7 +601,6 @@ EOS
def run_bintest
puts ">>> Bintest #{name} <<<"
targets = @gems.select { |v| File.directory? "#{v.dir}/bintest" }.map { |v| filename v.dir }
targets << filename(".") if File.directory? "./bintest"
mrbc = @gems["mruby-bin-mrbc"] ? exefile("#{@build_dir}/bin/mrbc") : mrbcfile
emulator = @test_runner.command
@@ -565,7 +611,8 @@ EOS
"MRBCFILE" => mrbc,
"EMULATOR" => @test_runner.emulator,
}
sh env, "ruby test/bintest.rb#{verbose_flag} #{targets.join ' '}"
bintest = File.join(MRUBY_ROOT, "test/bintest.rb")
sh env, "ruby #{bintest}#{verbose_flag} #{targets.join ' '}"
end
protected
+13 -3
View File
@@ -99,12 +99,16 @@ module MRuby
gemrake = File.join(source_dir, "mrbgem.rake")
rakedep = File.exist?(gemrake) ? [ gemrake ] : []
if build_dir.include? "mrbgems/"
bd = build_dir
if bd.start_with?(MRUBY_ROOT)
bd = bd.sub(MRUBY_ROOT, '')
end
if bd.include? "mrbgems/"
generated_file_matcher = Regexp.new("^#{Regexp.escape build_dir}/(?!mrbc/)(.*)#{Regexp.escape out_ext}$")
else
generated_file_matcher = Regexp.new("^#{Regexp.escape build_dir}/(?!mrbc/|mrbgems/.+/)(.*)#{Regexp.escape out_ext}$")
end
source_exts.each do |ext, compile|
source_exts.each do |ext|
rule generated_file_matcher => [
proc { |file|
file.sub(generated_file_matcher, "#{source_dir}/\\1#{ext}")
@@ -129,6 +133,12 @@ module MRuby
end
end
# This method can be redefined as a singleton method where appropriate.
# Manipulate `flags`, `include_paths` and/or more if necessary.
def setup_debug(conf)
nil
end
private
#
@@ -335,7 +345,7 @@ module MRuby
opt << " -s" if static
cmd = %["#{filename @command}" #{opt} #{filename(infiles).map{|f| %["#{f}"]}.join(' ')}]
puts cmd if Rake.verbose
IO.popen(cmd, 'r+') do |io|
IO.popen(cmd, 'r') do |io|
out.puts io.read
end
# if mrbc execution fail, drop the file
+1 -1
View File
@@ -299,7 +299,7 @@ module MRuby
@build.gem_dir_to_repo_url[repo_dir] = url
@build.locks[url] = {
'url' => url,
'branch' => @build.git.current_branch(repo_dir),
'branch' => branch || @build.git.current_branch(repo_dir),
'commit' => @build.git.commit_hash(repo_dir),
}
end
+21
View File
@@ -22,6 +22,27 @@ class String
def remove_leading_parents
Pathname.new(".#{Pathname.new("/#{self}").cleanpath}").cleanpath.to_s
end
def replace_prefix_by(dirmap)
[self].replace_prefix_by(dirmap)[0]
end
end
class Array
# Replace the prefix of each string that is a file path that contains in its own array.
#
# dirmap is a hash whose elements are `{ "path/to/old-prefix" => "path/to/new-prefix", ... }`.
# If it does not match any element of dirmap, the file path is not replaced.
def replace_prefix_by(dirmap)
dirmap = dirmap.map { |older, newer| [File.join(older, "/"), File.join(newer, "/")] }
dirmap.sort!
dirmap.reverse!
self.flatten.map do |e|
map = dirmap.find { |older, newer| e.start_with?(older) }
e = e.sub(map[0], map[1]) if map
e
end
end
end
def install_D(src, dst)
+21 -10
View File
@@ -36,6 +36,7 @@ module MRuby
attr_accessor :export_include_paths
attr_reader :generate_functions
attr_writer :skip_test
attr_block MRuby::Build::COMMANDS
@@ -62,6 +63,7 @@ module MRuby
@test_preload = nil # 'test/assert.rb'
@test_args = {}
@skip_test = false
@bins = []
@cdump = true
@@ -87,6 +89,10 @@ module MRuby
build.locks[repo_url]['version'] = version if repo_url
end
def skip_test?
@skip_test
end
def setup_compilers
(core? ? [@cc, *(@cxx if build.cxx_exception_enabled?)] : compilers).each do |compiler|
compiler.define_rules build_dir, @dir, @build.exts.presym_preprocessed if build.presym_enabled?
@@ -209,7 +215,6 @@ module MRuby
f.puts %Q[void mrb_#{funcname}_gem_final(mrb_state *mrb);]
f.puts %Q[]
f.puts %Q[void GENERATED_TMP_mrb_#{funcname}_gem_init(mrb_state *mrb) {]
f.puts %Q[ int ai = mrb_gc_arena_save(mrb);]
f.puts %Q[ gem_mrblib_#{funcname}_proc_init_syms(mrb);] if !rbfiles.empty? && cdump?
f.puts %Q[ mrb_#{funcname}_gem_init(mrb);] if objs != [objfile("#{build_dir}/gem_init")]
unless rbfiles.empty?
@@ -218,16 +223,7 @@ module MRuby
else
f.puts %Q[ mrb_load_irep(mrb, gem_mrblib_irep_#{funcname});]
end
f.puts %Q[ if (mrb->exc) {]
f.puts %Q[ mrb_print_error(mrb);]
f.puts %Q[ mrb_close(mrb);]
f.puts %Q[ exit(EXIT_FAILURE);]
f.puts %Q[ }]
f.puts %Q[ struct REnv *e = mrb_vm_ci_env(mrb->c->cibase);]
f.puts %Q[ mrb_vm_ci_env_set(mrb->c->cibase, NULL);]
f.puts %Q[ mrb_env_unshare(mrb, e, FALSE);]
end
f.puts %Q[ mrb_gc_arena_restore(mrb, ai);]
f.puts %Q[}]
f.puts %Q[]
f.puts %Q[void GENERATED_TMP_mrb_#{funcname}_gem_final(mrb_state *mrb) {]
@@ -241,6 +237,8 @@ module MRuby
f.puts %Q[ * This file is loading the irep]
f.puts %Q[ * Ruby GEM code.]
f.puts %Q[ *]
f.puts %Q[ * This file was generated by mruby/#{__FILE__.relative_path_from(MRUBY_ROOT)}.]
f.puts %Q[ *]
f.puts %Q[ * IMPORTANT:]
f.puts %Q[ * This file was generated!]
f.puts %Q[ * All manual changes will get lost.]
@@ -292,6 +290,19 @@ module MRuby
end
end.all?
end
def each_header_files(&block)
return to_enum(__method__) unless block
self.export_include_paths.flatten.uniq.compact.each do |dir|
Find.find(dir) do |d|
next unless File.file? d
yield d
end
end
self
end
end # Specification
class Version
+38 -2
View File
@@ -46,6 +46,18 @@ module MRuby
C_STR_LITERAL_RE = /"(?:[^\\\"]|\\.)*"/
ESCAPE_SEQUENCE_MAP = {
"a" => "\a",
"b" => "\b",
"e" => "\e",
"f" => "\f",
"n" => "\n",
"r" => "\r",
"t" => "\t",
"v" => "\v",
}
ESCAPE_SEQUENCE_MAP.keys.each { |k| ESCAPE_SEQUENCE_MAP[ESCAPE_SEQUENCE_MAP[k]] = k }
def initialize(build)
@build = build
end
@@ -93,7 +105,18 @@ module MRuby
f.puts "};"
f.puts
f.puts "static const char * const presym_name_table[] = {"
presyms.each{|sym| f.puts %| "#{sym}",|}
presyms.each do |sym|
sym = sym.gsub(/([\x01-\x1f\x7f-\xff])|("|\\)/n) {
case
when $1
e = ESCAPE_SEQUENCE_MAP[$1]
e ? "\\#{e}" : '\\x%02x""' % $1.ord
when $2
"\\#$2"
end
}
f.puts %| "#{sym}",|
end
f.puts "};"
end
end
@@ -119,7 +142,20 @@ module MRuby
def read_preprocessed(presym_hash, path)
File.binread(path).scan(/<@! (.*?) !@>/) do |part,|
literals = part.scan(C_STR_LITERAL_RE)
presym_hash[literals.map{|l| l[1..-2]}.join] = true unless literals.empty?
unless literals.empty?
literals = literals.map{|l| l[1..-2]}
literals.each do |e|
e.gsub!(/\\x([0-9A-Fa-f]{1,2})|\\(0[0-7]{,3})|\\([abefnrtv])|\\(.)/) do
case
when $1; $1.hex.chr(Encoding::BINARY)
when $2; $2.oct.chr(Encoding::BINARY)
when $3; ESCAPE_SEQUENCE_MAP[$3]
when $4; $4
end
end
end
presym_hash[literals.join] = true
end
end
end
+3
View File
@@ -8,6 +8,9 @@ MRuby::GemBox.new do |conf|
# Generate mrbc command
conf.gem :core => "mruby-bin-mrbc"
# Generate mrdb command
conf.gem :core => "mruby-bin-debugger"
# Generate mirb command
conf.gem :core => "mruby-bin-mirb"
+1 -1
View File
@@ -1,6 +1,6 @@
MRuby::GemBox.new do |conf|
Dir.glob("#{root}/mrbgems/mruby-*/mrbgem.rake") do |x|
g = File.basename File.dirname x
g = File.basename(File.dirname(x))
conf.gem :core => g unless g =~ /^mruby-(?:bin-debugger|test)$/
end
end
+1 -1
View File
@@ -820,7 +820,7 @@ class Array
return to_enum(:combination, n) unless block
size = self.size
if n == 0
yield []
yield []
elsif n == 1
i = 0
while i<size
+22 -23
View File
@@ -27,7 +27,7 @@
*/
static mrb_value
mrb_ary_assoc(mrb_state *mrb, mrb_value ary)
ary_assoc(mrb_state *mrb, mrb_value ary)
{
mrb_int i;
mrb_value v;
@@ -57,7 +57,7 @@ mrb_ary_assoc(mrb_state *mrb, mrb_value ary)
*/
static mrb_value
mrb_ary_rassoc(mrb_state *mrb, mrb_value ary)
ary_rassoc(mrb_state *mrb, mrb_value ary)
{
mrb_int i;
mrb_value v;
@@ -87,10 +87,9 @@ mrb_ary_rassoc(mrb_state *mrb, mrb_value ary)
*/
static mrb_value
mrb_ary_at(mrb_state *mrb, mrb_value ary)
ary_at(mrb_state *mrb, mrb_value ary)
{
mrb_int pos;
mrb_get_args(mrb, "i", &pos);
mrb_int pos = mrb_as_int(mrb, mrb_get_arg1(mrb));
return mrb_ary_entry(ary, pos);
}
@@ -102,7 +101,7 @@ ary_ref(mrb_state *mrb, mrb_value ary, mrb_int n)
}
static mrb_value
mrb_ary_values_at(mrb_state *mrb, mrb_value self)
ary_values_at(mrb_state *mrb, mrb_value self)
{
mrb_int argc = mrb_get_argc(mrb);
const mrb_value *argv = mrb_get_argv(mrb);
@@ -134,7 +133,7 @@ mrb_value mrb_ary_delete_at(mrb_state *mrb, mrb_value self);
*/
static mrb_value
mrb_ary_slice_bang(mrb_state *mrb, mrb_value self)
ary_slice_bang(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
mrb_int i, j, len, alen;
@@ -187,7 +186,7 @@ mrb_ary_slice_bang(mrb_state *mrb, mrb_value self)
*/
static mrb_value
mrb_ary_compact(mrb_state *mrb, mrb_value self)
ary_compact(mrb_state *mrb, mrb_value self)
{
mrb_value ary = mrb_ary_new(mrb);
mrb_int len = RARRAY_LEN(self);
@@ -213,14 +212,14 @@ mrb_ary_compact(mrb_state *mrb, mrb_value self)
* [ "a", "b", "c" ].compact! #=> nil
*/
static mrb_value
mrb_ary_compact_bang(mrb_state *mrb, mrb_value self)
ary_compact_bang(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
mrb_int i, j = 0;
mrb_int len = ARY_LEN(a);
mrb_value *p = ARY_PTR(a);
mrb_ary_modify(mrb, a);
mrb_value *p = ARY_PTR(a);
for (i = 0; i < len; i++) {
if (!mrb_nil_p(p[i])) {
if (i != j) p[j] = p[i];
@@ -228,7 +227,7 @@ mrb_ary_compact_bang(mrb_state *mrb, mrb_value self)
}
}
if (i == j) return mrb_nil_value();
if (j < len) ARY_SET_LEN(RARRAY(self), j);
ARY_SET_LEN(RARRAY(self), j);
return self;
}
@@ -250,7 +249,7 @@ mrb_ary_compact_bang(mrb_state *mrb, mrb_value self)
* a.rotate(-3) #=> ["b", "c", "d", "a"]
*/
static mrb_value
mrb_ary_rotate(mrb_state *mrb, mrb_value self)
ary_rotate(mrb_state *mrb, mrb_value self)
{
mrb_int count=1;
mrb_get_args(mrb, "|i", &count);
@@ -301,17 +300,17 @@ rev(mrb_value *p, mrb_int beg, mrb_int end)
* a.rotate!(-3) #=> ["a", "b", "c", "d"]
*/
static mrb_value
mrb_ary_rotate_bang(mrb_state *mrb, mrb_value self)
ary_rotate_bang(mrb_state *mrb, mrb_value self)
{
mrb_int count=1;
mrb_get_args(mrb, "|i", &count);
struct RArray *a = mrb_ary_ptr(self);
mrb_int len = ARY_LEN(a);
mrb_value *p = ARY_PTR(a);
mrb_int idx;
mrb_ary_modify(mrb, a);
mrb_value *p = ARY_PTR(a);
if (len == 0 || count == 0) return self;
if (count == 1) {
mrb_value v = p[0];
@@ -347,15 +346,15 @@ mrb_mruby_array_ext_gem_init(mrb_state* mrb)
{
struct RClass * a = mrb->array_class;
mrb_define_method(mrb, a, "assoc", mrb_ary_assoc, MRB_ARGS_REQ(1));
mrb_define_method(mrb, a, "at", mrb_ary_at, MRB_ARGS_REQ(1));
mrb_define_method(mrb, a, "rassoc", mrb_ary_rassoc, MRB_ARGS_REQ(1));
mrb_define_method(mrb, a, "values_at", mrb_ary_values_at, MRB_ARGS_ANY());
mrb_define_method(mrb, a, "slice!", mrb_ary_slice_bang, MRB_ARGS_ARG(1,1));
mrb_define_method(mrb, a, "compact", mrb_ary_compact, MRB_ARGS_NONE());
mrb_define_method(mrb, a, "compact!", mrb_ary_compact_bang, MRB_ARGS_NONE());
mrb_define_method(mrb, a, "rotate", mrb_ary_rotate, MRB_ARGS_OPT(1));
mrb_define_method(mrb, a, "rotate!", mrb_ary_rotate_bang, MRB_ARGS_OPT(1));
mrb_define_method(mrb, a, "assoc", ary_assoc, MRB_ARGS_REQ(1));
mrb_define_method(mrb, a, "at", ary_at, MRB_ARGS_REQ(1));
mrb_define_method(mrb, a, "rassoc", ary_rassoc, MRB_ARGS_REQ(1));
mrb_define_method(mrb, a, "values_at", ary_values_at, MRB_ARGS_ANY());
mrb_define_method(mrb, a, "slice!", ary_slice_bang, MRB_ARGS_ARG(1,1));
mrb_define_method(mrb, a, "compact", ary_compact, MRB_ARGS_NONE());
mrb_define_method(mrb, a, "compact!", ary_compact_bang, MRB_ARGS_NONE());
mrb_define_method(mrb, a, "rotate", ary_rotate, MRB_ARGS_OPT(1));
mrb_define_method(mrb, a, "rotate!", ary_rotate_bang, MRB_ARGS_OPT(1));
}
void
+9 -9
View File
@@ -56,7 +56,7 @@ Thanks also to Erick Gallesio <eg@kaolin.unice.fr> for a fix
to mpz_init_set_str
Define B64 if your "long" type is 64 bits. Otherwise we assume 32
bit longs. (The 64 bit version hasn't been tested enough)
bit longs. (The 64-bit version hasn't been tested enough)
```
Platforms:
@@ -73,18 +73,18 @@ MS-DOS 286 C compiler (see credits above)
1. fgmp is considerably slower than gmp
2. fgmp does not implement the following:
all mpq_*
internal mpn_* functions
mpz_perfect_square_p
mpz_inp_raw, mpz_out_raw
mp_set_memory_functions, mpz_out_str, mpz_inp_str
- all mpq\_\*
- internal mpn\_\* functions
- mpz_perfect_square_p
- mpz_inp_raw, mpz_out_raw
- mp_set_memory_functions, mpz_out_str, mpz_inp_str
3. fgmp implements the following in addition to the routines in GNU gmp.
`int mpz_jacobi(MP_INT *a, MP_INT *b)`
- finds the jacobi symbol (a/b)
`int mpz_jacobi(MP_INT *a, MP_INT *b)`
- finds the jacobi symbol (a/b)
4. mpz_sizeinbase often overestimates the exact value
5. To convert your gmp based program to fgmp (subject to the
above)
above)
- recompile your source. Make sure to include the gmp.h file included
with fgmp rather than that included with gmp. (The point is to recompile
+185 -56
View File
@@ -78,7 +78,7 @@ mpz_set_int(mrb_state *mrb, mpz_t *y, mrb_int v)
y->sn = 1;
u = v;
}
if (v < 0) {
else /* if (v < 0) */ {
y->sn = -1;
if (v == MRB_INT_MIN) u = v;
else u = -v;
@@ -97,6 +97,39 @@ mpz_set_int(mrb_state *mrb, mpz_t *y, mrb_int v)
}
}
static void
mpz_set_uint64(mrb_state *mrb, mpz_t *y, uint64_t u)
{
const size_t len = sizeof(uint64_t) / sizeof(mp_limb);
y->sn = (u != 0);
mpz_realloc(mrb, y, len);
for (size_t i=0; i<len; i++) {
y->p[i++] = (mp_limb)LOW(u);
u >>= DIG_SIZE;
}
}
#ifdef MRB_INT32
static void
mpz_set_int64(mrb_state *mrb, mpz_t *y, int64_t v)
{
uint64_t u;
if (v < 0) {
if (v == INT64_MIN) u = v;
else u = -v;
}
else {
u = v;
}
mpz_set_uint64(mrb, y, u);
if (v < 0) {
y->sn = -1;
}
}
#endif
static void
mpz_init_set_int(mrb_state *mrb, mpz_t *y, mrb_int v)
{
@@ -131,7 +164,7 @@ digits(mpz_t *x)
size_t i;
if (x->sz == 0) return 0;
for (i = x->sz - 1; x->p[i] == 0 ; i--)
for (i = x->sz - 1; x->p[i] == 0; i--)
if (i == 0) break;
return i+1;
}
@@ -362,7 +395,7 @@ lzb(mp_limb x)
int j=0;
for (mp_limb i = ((mp_limb)1 << (DIG_SIZE-1)); i && !(x&i) ; j++,i>>=1)
for (mp_limb i = ((mp_limb)1 << (DIG_SIZE-1)); i && !(x&i); j++,i>>=1)
;
return j;
}
@@ -909,7 +942,41 @@ mpz_pow(mrb_state *mrb, mpz_t *zz, mpz_t *x, mrb_int e)
}
static void
mpz_powm(mrb_state *mrb, mpz_t *zz, mpz_t *x, mrb_int ex, mpz_t *n)
mpz_powm(mrb_state *mrb, mpz_t *zz, mpz_t *x, mpz_t *ex, mpz_t *n)
{
mpz_t t, b;
if (uzero(ex)) {
mpz_set_int(mrb, zz, 1);
return;
}
if (ex->sn < 0) {
return;
}
mpz_init_set_int(mrb, &t, 1);
mpz_init_set(mrb, &b, x);
size_t len = digits(ex);
for (size_t i=0; i<len; i++) {
mp_limb e = ex->p[i];
for (size_t j=0; j<sizeof(mp_limb)*8; j++) {
if ((e & 1) == 1) {
mpz_mul(mrb, &t, &t, &b);
mpz_mod(mrb, &t, &t, n);
}
e >>= 1;
mpz_mul(mrb, &b, &b, &b);
mpz_mod(mrb, &b, &b, n);
}
}
mpz_move(mrb, zz, &t);
mpz_clear(mrb, &b);
}
static void
mpz_powm_i(mrb_state *mrb, mpz_t *zz, mpz_t *x, mrb_int ex, mpz_t *n)
{
mpz_t t, b;
@@ -955,13 +1022,6 @@ bint_new_int(mrb_state *mrb, mrb_int x)
return b;
}
mrb_value
mrb_bint_new(mrb_state *mrb)
{
struct RBigint *b = bint_new(mrb);
return mrb_obj_value(b);
}
mrb_value
mrb_bint_new_int(mrb_state *mrb, mrb_int x)
{
@@ -969,6 +1029,26 @@ mrb_bint_new_int(mrb_state *mrb, mrb_int x)
return mrb_obj_value(b);
}
#ifdef MRB_INT32
mrb_value
mrb_bint_new_int64(mrb_state *mrb, int64_t x)
{
struct RBigint *b = bint_new(mrb);
mpz_init(mrb, &b->mp);
mpz_set_int64(mrb, &b->mp, x);
return mrb_obj_value(b);
}
#endif
mrb_value
mrb_bint_new_uint64(mrb_state *mrb, uint64_t x)
{
struct RBigint *b = bint_new(mrb);
mpz_init(mrb, &b->mp);
mpz_set_uint64(mrb, &b->mp, x);
return mrb_obj_value(b);
}
mrb_value
mrb_bint_new_str(mrb_state *mrb, const char *x, mrb_int len, mrb_int base)
{
@@ -1086,6 +1166,61 @@ mrb_bint_as_int(mrb_state *mrb, mrb_value x)
return i;
}
#ifdef MRB_INT32
int64_t
mrb_bint_as_int64(mrb_state *mrb, mrb_value x)
{
struct RBigint *b = RBIGINT(x);
mpz_t *m = &b->mp;
uint64_t u = 0;
size_t len = digits(m);
if (len*sizeof(mp_limb) > sizeof(uint64_t)) {
out_of_range:
mrb_raise(mrb, E_RANGE_ERROR, "integer out of range");
}
for (size_t i=len-1; ; i--) {
u <<= DIG_SIZE;
u |= m->p[i];
if (i==0) break;
}
if (u > INT64_MAX) goto out_of_range;
if (m->sn < 0) return -(int64_t)u;
return (int64_t)u;
}
#endif
uint64_t
mrb_bint_as_uint64(mrb_state *mrb, mrb_value x)
{
struct RBigint *b = RBIGINT(x);
mpz_t *m = &b->mp;
uint64_t u = 0;
size_t len = digits(m);
if (m->sn < 0 || len*sizeof(mp_limb) > sizeof(uint64_t)) {
mrb_raise(mrb, E_RANGE_ERROR, "integer out of range");
}
for (size_t i=len-1; ; i--) {
u <<= DIG_SIZE;
u |= m->p[i];
if (i==0) break;
}
return u;
}
/* unnormalize version of mrb_bint_add */
mrb_value
mrb_bint_add_d(mrb_state *mrb, mrb_value x, mrb_value y)
{
y = mrb_as_bint(mrb, y);
struct RBigint *b = RBIGINT(x);
struct RBigint *b2 = RBIGINT(y);
struct RBigint *b3 = bint_new(mrb);
mpz_add(mrb, &b3->mp, &b->mp, &b2->mp);
return mrb_obj_value(b3);
}
mrb_value
mrb_bint_add(mrb_state *mrb, mrb_value x, mrb_value y)
{
@@ -1096,12 +1231,20 @@ mrb_bint_add(mrb_state *mrb, mrb_value x, mrb_value y)
return mrb_float_value(mrb,v1+v2);
}
#endif
x = mrb_bint_add_d(mrb, x, y);
return bint_norm(mrb, RBIGINT(x));
}
/* unnormalize version of mrb_bint_sub */
mrb_value
mrb_bint_sub_d(mrb_state *mrb, mrb_value x, mrb_value y)
{
y = mrb_as_bint(mrb, y);
struct RBigint *b = RBIGINT(x);
struct RBigint *b2 = RBIGINT(y);
struct RBigint *b3 = bint_new(mrb);
mpz_add(mrb, &b3->mp, &b->mp, &b2->mp);
return bint_norm(mrb, b3);
mpz_sub(mrb, &b3->mp, &b->mp, &b2->mp);
return mrb_obj_value(b3);
}
mrb_value
@@ -1114,12 +1257,8 @@ mrb_bint_sub(mrb_state *mrb, mrb_value x, mrb_value y)
return mrb_float_value(mrb,v1-v2);
}
#endif
y = mrb_as_bint(mrb, y);
struct RBigint *b = RBIGINT(x);
struct RBigint *b2 = RBIGINT(y);
struct RBigint *b3 = bint_new(mrb);
mpz_sub(mrb, &b3->mp, &b->mp, &b2->mp);
return bint_norm(mrb, b3);
x = mrb_bint_sub_d(mrb, x, y);
return bint_norm(mrb, RBIGINT(x));
}
mrb_value
@@ -1206,20 +1345,6 @@ mrb_bint_mul_ii(mrb_state *mrb, mrb_int x, mrb_int y)
return bint_norm(mrb, b);
}
mrb_value
mrb_bint_div_ii(mrb_state *mrb, mrb_int x, mrb_int y)
{
struct RBigint *b = bint_new(mrb);
mpz_t z1, z2;
mpz_init_set_int(mrb, &z1, x);
mpz_init_set_int(mrb, &z2, y);
mpz_mdiv(mrb, &b->mp, &z1, &z2);
mpz_clear(mrb, &z1);
mpz_clear(mrb, &z2);
return bint_norm(mrb, b);
}
mrb_value
mrb_bint_mod(mrb_state *mrb, mrb_value x, mrb_value y)
{
@@ -1334,32 +1459,36 @@ mrb_bint_pow(mrb_state *mrb, mrb_value x, mrb_value y)
}
mrb_value
mrb_bint_powm(mrb_state *mrb, mrb_value x, mrb_int exp, mrb_value mod)
mrb_bint_powm(mrb_state *mrb, mrb_value x, mrb_value exp, mrb_value mod)
{
struct RBigint *b = RBIGINT(x);
switch (mrb_type(mod)) {
case MRB_TT_INTEGER:
{
mrb_int m = mrb_integer(mod);
if (m == 0) mrb_int_zerodiv(mrb);
struct RBigint *b2 = bint_new_int(mrb, m);
struct RBigint *b3 = bint_new(mrb);
mpz_powm(mrb, &b3->mp, &b->mp, exp, &b2->mp);
return bint_norm(mrb, b3);
}
case MRB_TT_BIGINT:
{
struct RBigint *b2 = RBIGINT(mod);
struct RBigint *b3 = bint_new(mrb);
if (uzero(&b2->mp)) mrb_int_zerodiv(mrb);
mpz_powm(mrb, &b3->mp, &b->mp, exp, &b2->mp);
return bint_norm(mrb, b3);
}
mrb_raise(mrb, E_TYPE_ERROR, "too big power");
default:
mrb_raisef(mrb, E_TYPE_ERROR, "%v cannot be convert to integer", mod);
struct RBigint *b2, *b3;
if (mrb_bigint_p(mod)) {
b2 = RBIGINT(mod);
if (uzero(&b2->mp)) mrb_int_zerodiv(mrb);
}
return mrb_nil_value();
else {
mrb_int m = mrb_integer(mod);
if (m == 0) mrb_int_zerodiv(mrb);
b2 = bint_new_int(mrb, m);
}
b3 = bint_new(mrb);
if (mrb_bigint_p(exp)) {
struct RBigint *be = RBIGINT(exp);
if (be->mp.sn < 0) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "int.pow(n,m): n must be positive");
}
mpz_powm(mrb, &b3->mp, &b->mp, &be->mp, &b2->mp);
}
else {
mrb_int e = mrb_integer(exp);
if (e < 0) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "int.pow(n,m): n must be positive");
}
mpz_powm_i(mrb, &b3->mp, &b->mp, e, &b2->mp);
}
return bint_norm(mrb, b3);
}
mrb_value
+16 -2
View File
@@ -11,7 +11,16 @@ MRuby::Gem::Specification.new('mruby-bin-config') do |spec|
else
mruby_config_dir = "#{build.build_dir}/bin"
end
mruby_config = name + (ENV['OS'] == 'Windows_NT' ? '.bat' : '')
if ENV['OS'] == 'Windows_NT'
suffix = '.bat'
refvar = '%\\1%'
else
suffix = ''
refvar = '${\\1}'
end
mruby_config = name + suffix
mruby_config_path = "#{mruby_config_dir}/#{mruby_config}"
make_cfg = "#{build.build_dir}/lib/libmruby.flags.mak"
tmplt_path = "#{__dir__}/#{mruby_config}"
@@ -24,11 +33,16 @@ MRuby::Gem::Specification.new('mruby-bin-config') do |spec|
directory mruby_config_dir
file mruby_config_path => [mruby_config_dir, make_cfg, tmplt_path] do |t|
file mruby_config_path => [__FILE__, mruby_config_dir, make_cfg, tmplt_path] do |t|
config = Hash[File.readlines(make_cfg).map!(&:chomp).map! {|l|
l.gsub!(/\$\((\w+)\)/, refvar)
l.gsub('\\"', '"').split(' = ', 2).map! {|s| s.sub(/^(?=.)/, 'echo ')}
}]
tmplt = File.read(tmplt_path)
tmplt.sub!(%r((?<=\A#!/bin/sh\n\n)), <<~SETDIR)
MRUBY_PACKAGE_DIR=$(dirname "$(dirname "$(readlink -f "$0")")")
SETDIR
File.write(t.name, tmplt.gsub(/(#{Regexp.union(*config.keys)})\b/, config))
chmod(0755, t.name)
end
+14 -2
View File
@@ -4,8 +4,14 @@ print_help()
{
echo "Usage: mruby-config [switches]"
echo " switches:"
echo " --cc print compiler name"
echo " --cflags print flags passed to compiler"
echo " --cc print C compiler name"
echo " --cflags print flags passed to C compiler"
echo " --cxx print C++ compiler name"
echo " --cxxflags print flags passed to C++ compiler"
echo " --as print assembler name"
echo " --asflags print flags passed to assembler"
echo " --objc print Objective C compiler name"
echo " --objcflags print flags passed to Objective C compiler"
echo " --ld print linker name"
echo " --ldflags print flags passed to linker"
echo " --ldflags-before-libs print flags passed to linker before linked libraries"
@@ -23,6 +29,12 @@ while [ $# -gt 0 ]; do
case $1 in
--cc) echo MRUBY_CC;;
--cflags) echo MRUBY_CFLAGS;;
--cxx) echo MRUBY_CXX;;
--cxxflags) echo MRUBY_CXXFLAGS;;
--as) echo MRUBY_AS;;
--asflags) echo MRUBY_ASFLAGS;;
--objc) echo MRUBY_OBJC;;
--objcflags) echo MRUBY_OBJCFLAGS;;
--ld) echo MRUBY_LD;;
--ldflags) echo MRUBY_LDFLAGS;;
--ldflags-before-libs) echo MRUBY_LDFLAGS_BEFORE_LIBS;;
+50 -2
View File
@@ -1,10 +1,28 @@
@echo off
call :init "%~dp0."
goto top
:init
rem call init2 for treatments last directory separator
call :init2 "%~dp1."
goto :eof
:init2
set MRUBY_PACKAGE_DIR=%~f1
goto :eof
:top
shift
if "%0" equ "" goto :eof
if "%0" equ "--cc" goto cc
if "%0" equ "--cflags" goto cflags
if "%0" equ "--cxx" goto cxx
if "%0" equ "--cxxflags" goto cxxflags
if "%0" equ "--as" goto as
if "%0" equ "--asflags" goto asflags
if "%0" equ "--objc" goto objc
if "%0" equ "--objcflags" goto objcflags
if "%0" equ "--ld" goto ld
if "%0" equ "--ldflags" goto ldflags
if "%0" equ "--ldflags-before-libs" goto ldflagsbeforelibs
@@ -22,6 +40,30 @@ goto top
echo MRUBY_CFLAGS
goto top
:cxx
echo MRUBY_CXX
goto top
:cxxflags
echo MRUBY_CXXFLAGS
goto top
:as
echo MRUBY_AS
goto top
:asflags
echo MRUBY_ASFLAGS
goto top
:objc
echo MRUBY_OBJC
goto top
:objcflags
echo MRUBY_OBJCFLAGS
goto top
:ld
echo MRUBY_LD
goto top
@@ -45,8 +87,14 @@ goto top
:showhelp
echo Usage: mruby-config [switches]
echo switches:
echo --cc print compiler name
echo --cflags print flags passed to compiler
echo --cc print C compiler name
echo --cflags print flags passed to C compiler
echo --cxx print C++ compiler name
echo --cxxflags print flags passed to C++ compiler
echo --as print assembler name
echo --asflags print flags passed to assembler
echo --objc print Objective C compiler name
echo --objcflags print flags passed to Objective C compiler
echo --ld print linker name
echo --ldflags print flags passed to linker
echo --ldflags-before-libs print flags passed to linker before linked libraries
+1 -1
View File
@@ -2,7 +2,7 @@ MRuby::Gem::Specification.new('mruby-bin-debugger') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'mruby debugger command'
spec.build.defines |= %w(MRB_USE_DEBUG_HOOK)
spec.build.defines << "MRB_USE_DEBUG_HOOK"
spec.add_dependency('mruby-eval', :core => 'mruby-eval')
spec.bins = %w(mrdb)
@@ -68,7 +68,7 @@ get_break_index(mrb_debug_context *dbg, uint32_t bpno)
int32_t index;
char hit = FALSE;
for(i = 0 ; i < dbg->bpnum; i++) {
for (i = 0; i < dbg->bpnum; i++) {
if (dbg->bp[i].bpno == bpno) {
hit = TRUE;
index = i;
@@ -341,7 +341,7 @@ mrb_debug_delete_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
free_breakpoint(mrb, &dbg->bp[index]);
for(i = index ; i < dbg->bpnum; i++) {
for (i = index; i < dbg->bpnum; i++) {
if ((i + 1) == dbg->bpnum) {
dbg->bp[i] = (mrb_debug_breakpoint){0};
}
@@ -364,7 +364,7 @@ mrb_debug_delete_break_all(mrb_state *mrb, mrb_debug_context *dbg)
return MRB_DEBUG_INVALID_ARGUMENT;
}
for(i = 0 ; i < dbg->bpnum ; i++) {
for (i = 0; i < dbg->bpnum; i++) {
free_breakpoint(mrb, &dbg->bp[i]);
}
@@ -401,7 +401,7 @@ mrb_debug_enable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
return MRB_DEBUG_INVALID_ARGUMENT;
}
for(i = 0 ; i < dbg->bpnum; i++) {
for (i = 0; i < dbg->bpnum; i++) {
dbg->bp[i].enable = TRUE;
}
@@ -436,7 +436,7 @@ mrb_debug_disable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
return MRB_DEBUG_INVALID_ARGUMENT;
}
for(i = 0 ; i < dbg->bpnum; i++) {
for (i = 0; i < dbg->bpnum; i++) {
dbg->bp[i].enable = FALSE;
}
@@ -470,7 +470,7 @@ mrb_debug_check_breakpoint_line(mrb_state *mrb, mrb_debug_context *dbg, const ch
}
bp = dbg->bp;
for(i=0; i<dbg->bpnum; i++) {
for (i=0; i<dbg->bpnum; i++) {
switch (bp->type) {
case MRB_DEBUG_BPTYPE_LINE:
if (bp->enable == TRUE) {
@@ -504,7 +504,7 @@ mrb_debug_check_breakpoint_method(mrb_state *mrb, mrb_debug_context *dbg, struct
}
bp = dbg->bp;
for(i=0; i<dbg->bpnum; i++) {
for (i=0; i<dbg->bpnum; i++) {
if (bp->type == MRB_DEBUG_BPTYPE_METHOD) {
if (bp->enable == TRUE) {
bpno = compare_break_method(mrb, bp, class_obj, method_sym, isCfunc);
@@ -9,18 +9,18 @@
#include <mruby.h>
#include "mrdb.h"
int32_t mrb_debug_set_break_line(mrb_state *, mrb_debug_context *, const char *, uint16_t);
int32_t mrb_debug_set_break_method(mrb_state *, mrb_debug_context *, const char *, const char *);
int32_t mrb_debug_get_breaknum(mrb_state *, mrb_debug_context *);
int32_t mrb_debug_get_break_all(mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint bp[]);
int32_t mrb_debug_get_break(mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint *);
int32_t mrb_debug_delete_break(mrb_state *, mrb_debug_context *, uint32_t);
int32_t mrb_debug_delete_break_all(mrb_state *, mrb_debug_context *);
int32_t mrb_debug_enable_break(mrb_state *, mrb_debug_context *, uint32_t);
int32_t mrb_debug_enable_break_all(mrb_state *, mrb_debug_context *);
int32_t mrb_debug_disable_break(mrb_state *, mrb_debug_context *, uint32_t);
int32_t mrb_debug_disable_break_all(mrb_state *, mrb_debug_context *);
int32_t mrb_debug_check_breakpoint_line(mrb_state *, mrb_debug_context *, const char *, uint16_t);
int32_t mrb_debug_check_breakpoint_method(mrb_state *, mrb_debug_context *, struct RClass *, mrb_sym, mrb_bool*);
int32_t mrb_debug_set_break_line(mrb_state*, mrb_debug_context*, const char*, uint16_t);
int32_t mrb_debug_set_break_method(mrb_state*, mrb_debug_context*, const char*, const char*);
int32_t mrb_debug_get_breaknum(mrb_state*, mrb_debug_context*);
int32_t mrb_debug_get_break_all(mrb_state*, mrb_debug_context*, uint32_t, mrb_debug_breakpoint bp[]);
int32_t mrb_debug_get_break(mrb_state*, mrb_debug_context*, uint32_t, mrb_debug_breakpoint*);
int32_t mrb_debug_delete_break(mrb_state*, mrb_debug_context*, uint32_t);
int32_t mrb_debug_delete_break_all(mrb_state*, mrb_debug_context*);
int32_t mrb_debug_enable_break(mrb_state*, mrb_debug_context*, uint32_t);
int32_t mrb_debug_enable_break_all(mrb_state*, mrb_debug_context*);
int32_t mrb_debug_disable_break(mrb_state*, mrb_debug_context*, uint32_t);
int32_t mrb_debug_disable_break_all(mrb_state*, mrb_debug_context*);
int32_t mrb_debug_check_breakpoint_line(mrb_state*, mrb_debug_context*, const char*, uint16_t);
int32_t mrb_debug_check_breakpoint_method(mrb_state*, mrb_debug_context*, struct RClass*, mrb_sym, mrb_bool*);
#endif /* APIBREAK_H_ */
@@ -200,7 +200,7 @@ mrb_debug_get_source(mrb_state *mrb, mrdb_state *mrdb, const char *srcpath, cons
break;
}
mrb_free(mrb, (void *)search_path[1]);
mrb_free(mrb, (void*)search_path[1]);
return path;
}
@@ -8,7 +8,7 @@
#include <mruby.h>
#include "mrdb.h"
int32_t mrb_debug_list(mrb_state *, mrb_debug_context *, char *, uint16_t, uint16_t);
char* mrb_debug_get_source(mrb_state *, mrdb_state *, const char *, const char *);
int32_t mrb_debug_list(mrb_state*, mrb_debug_context*, char*, uint16_t, uint16_t);
char* mrb_debug_get_source(mrb_state*, mrdb_state*, const char*, const char *);
#endif /* APILIST_H_ */
@@ -17,24 +17,24 @@
static void
mrdb_check_syntax(mrb_state *mrb, mrb_debug_context *dbg, const char *expr, size_t len)
{
mrbc_context *c;
mrb_ccontext *c;
c = mrbc_context_new(mrb);
c = mrb_ccontext_new(mrb);
c->no_exec = TRUE;
c->capture_errors = TRUE;
mrbc_filename(mrb, c, (const char*)dbg->prvfile);
mrb_ccontext_filename(mrb, c, (const char*)dbg->prvfile);
c->lineno = dbg->prvline;
/* Load program */
mrb_load_nstring_cxt(mrb, expr, len, c);
mrbc_context_free(mrb, c);
mrb_ccontext_free(mrb, c);
}
mrb_value
mrb_debug_eval(mrb_state *mrb, mrb_debug_context *dbg, const char *expr, size_t len, mrb_bool *exc, int direct_eval)
{
void (*tmp)(struct mrb_state *, const struct mrb_irep *, const mrb_code *, mrb_value *);
void (*tmp)(struct mrb_state*, const struct mrb_irep*, const mrb_code*, mrb_value*);
mrb_value ruby_code;
mrb_value s;
mrb_value v;
@@ -68,11 +68,11 @@ mrb_debug_eval(mrb_state *mrb, mrb_debug_context *dbg, const char *expr, size_t
recv = dbg->regs[0];
v = mrb_funcall_id(mrb, recv, MRB_SYM(instance_eval), 1, ruby_code);
v = mrb_funcall_argv(mrb, recv, MRB_SYM(instance_eval), 1, &ruby_code);
}
if (exc) {
*exc = mrb_obj_is_kind_of(mrb, v, mrb->eException_class);
*exc = mrb_obj_is_kind_of(mrb, v, E_EXCEPTION);
}
s = mrb_inspect(mrb, v);
@@ -42,8 +42,8 @@
#define LINENO_MAX_DIGIT 6
#define BPNO_LETTER_NUM 9
typedef int32_t (*all_command_func)(mrb_state *, mrb_debug_context *);
typedef int32_t (*select_command_func)(mrb_state *, mrb_debug_context *, uint32_t);
typedef int32_t (*all_command_func)(mrb_state*, mrb_debug_context*);
typedef int32_t (*select_command_func)(mrb_state*, mrb_debug_context*, uint32_t);
static void
print_api_common_error(int32_t error)
@@ -61,7 +61,7 @@ print_api_common_error(int32_t error)
#define STRTOUL(ul,s) { \
int i; \
ul = 0; \
for(i=0; ISDIGIT(s[i]); i++) ul = 10*ul + (s[i] -'0'); \
for (i=0; ISDIGIT(s[i]); i++) ul = 10*ul + (s[i] -'0'); \
}
static int32_t
@@ -106,7 +106,7 @@ exe_set_command_select(mrb_state *mrb, mrdb_state *mrdb, select_command_func fun
int32_t bpno = 0;
int32_t i;
for(i=1; i<mrdb->wcnt; i++) {
for (i=1; i<mrdb->wcnt; i++) {
ps = mrdb->words[i];
bpno = parse_breakpoint_no(ps);
if (bpno == 0) {
@@ -199,7 +199,7 @@ info_break_all(mrb_state *mrb, mrdb_state *mrdb)
return;
}
puts(BREAK_INFO_MSG_HEADER);
for(i = 0 ; i < bpnum ; i++) {
for (i = 0; i < bpnum; i++) {
print_breakpoint(&bp_list[i]);
}
@@ -216,7 +216,7 @@ info_break_select(mrb_state *mrb, mrdb_state *mrdb)
mrb_bool isFirst = TRUE;
int32_t i;
for(i=2; i<mrdb->wcnt; i++) {
for (i=2; i<mrdb->wcnt; i++) {
ps = mrdb->words[i];
bpno = parse_breakpoint_no(ps);
if (bpno == 0) {
@@ -167,7 +167,8 @@ parse_uint(char **sp, uint16_t *n)
return FALSE;
}
for (p = *sp; *p != '\0' && ISDIGIT(*p); p++) ;
for (p = *sp; *p != '\0' && ISDIGIT(*p); p++)
;
if (p != *sp && (i = atoi(*sp)) >= 0) {
*n = (uint16_t)i;
@@ -350,9 +351,9 @@ check_cmd_pattern(const char *pattern, const char *cmd)
}
p = lbracket + 1;
q = (char *)cmd + (lbracket - pattern);
q = (char*)cmd + (lbracket - pattern);
for ( ; p < rbracket && *q != '\0'; p++, q++) {
for (; p < rbracket && *q != '\0'; p++, q++) {
if (*p != *q) {
break;
}
@@ -479,7 +480,8 @@ dbgcmd_quit(mrb_state *mrb, mrdb_state *mrdb)
break;
}
c = buf;
while (buf != '\n' && (buf = getchar()) != EOF) ;
while (buf != '\n' && (buf = getchar()) != EOF)
;
if (c == 'y' || c == 'Y') {
mrdb->dbg->xm = DBG_QUIT;
@@ -500,7 +502,7 @@ dbgcmd_quit(mrb_state *mrb, mrdb_state *mrdb)
if (mrdb->dbg->xm == DBG_QUIT) {
struct RClass *exc;
exc = mrb_define_class(mrb, "DebuggerExit", mrb->eException_class);
exc = mrb_define_class(mrb, "DebuggerExit", E_EXCEPTION);
mrb_raise(mrb, exc, "Exit mrdb");
}
return DBGST_PROMPT;
@@ -19,7 +19,7 @@ dbgcmd_run(mrb_state *mrb, mrdb_state *mrdb)
if (dbg->xphase == DBG_PHASE_RUNNING){
struct RClass *exc;
puts("Start it from the beginning");
exc = mrb_define_class(mrb, "DebuggerRestart", mrb->eException_class);
exc = mrb_define_class(mrb, "DebuggerRestart", E_EXCEPTION);
mrb_raise(mrb, exc, "Restart mrdb");
}
}
+15 -13
View File
@@ -20,7 +20,7 @@
#include "apibreak.h"
#include "apilist.h"
void mrdb_state_free(mrb_state *);
void mrdb_state_free(mrb_state*);
static mrb_debug_context *_debug_context = NULL;
static mrdb_state *_mrdb_state = NULL;
@@ -113,7 +113,7 @@ append_srcpath:
char *buf;
buflen = strlen(item) + 1;
buf = (char *)mrb_malloc(mrb, buflen);
buf = (char*)mrb_malloc(mrb, buflen);
memcpy(buf, item, buflen);
args->srcpath = buf;
}
@@ -123,8 +123,7 @@ append_srcpath:
srcpathlen = strlen(args->srcpath);
itemlen = strlen(item);
args->srcpath =
(char *)mrb_realloc(mrb, args->srcpath, srcpathlen + itemlen + 2);
args->srcpath = (char*)mrb_realloc(mrb, args->srcpath, srcpathlen + itemlen + 2);
args->srcpath[srcpathlen] = '\n';
memcpy(args->srcpath + srcpathlen + 1, item, itemlen + 1);
}
@@ -280,7 +279,7 @@ get_command(mrb_state *mrb, mrdb_state *mrdb)
}
if (i == MAX_COMMAND_LINE) {
for ( ; (c=getchar()) != EOF && c !='\n'; i++) ;
for (; (c=getchar()) != EOF && c !='\n'; i++) ;
}
if (i > MAX_COMMAND_LINE) {
@@ -297,7 +296,8 @@ pick_out_word(mrb_state *mrb, char **pp)
{
char *ps;
for (ps=*pp; ISBLANK(*ps); ps++) ;
for (ps=*pp; ISBLANK(*ps); ps++)
;
if (*ps == '\0') {
return NULL;
}
@@ -336,7 +336,8 @@ parse_command(mrb_state *mrb, mrdb_state *mrdb, char *buf)
}
mrdb->wcnt = 1;
/* set remain parameter */
for ( ; *p && ISBLANK(*p); p++) ;
for (; *p && ISBLANK(*p); p++)
;
if (*p) {
mrdb->words[mrdb->wcnt++] = p;
}
@@ -356,7 +357,8 @@ parse_command(mrb_state *mrb, mrdb_state *mrdb, char *buf)
mrdb->words[1] = pick_out_word(mrb, &p);
if (mrdb->words[1]) {
/* update remain parameter */
for ( ; *p && ISBLANK(*p); p++) ;
for (; *p && ISBLANK(*p); p++)
;
if (*p) {
mrdb->words[mrdb->wcnt++] = p;
}
@@ -364,7 +366,7 @@ parse_command(mrb_state *mrb, mrdb_state *mrdb, char *buf)
}
/* check word #1,#2 */
for ( ; cmd->cmd1; cmd++) {
for (; cmd->cmd1; cmd++) {
wlen = strlen(mrdb->words[0]);
if (wlen < cmd->len1 ||
strncmp(mrdb->words[0], cmd->cmd1, wlen)) {
@@ -386,7 +388,7 @@ parse_command(mrb_state *mrb, mrdb_state *mrdb, char *buf)
/* divide remain parameters */
if (cmd->cmd1 && cmd->div) {
p = mrdb->words[--mrdb->wcnt];
for ( ; mrdb->wcnt<MAX_COMMAND_WORD; mrdb->wcnt++) {
for (; mrdb->wcnt<MAX_COMMAND_WORD; mrdb->wcnt++) {
mrdb->words[mrdb->wcnt] = pick_out_word(mrb, &p);
if (!mrdb->words[mrdb->wcnt]) {
break;
@@ -704,10 +706,10 @@ main(int argc, char **argv)
v = mrb_load_irep_file(mrb, args.rfp);
}
else { /* .rb */
mrbc_context *cc = mrbc_context_new(mrb);
mrbc_filename(mrb, cc, args.fname);
mrb_ccontext *cc = mrb_ccontext_new(mrb);
mrb_ccontext_filename(mrb, cc, args.fname);
v = mrb_load_file_cxt(mrb, args.rfp, cc);
mrbc_context_free(mrb, cc);
mrb_ccontext_free(mrb, cc);
}
if (mrdb->dbg->xm == DBG_QUIT && !mrb_undef_p(v) && mrb->exc) {
const char *classname = mrb_obj_classname(mrb, mrb_obj_value(mrb->exc));
@@ -74,10 +74,6 @@ typedef enum {
MRB_DEBUG_BPTYPE_METHOD,
} mrb_debug_bptype;
struct mrb_irep;
struct mrbc_context;
struct mrb_debug_context;
typedef struct mrb_debug_linepoint {
const char *file;
uint16_t lineno;

Some files were not shown because too many files have changed in this diff Show More