aboutsummaryrefslogtreecommitdiff
path: root/ruby/ext/google/protobuf_c/protobuf.c
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2015-07-15 11:05:10 -0700
committerJosh Haberman <jhaberman@gmail.com>2015-07-16 12:25:55 -0700
commit181c7f26360429b236ab833c746d10d97811931f (patch)
tree3abdbaf4abb0115c17892bcf2a1629c9475f147c /ruby/ext/google/protobuf_c/protobuf.c
parentfde6e89f99eda04a4f1b8677bcea07e6c2040405 (diff)
downloadprotobuf-181c7f26360429b236ab833c746d10d97811931f.tar.gz
protobuf-181c7f26360429b236ab833c746d10d97811931f.tar.bz2
protobuf-181c7f26360429b236ab833c746d10d97811931f.zip
Added Ruby to conformance tests.
This involved fixing a few important bugs in the Ruby implementation -- mostly cases of mixing upb field types and descriptor types (upb field types do not distinguish between int/sint/fixed/sfixed like descriptor types do). Also added protobuf-specific exceptions so parse errors can be caught specifically. Change-Id: Ib49d3db976900b2c6f3455c8b88af52cfb86e036
Diffstat (limited to 'ruby/ext/google/protobuf_c/protobuf.c')
-rw-r--r--ruby/ext/google/protobuf_c/protobuf.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ruby/ext/google/protobuf_c/protobuf.c b/ruby/ext/google/protobuf_c/protobuf.c
index d0625a10..ca0f7b7c 100644
--- a/ruby/ext/google/protobuf_c/protobuf.c
+++ b/ruby/ext/google/protobuf_c/protobuf.c
@@ -39,6 +39,9 @@
// Ruby integers) to MessageDef/EnumDef instances (as Ruby values).
VALUE upb_def_to_ruby_obj_map;
+VALUE cError;
+VALUE cParseError;
+
void add_def_obj(const void* def, VALUE value) {
rb_hash_aset(upb_def_to_ruby_obj_map, ULL2NUM((intptr_t)def), value);
}
@@ -96,6 +99,9 @@ void Init_protobuf_c() {
RepeatedField_register(protobuf);
Map_register(protobuf);
+ cError = rb_const_get(protobuf, rb_intern("Error"));
+ cParseError = rb_const_get(protobuf, rb_intern("ParseError"));
+
rb_define_singleton_method(protobuf, "deep_copy",
Google_Protobuf_deep_copy, 1);