Implement declarative references for enumerator
This commit is contained in:
parent
405966e239
commit
22b349294b
Notes:
git
2023-03-17 19:21:13 +00:00
51
enumerator.c
51
enumerator.c
@ -188,6 +188,18 @@ struct enumerator {
|
|||||||
int kw_splat;
|
int kw_splat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RUBY_REFERENCES_START(enumerator_refs)
|
||||||
|
REF_EDGE(enumerator, obj),
|
||||||
|
REF_EDGE(enumerator, args),
|
||||||
|
REF_EDGE(enumerator, fib),
|
||||||
|
REF_EDGE(enumerator, dst),
|
||||||
|
REF_EDGE(enumerator, lookahead),
|
||||||
|
REF_EDGE(enumerator, feedvalue),
|
||||||
|
REF_EDGE(enumerator, stop_exc),
|
||||||
|
REF_EDGE(enumerator, size),
|
||||||
|
REF_EDGE(enumerator, procs),
|
||||||
|
RUBY_REFERENCES_END
|
||||||
|
|
||||||
static VALUE rb_cGenerator, rb_cYielder, rb_cEnumProducer;
|
static VALUE rb_cGenerator, rb_cYielder, rb_cEnumProducer;
|
||||||
|
|
||||||
struct generator {
|
struct generator {
|
||||||
@ -237,39 +249,6 @@ struct enum_product {
|
|||||||
|
|
||||||
VALUE rb_cArithSeq;
|
VALUE rb_cArithSeq;
|
||||||
|
|
||||||
/*
|
|
||||||
* Enumerator
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
enumerator_mark(void *p)
|
|
||||||
{
|
|
||||||
struct enumerator *ptr = p;
|
|
||||||
rb_gc_mark_movable(ptr->obj);
|
|
||||||
rb_gc_mark_movable(ptr->args);
|
|
||||||
rb_gc_mark_movable(ptr->fib);
|
|
||||||
rb_gc_mark_movable(ptr->dst);
|
|
||||||
rb_gc_mark_movable(ptr->lookahead);
|
|
||||||
rb_gc_mark_movable(ptr->feedvalue);
|
|
||||||
rb_gc_mark_movable(ptr->stop_exc);
|
|
||||||
rb_gc_mark_movable(ptr->size);
|
|
||||||
rb_gc_mark_movable(ptr->procs);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
enumerator_compact(void *p)
|
|
||||||
{
|
|
||||||
struct enumerator *ptr = p;
|
|
||||||
ptr->obj = rb_gc_location(ptr->obj);
|
|
||||||
ptr->args = rb_gc_location(ptr->args);
|
|
||||||
ptr->fib = rb_gc_location(ptr->fib);
|
|
||||||
ptr->dst = rb_gc_location(ptr->dst);
|
|
||||||
ptr->lookahead = rb_gc_location(ptr->lookahead);
|
|
||||||
ptr->feedvalue = rb_gc_location(ptr->feedvalue);
|
|
||||||
ptr->stop_exc = rb_gc_location(ptr->stop_exc);
|
|
||||||
ptr->size = rb_gc_location(ptr->size);
|
|
||||||
ptr->procs = rb_gc_location(ptr->procs);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define enumerator_free RUBY_TYPED_DEFAULT_FREE
|
#define enumerator_free RUBY_TYPED_DEFAULT_FREE
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
@ -281,12 +260,12 @@ enumerator_memsize(const void *p)
|
|||||||
static const rb_data_type_t enumerator_data_type = {
|
static const rb_data_type_t enumerator_data_type = {
|
||||||
"enumerator",
|
"enumerator",
|
||||||
{
|
{
|
||||||
enumerator_mark,
|
REFS_LIST_PTR(enumerator_refs),
|
||||||
enumerator_free,
|
enumerator_free,
|
||||||
enumerator_memsize,
|
enumerator_memsize,
|
||||||
enumerator_compact,
|
NULL,
|
||||||
},
|
},
|
||||||
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
0, NULL, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_DECL_MARKING
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct enumerator *
|
static struct enumerator *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user