mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user