51 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 8956c5abb5 mruby.h: include mruby/presym.h for all source files
Since presym is now mandatory, mruby.h includes presym.h so that
MRB_SYM() macros are available everywhere without explicit include.
Remove redundant #include <mruby/presym.h> from all source files.

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-09 16:50:58 +09:00
Yukihiro "Matz" Matsumoto b460554d33 vm.c: generalize pre-dispatch argument count check for C methods
Replace check_method_noarg() with check_argument_count() that validates
min <= argc <= max using the full aspec stored in mrb_method_t.flags.
This catches ArgumentError earlier at dispatch time, before entering
the C function.

The old check only handled the special case of aspec==0 (NOARG).
The new check extracts REQ, OPT, REST, POST, KEY, and KDICT from
the aspec and validates accordingly. Keyword hash is counted as
a positional arg only when the method doesn't accept keywords.

Remove MRB_METHOD_NOARG_P macro from proc.h (subsumed by aspec check).
Fix 15 incorrect aspec declarations across the codebase that were
exposed by the stricter enforcement.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-20 14:25:48 +09:00
Yukihiro "Matz" Matsumoto f86caf9e14 mruby-errno: remove MRB_NO_PRESYM fallback code
Simplify struct layouts and macros to use presym-only path.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-19 12:17:51 +09:00
Yukihiro "Matz" Matsumoto b6eb21cac0 mruby-errno: combine variable declaration with initialization 2025-10-27 07:59:20 +09:00
Yukihiro "Matz" Matsumoto e2c4e2f4a7 mruby-errno: add comprehensive call-seq documentation for errno handling
Added complete call-seq documentation for all errno module methods in
mrblib/errno.rb (3 methods):

## Errno Module Methods:

- const_defined?: checks if errno constant exists on the system, provides
  dynamic errno constant detection by querying both system-defined errno
  values and superclass constants with proper boolean return values

- const_missing: handles dynamic errno constant definition when undefined
  constants are referenced, automatically defines errno classes for valid
  system error codes and delegates to superclass for invalid names

- constants: returns array of all available errno constant names on the
  system, includes both already defined constants and those that can be
  dynamically defined, with dependency note for mruby-metaprog gem

Co-authored-by: Atlassian Rovo Dev
2025-08-14 10:52:46 +09:00
Yukihiro "Matz" Matsumoto bac7eb984a mruby-errno: add comprehensive documentation and fix internal method comments
Added complete call-seq documentation for public methods and corrected
internal method documentation structure:

Public API methods
- SystemCallError.new: Create SystemCallError with message/errno
- SystemCallError#errno: Get errno number from exception
- SystemCallError._sys_fail: Internal method to raise errno exceptions
- Errno exception classes#new: Create specific errno exceptions

Fixed documentation structure to follow mruby conventions where internal
methods starting with __ should not have call-seq documentation but only
brief explanatory comments.

Each public method now includes:
- Clear method signatures with parameter and return types
- Descriptions of errno handling behavior
- Practical examples showing exception creation and handling
- Consistent formatting following mruby documentation standards

