Prefix REF_EDGE and REFS_LIST_PTR with RUBY_

Also move `struct` so that `typedef`-ed names can be used.
This commit is contained in:
Nobuyoshi Nakada 2023-11-26 16:04:27 +09:00
parent 18f218d6a1
commit 30f7b7a053
4 changed files with 17 additions and 17 deletions

4
dir.c
View File

@ -474,13 +474,13 @@ dir_free(void *ptr)
} }
RUBY_REFERENCES_START(dir_refs) RUBY_REFERENCES_START(dir_refs)
REF_EDGE(dir_data, path), RUBY_REF_EDGE(struct dir_data, path),
RUBY_REFERENCES_END RUBY_REFERENCES_END
static const rb_data_type_t dir_data_type = { static const rb_data_type_t dir_data_type = {
"dir", "dir",
{ {
REFS_LIST_PTR(dir_refs), RUBY_REFS_LIST_PTR(dir_refs),
dir_free, dir_free,
NULL, // Nothing allocated externally, so don't need a memsize function NULL, // Nothing allocated externally, so don't need a memsize function
}, },

View File

@ -795,7 +795,7 @@ Some Macros have been provided to make edge referencing easier:
* <code>RUBY_REF_EDGE(struct, member)</code> - Declare _member_ as a VALUE edge from _struct_. Use this after +RUBY_REFERENCES_START+ * <code>RUBY_REF_EDGE(struct, member)</code> - Declare _member_ as a VALUE edge from _struct_. Use this after +RUBY_REFERENCES_START+
* +REFS_LIST_PTR+ - Coerce the reference list into a format that can be * +RUBY_REFS_LIST_PTR+ - Coerce the reference list into a format that can be
accepted by the existing +dmark+ interface. accepted by the existing +dmark+ interface.
The example below is from Dir (defined in +dir.c+) The example below is from Dir (defined in +dir.c+)
@ -811,7 +811,7 @@ The example below is from Dir (defined in +dir.c+)
// Define a reference list `dir_refs` containing a single entry to `path`, and // Define a reference list `dir_refs` containing a single entry to `path`, and
// terminating with RUBY_REF_END // terminating with RUBY_REF_END
RUBY_REFERENCES_START(dir_refs) RUBY_REFERENCES_START(dir_refs)
REF_EDGE(dir_data, path), RUBY_REF_EDGE(dir_data, path),
RUBY_REFERENCES_END RUBY_REFERENCES_END
// Override the "dmark" field with the defined reference list now that we // Override the "dmark" field with the defined reference list now that we
@ -819,7 +819,7 @@ The example below is from Dir (defined in +dir.c+)
// flags field // flags field
static const rb_data_type_t dir_data_type = { static const rb_data_type_t dir_data_type = {
"dir", "dir",
{REFS_LIST_PTR(dir_refs), dir_free, dir_memsize,}, {RUBY_REFS_LIST_PTR(dir_refs), dir_free, dir_memsize,},
0, NULL, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_DECL_MARKING 0, NULL, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_DECL_MARKING
}; };

View File

@ -196,15 +196,15 @@ struct enumerator {
}; };
RUBY_REFERENCES_START(enumerator_refs) RUBY_REFERENCES_START(enumerator_refs)
REF_EDGE(enumerator, obj), RUBY_REF_EDGE(struct enumerator, obj),
REF_EDGE(enumerator, args), RUBY_REF_EDGE(struct enumerator, args),
REF_EDGE(enumerator, fib), RUBY_REF_EDGE(struct enumerator, fib),
REF_EDGE(enumerator, dst), RUBY_REF_EDGE(struct enumerator, dst),
REF_EDGE(enumerator, lookahead), RUBY_REF_EDGE(struct enumerator, lookahead),
REF_EDGE(enumerator, feedvalue), RUBY_REF_EDGE(struct enumerator, feedvalue),
REF_EDGE(enumerator, stop_exc), RUBY_REF_EDGE(struct enumerator, stop_exc),
REF_EDGE(enumerator, size), RUBY_REF_EDGE(struct enumerator, size),
REF_EDGE(enumerator, procs), RUBY_REF_EDGE(struct enumerator, procs),
RUBY_REFERENCES_END RUBY_REFERENCES_END
static VALUE rb_cGenerator, rb_cYielder, rb_cEnumProducer; static VALUE rb_cGenerator, rb_cYielder, rb_cEnumProducer;
@ -259,7 +259,7 @@ VALUE rb_cArithSeq;
static const rb_data_type_t enumerator_data_type = { static const rb_data_type_t enumerator_data_type = {
"enumerator", "enumerator",
{ {
REFS_LIST_PTR(enumerator_refs), RUBY_REFS_LIST_PTR(enumerator_refs),
RUBY_TYPED_DEFAULT_FREE, RUBY_TYPED_DEFAULT_FREE,
NULL, // Nothing allocated externally, so don't need a memsize function NULL, // Nothing allocated externally, so don't need a memsize function
NULL, NULL,

View File

@ -44,8 +44,8 @@
RBIMPL_SYMBOL_EXPORT_BEGIN() RBIMPL_SYMBOL_EXPORT_BEGIN()
#define REF_EDGE(s, p) (offsetof(struct s, p)) #define RUBY_REF_EDGE(s, p) offsetof(s, p)
#define REFS_LIST_PTR(l) ((RUBY_DATA_FUNC)l) #define RUBY_REFS_LIST_PTR(l) (RUBY_DATA_FUNC)(l)
#define RUBY_REF_END SIZE_MAX #define RUBY_REF_END SIZE_MAX
#define RUBY_REFERENCES_START(t) static const size_t t[] = { #define RUBY_REFERENCES_START(t) static const size_t t[] = {
#define RUBY_REFERENCES_END RUBY_REF_END, }; #define RUBY_REFERENCES_END RUBY_REF_END, };