diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2017-08-23 22:03:18 -0700 |
---|---|---|
committer | Bo Yang <teboring@google.com> | 2017-09-13 14:27:52 -0700 |
commit | c1dd8e85a1314a7bcb2059b842c6830d854fbefa (patch) | |
tree | 24b15fc50665a56b9c658c31623a9fddcdde38bf /ruby/ext/google/protobuf_c/map.c | |
parent | 8741da3e45876f8c55ca062a08726f542f646423 (diff) |
Move parse frame array to the Map object
This makes the frame stack per-parser, and per-thread. Fixes #3250
Diffstat (limited to 'ruby/ext/google/protobuf_c/map.c')
-rw-r--r-- | ruby/ext/google/protobuf_c/map.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ruby/ext/google/protobuf_c/map.c b/ruby/ext/google/protobuf_c/map.c index 4be54c39..0787f6d5 100644 --- a/ruby/ext/google/protobuf_c/map.c +++ b/ruby/ext/google/protobuf_c/map.c @@ -146,6 +146,7 @@ void Map_mark(void* _self) { Map* self = _self; rb_gc_mark(self->value_type_class); + rb_gc_mark(self->parse_frames); if (self->value_type == UPB_TYPE_STRING || self->value_type == UPB_TYPE_BYTES || @@ -174,6 +175,16 @@ VALUE Map_alloc(VALUE klass) { return TypedData_Wrap_Struct(klass, &Map_type, self); } +VALUE Map_push_frame(VALUE map, VALUE val) { + Map* self = ruby_to_Map(map); + return rb_ary_push(self->parse_frames, val); +} + +VALUE Map_pop_frame(VALUE map) { + Map* self = ruby_to_Map(map); + return rb_ary_pop(self->parse_frames); +} + static bool needs_typeclass(upb_fieldtype_t type) { switch (type) { case UPB_TYPE_MESSAGE: @@ -227,6 +238,7 @@ VALUE Map_init(int argc, VALUE* argv, VALUE _self) { self->key_type = ruby_to_fieldtype(argv[0]); self->value_type = ruby_to_fieldtype(argv[1]); + self->parse_frames = rb_ary_new(); // Check that the key type is an allowed type. switch (self->key_type) { |