Co-authored-by: Atlassian Rovo Dev
2025-07-15 17:28:39 +09:00
Yukihiro "Matz" Matsumoto 470c1dc184 mruby-errno: add README.md
The document is written by Google Jules.
2025-06-09 17:14:02 +09:00
Yukihiro "Matz" Matsumoto 85d048c1fb mruby-error: update tests for new Exception#inspect format 2025-05-07 12:19:05 +09:00
Yukihiro "Matz" Matsumoto 9c060b425c mruby-errno: use presym for initialization 2024-06-14 00:25:26 +09:00
Yukihiro "Matz" Matsumoto 87b358a342 Including header files in include/* by <> 2024-03-26 13:59:59 +09:00
Yukihiro "Matz" Matsumoto 2ce5c52726 mruby-errno (mrb_sce_sys_fail): remove redundant assignment 2024-01-04 10:08:22 +09:00
Yukihiro "Matz" Matsumoto c32f7915fb reformat else clause indentation style 2023-05-20 00:21:01 +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 89a34e1b7e Revert "error.c (mrb_sys_fail): errno argument removed from _sys_fail."
Intermediate function calls may update `errno`.
This reverts commit a099ca44f4.
2022-11-19 17:11:56 +09:00
Yukihiro "Matz" Matsumoto a099ca44f4 error.c (mrb_sys_fail): errno argument removed from _sys_fail.
As a side effect, `errno.h` dependency removed from `error.c`.
2022-11-15 13:27:32 +09:00
Yukihiro "Matz" Matsumoto 84c26870d2 mruby-errno/errno.c (mrb_errno_list): no need to check array type here. 2022-10-16 23:20:49 +09:00
Yukihiro "Matz" Matsumoto 9caa4d642c errno.rb: fixed a typo. 2022-09-18 08:01:07 +09:00
Yukihiro "Matz" Matsumoto 3d125aeb89 errno.c (mrb_exxx_init): simplify the function.
Code duplication with mrb_sce_init has been unified.
2022-09-18 07:59:36 +09:00
Yukihiro "Matz" Matsumoto db536da412 errno.c (mrb_sce_sys_fail): SystemCallError may be overridden; fix #5793 2022-09-18 00:07:28 +09:00
dearblue 50ea98e76d Retrieve the StandardError class from mrb_state 2022-09-17 22:03:52 +09:00
Yukihiro "Matz" Matsumoto f1f8221bf3 Merge pull request #5747 from dearblue/errno-summary
Added summary for `mrbgems/mruby-errno`
2022-07-15 13:45:09 +09:00
Yukihiro "Matz" Matsumoto 1d8f4bc775 Merge pull request #5746 from dearblue/cleanup-errno
Delete unnecessary files in `mrbgems/mruby-errno`
2022-07-15 13:44:35 +09:00
dearblue bd98b71668 Added summary for mrbgems/mruby-errno 2022-07-14 21:55:15 +09:00
dearblue a74b0fb62b Delete unnecessary files in mrbgems/mruby-errno
This is because it has been integrated into the mruby repository.
2022-07-14 21:53:03 +09:00
dearblue 66b72430e6 Allow negative errno to be handled as well 2022-07-14 21:49:44 +09:00
dearblue c14e26d79e Define Errno::EXXX when needed
If the `Errno::EXXX` class is defined minimally when needed, it will save about 17 KiB of RAM in a 32-bit environment.
Define the singular methods `.const_defined?`, `.const_missing` and `.constants` in the `Errno` module and act as if there are classes that have not yet been defined.

However, if real classes are enumerated, for example by the following code, the effect is lost.

```ruby
Errno.constants.map { |id| Errno.const_get(id) }
```

But I believe that such codes are rarely written with the intention of being written.

In this patch, the `Errno::EXXX#initialize` method is no longer defined for further memory reduction.
Instead, it has been merged into the `SystemCallError#initialize` method.
2022-07-10 20:53:55 +09:00
dearblue 9a84ef926b Avoid adding MRUBY_ROOT/src to cc.include_paths 2022-07-02 09:56:13 +09:00
Yukihiro "Matz" Matsumoto bdc244e9b0 mruby-errno/errno.c: fix integer size mixtures. 2022-04-21 14:47:15 +09:00
Yukihiro "Matz" Matsumoto 2f918f1926 errno.c: fix int and mrb_int mixture.
`strerror(3) takes `int` not `mrb_int`.
2022-04-12 16:11:01 +09:00
Yukihiro "Matz" Matsumoto 3dabd18dcc errno.c: resolve signedness warning. 2022-04-02 18:25:13 +09:00
Yukihiro "Matz" Matsumoto b99c389ec3 internal.h: aggregate internal functions.
Internal functions can only be called from within the library.
Functions listed in `mruby/internal.h` can be called from:

* core (src/*.c)
* gems (mrbgems/**/*.c)

