Add RUBY_REFERENCES

Instead of `RUBY_REFERENCES_START` and `RUBY_REFERENCES_END`, so that
auto-indent works well.
This commit is contained in:
Nobuyoshi Nakada 2023-11-26 19:09:16 +09:00
parent 30f7b7a053
commit 0cdad3b92a
4 changed files with 15 additions and 11 deletions

5
dir.c
View File

@ -473,9 +473,10 @@ dir_free(void *ptr)
if (dir->dir) closedir(dir->dir); if (dir->dir) closedir(dir->dir);
} }
RUBY_REFERENCES_START(dir_refs) RUBY_REFERENCES(dir_refs) = {
RUBY_REF_EDGE(struct dir_data, path), RUBY_REF_EDGE(struct dir_data, path),
RUBY_REFERENCES_END RUBY_REF_END
};
static const rb_data_type_t dir_data_type = { static const rb_data_type_t dir_data_type = {
"dir", "dir",

View File

@ -789,9 +789,9 @@ Some Macros have been provided to make edge referencing easier:
* <code>RUBY_TYPED_DECL_MARKING</code> =A flag that can be set on the +ruby_data_type_t+ to indicate that references are being declared as edges. * <code>RUBY_TYPED_DECL_MARKING</code> =A flag that can be set on the +ruby_data_type_t+ to indicate that references are being declared as edges.
* <code>RUBY_REFERENCES_START(ref_list_name)</code> - Define _ref_list_name_ as a list of references * <code>RUBY_REFERENCES(ref_list_name)</code> - Define _ref_list_name_ as a list of references
* <code>RUBY_REFERENCES_END</code> - Mark the end of the references list. This will take care of terminating the list correctly * <code>RUBY_REF_END</code> - The end mark of the references list.
* <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+
@ -808,11 +808,12 @@ The example below is from Dir (defined in +dir.c+)
rb_encoding *enc; rb_encoding *enc;
} }
// 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`.
// terminating with RUBY_REF_END // Needs terminating with RUBY_REF_END
RUBY_REFERENCES_START(dir_refs) RUBY_REFERENCES(dir_refs) = {
RUBY_REF_EDGE(dir_data, path), RUBY_REF_EDGE(dir_data, path),
RUBY_REFERENCES_END RUBY_REF_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
// no longer need a marking callback and add RUBY_TYPED_DECL_MARKING to the // no longer need a marking callback and add RUBY_TYPED_DECL_MARKING to the

View File

@ -195,7 +195,7 @@ struct enumerator {
int kw_splat; int kw_splat;
}; };
RUBY_REFERENCES_START(enumerator_refs) RUBY_REFERENCES(enumerator_refs) = {
RUBY_REF_EDGE(struct enumerator, obj), RUBY_REF_EDGE(struct enumerator, obj),
RUBY_REF_EDGE(struct enumerator, args), RUBY_REF_EDGE(struct enumerator, args),
RUBY_REF_EDGE(struct enumerator, fib), RUBY_REF_EDGE(struct enumerator, fib),
@ -205,7 +205,8 @@ RUBY_REFERENCES_START(enumerator_refs)
RUBY_REF_EDGE(struct enumerator, stop_exc), RUBY_REF_EDGE(struct enumerator, stop_exc),
RUBY_REF_EDGE(struct enumerator, size), RUBY_REF_EDGE(struct enumerator, size),
RUBY_REF_EDGE(struct enumerator, procs), RUBY_REF_EDGE(struct enumerator, procs),
RUBY_REFERENCES_END RUBY_REF_END
};
static VALUE rb_cGenerator, rb_cYielder, rb_cEnumProducer; static VALUE rb_cGenerator, rb_cYielder, rb_cEnumProducer;

View File

@ -47,7 +47,8 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
#define RUBY_REF_EDGE(s, p) offsetof(s, p) #define RUBY_REF_EDGE(s, p) offsetof(s, p)
#define RUBY_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(t) static const size_t t[]
#define RUBY_REFERENCES_START(t) RUBY_REFERENCES(t) = {
#define RUBY_REFERENCES_END RUBY_REF_END, }; #define RUBY_REFERENCES_END RUBY_REF_END, };
/* gc.c */ /* gc.c */