29 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 00905566ac mruby-dir: combine variable declaration with initialization 2025-11-08 14:27:44 +09:00
Yukihiro "Matz" Matsumoto 610ff67906 HAL: rename functions to mrb_hal_<feature>_<name> convention
rename all HAL functions from mrb_<feature>_hal_<name>() to
mrb_hal_<feature>_<name>() for better grouping and clarity. this makes all
HAL functions immediately identifiable with the mrb_hal_* prefix.

affected gems:
- mruby-task: mrb_task_hal_* -> mrb_hal_task_*
- mruby-io: mrb_io_hal_* -> mrb_hal_io_*
- mruby-socket: mrb_socket_hal_* -> mrb_hal_socket_*
- mruby-dir: mrb_dir_hal_* -> mrb_hal_dir_*

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-16 09:59:03 +09:00
Yukihiro "Matz" Matsumoto 74c0fb9c6e mruby-dir: introduce HAL for platform abstraction
platform-specific directory operations separated into hal-posix-dir and
hal-win-dir gems. this allows mruby-dir to support embedded platforms and
simplifies platform-specific implementations.

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-16 08:17:43 +09:00
Yukihiro "Matz" Matsumoto c54d5abdaf mruby-dir: unify int and mrb_int types for consistency
Change int variables to mrb_int in mrb_dir_getwd and mrb_dir_chroot
to maintain consistent use of mruby's integer type internally.
Keep explicit casts only at system interface boundaries where
different types are required by system calls.

Eliminates VC warning C4267 while following the same type
unification approach used in pack.c.

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-03 19:46:02 +09:00
Yukihiro "Matz" Matsumoto 0ce99e442d mruby-dir: fix C4244 warning in mrb_dir_getwd function
use mrb_int for size variable and cast to size_t only when calling getcwd.
this maintains consistency with mruby type system while avoiding
conversion warnings on windows vc compiler.

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-22 18:20:47 +09:00
Yukihiro "Matz" Matsumoto 2113b7cd23 mruby-dir: implement Dir.children in c for improved performance
Moved Dir.children from Ruby to C implementation to eliminate
Ruby loop overhead and string comparison inefficiencies.
Uses existing skip_name_p helper to filter out "." and ".." entries
efficiently in C.

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-19 10:06:16 +09:00
Yukihiro "Matz" Matsumoto c699b211d7 mruby-dir: implement Dir.entries in c for improved performance
Moved Dir.entries from Ruby to C implementation to eliminate
Ruby loop overhead and array allocation inefficiencies.
Builds result array directly in C for better performance.

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-19 10:06:16 +09:00
Yukihiro "Matz" Matsumoto 785d3b81d5 mruby-dir: add comprehensive call-seq documentation for Ruby and C methods
Added complete call-seq documentation for directory operations across
both mrblib/dir.rb (7 Ruby methods) and src/dir.c (12 C methods):

## Ruby Methods (mrblib/dir.rb):

- Dir instance methods: each, each_child for directory iteration with
  enumerator support when no block given

- Dir class methods: entries, children for getting directory contents
  as arrays, foreach for iteration, open for directory access with
  optional block handling, chdir for changing working directory with
  optional block for temporary changes

## C Methods (src/dir.c):

- Dir class methods: delete for removing directories, exist? for checking
  directory existence, getwd/pwd for current directory, mkdir for creating
  directories with optional permissions, chroot for changing filesystem root,
  empty? for checking if directory is empty

- Dir instance methods: new for creating directory objects, close for
  closing directory streams, read for reading directory entries, rewind
  for repositioning to beginning, seek/tell/pos for directory positioning

Co-authored-by: Atlassian Rovo Dev
2025-08-14 10:52:45 +09:00
dearblue 1326017d1d Omit the _WIN64 definition check
Checking the official MSVC documentation, if `_WIN64` is defined, then `_WIN32` is also defined.
https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros

I could not find any documentation on MinGW, but I assume it is not a problem.
2024-12-07 22:47:28 +09:00
Yukihiro "Matz" Matsumoto 3628d093f4 mruby-dir: use presym for initialization 2024-06-14 00:27:13 +09:00
Yukihiro "Matz" Matsumoto 87b358a342 Including header files in include/* by <> 2024-03-26 13:59:59 +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
Ray Chason 23e9befbc0 Changes to cross-compile with DJGPP 2023-06-17 17:20:33 -04: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 b4c936b533 use new E_EXCEPTION and E_STANDARD_ERROR; ref #5924 2023-02-10 15:21:38 +09:00
Yukihiro "Matz" Matsumoto 3518d15d04 Merge pull request #5875 from dearblue/dir-cstr
Get argument of the `Dir` method takes a C string directly
2022-12-26 13:26:56 +09:00
Yukihiro "Matz" Matsumoto 2656a92380 Merge pull request #5874 from dearblue/dir-funcs
Hide substance functions of methods in `mruby-dir`
2022-12-26 12:58:44 +09:00
dearblue 1fb19ca046 Get argument of the Dir method takes a C string directly 2022-12-25 21:25:30 +09:00
dearblue 71df263bdf Hide substance functions of methods in mruby-dir 2022-12-25 21:25:30 +09:00
dearblue 35490c2c32 Define also the exception class IOError in mruby-dir
Since `IOError` is a standard exception class in Ruby, there is no need to assume different superclasses.
The Ruby specification allows repeated class definitions as long as the superclass is the same.

This also avoids using the `mruby/ext/io.h` file to reference `E_IO_ERROR`.
2022-12-25 21:25:21 +09:00
dearblue fec74cd040 Avoid uses mruby/src/error.h file 2022-12-25 17:31:53 +09:00
Yukihiro "Matz" Matsumoto d51d5825ad mruby-dir/dir.c: update compatibility macros for Windows 2022-12-22 11:13:50 +09:00
Yukihiro "Matz" Matsumoto 3d6a4c39bf mruby-dir: reformat 2022-12-21 15:18:09 +09:00
Yukihiro "Matz" Matsumoto d656ea87c6 mruby-dir: add compatibility macro 2022-12-21 15:15:10 +09:00
Yukihiro "Matz" Matsumoto b93a624b5f mruby-dir/dir.c: add new method Dir.empty?(path) 2022-12-21 15:11:37 +09:00
Yukihiro "Matz" Matsumoto 4b48c86103 mruby-dir: extra spaces and typos are removed 2022-12-20 22:12:21 +09:00
Yukihiro "Matz" Matsumoto 277341f694 Add 'mrbgems/mruby-dir/' from commit '89dceefa1250fb1ae868d4cb52498e9e24293cd1'
git-subtree-dir: mrbgems/mruby-dir
git-subtree-mainline: f2d43069f0
git-subtree-split: 89dceefa12
2022-12-20 18:06:36 +09:00