doc/guides/rom-method-table.md: sync with new MRB_MT_ENTRY shape

Per gemini-code-assist review on #6790: the documentation still
showed the pre-#6790 union mrb_mt_ptr member order (proc first)
and the C99 designated-initializer form of MRB_MT_ENTRY.  Update
both to match the merged code, and add a note explaining why func
must come first in the union.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-04-15 09:42:56 +09:00
parent 81bcd4e931
commit 7e8d74793c
+6 -3
View File
@@ -117,8 +117,8 @@ Defined in `include/mruby/class.h`:
```c
union mrb_mt_ptr {
mrb_func_t func; /* first member: see MRB_MT_ENTRY note */
const struct RProc *proc;
mrb_func_t func;
};
typedef struct mrb_mt_entry {
@@ -139,9 +139,12 @@ typedef struct mrb_mt_tbl {
```c
/* ROM table entry: 3rd param is MRB_ARGS_*() optionally OR'd with
MRB_MT_PRIVATE. The macro OR's in MRB_MT_FUNC automatically. */
MRB_MT_PRIVATE. The macro OR's in MRB_MT_FUNC automatically.
`func` must be the first member of `union mrb_mt_ptr` so that
positional initialization works on legacy C++ compilers that do
not accept C99 designated initializers. */
#define MRB_MT_ENTRY(fn, sym, flags) \
{ { .func = (fn) }, (sym), (flags) | MRB_MT_FUNC }
{ { (fn) }, (sym), (flags) | MRB_MT_FUNC }
/* Extract aspec from combined flags */
#define MRB_MT_ASPEC(flags) ((mrb_aspec)((flags) & 0xffffff))