But not from the application linked with `libmruby`.
2022-04-02 18:25:13 +09:00
Yukihiro "Matz" Matsumoto ad3ce7b41c Merge pull request #5642 from dearblue/errmesg
Avoid direct access to error messages as instance variables
2022-02-13 20:59:47 +09:00
Yukihiro "Matz" Matsumoto 6cc6d9b078 Merge pull request #5644 from dearblue/errno-nopresym
Support `disable_presym` for `mrbgems/mruby-errno`
2022-02-07 16:05:22 +09:00
dearblue 0a4f21c60f Support disable_presym for mrbgems/mruby-errno
The `mrbgems/mruby-errno/src/known_errors_def.cstub` file has been extended, so the `mrbgems/mruby-errno/src/known_errors_e2c.cstub` file is no longer needed.
2022-02-06 18:39:46 +09:00
dearblue a82220211d Support MRB_NO_STDIO for mrbgems/mruby-errno 2022-02-06 16:12:41 +09:00
dearblue d6773cbd71 Avoid direct access to error messages as instance variables
ref. #2485

The `SystemCallError#to_s` method also needed to be modified, but since it has no functional difference from the `Exception#to_s` method, it will be removed.
2022-02-06 15:45:13 +09:00
Chris Reuter 198e10473b Updated mruby-errno/README.md to pass the lint checks. 2022-01-29 18:40:05 -05:00
Yukihiro "Matz" Matsumoto c5bdfe1bd4 mruby-errno: add errno constants to known_errors.def.
Add unlisted errno constants found in macOS and FreeBSD.
If you see unlisted errno, please report.
2022-01-26 12:58:52 +09:00
Yukihiro "Matz" Matsumoto b7cdb59f26 errno.c: stop generating Errno::Exxx error classes on the fly. 2022-01-26 12:29:19 +09:00
Yukihiro "Matz" Matsumoto dd93dd7419 errno.c: refactor _sys_fail to avoid mrb_funcall. 2022-01-25 16:01:33 +09:00
Yukihiro "Matz" Matsumoto 9892742d27 errno.c: use C array instead of a hash table to lookup a errno class.
To reduce memory consumption by avoiding allocating Ruby objects.
2022-01-25 11:15:34 +09:00
Yukihiro "Matz" Matsumoto 194d0c6f46 mruby-errno: change the format of known_errors_e2c.cstub. 2022-01-25 11:08:52 +09:00
Yukihiro "Matz" Matsumoto 5c7338491c errno.c: use mrb_fixnum_p() instead of mrb_type(). 2022-01-25 10:39:13 +09:00
Yukihiro "Matz" Matsumoto 6744d69d3d errno.c: replace string literals by MRB_SYM(). 2022-01-25 10:39:13 +09:00
Yukihiro "Matz" Matsumoto 1e866dffc4 errno.c: bundled mrbgem need not to support mruby 1.x. 2022-01-25 10:28:50 +09:00
Yukihiro "Matz" Matsumoto 0f5829795e errno.c: use MRB_SYM() instead of mrb_intern_lit(). 2022-01-25 10:26:34 +09:00
Yukihiro "Matz" Matsumoto 3b5486e3ae mruby-errno/test: update test suites not to report warnings. 2022-01-25 10:22:28 +09:00
Yukihiro "Matz" Matsumoto 3a15d18ebb errno.c: hide internal _sys_fail from backtrace. 2022-01-24 18:14:28 +09:00
Yukihiro "Matz" Matsumoto a60073d7b9 mruby-errno: remove .gitkeep. 2022-01-24 18:07:59 +09:00
Yukihiro "Matz" Matsumoto 0a6d57ab3c Merge remote-tracking branch 'mruby-errno/master' 2022-01-24 17:58:41 +09:00