mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
df74d57857
Adds two API helpers that mirror CRuby's RSTRING_GETMEM idiom:
- ARY_GETMEM(a, ptr, len): inside-mruby helper that takes a
struct RArray* and assigns ptr/len from the embed or heap form.
- RARRAY_GETMEM(a, ptr, len): public wrapper on an mrb_value.
Both expand to a single ARY_EMBED_P check, with a uniqued local so
the array argument is evaluated only once (callers can safely pass
expressions with side effects).
Also type the ARY_NO_EMBED stub of ARY_EMBED_PTR as
((mrb_value*)NULL) instead of integer 0, so it composes cleanly in
pointer expressions like the new ARY_GETMEM.
The build-error issue this originated from (compilation with
MRB_ARY_NO_EMBED) was already fixed differently in master via
#ifndef guards (commit 78658d67e). These additions stand on their
own as new API for downstream gems.
Closes #6712, picked from PR by dearblue.
Co-authored-by: Claude <noreply@anthropic.com>