浏览代码

Fixed conformance test regression: empty string wrapper.

Joshua Haberman 5 年之前
父节点
当前提交
5f25400250
共有 2 个文件被更改,包括 18 次插入1 次删除
  1. 18 0
      ruby/ext/google/protobuf_c/encode_decode.c
  2. 0 1
      ruby/tests/common_tests.rb

+ 18 - 0
ruby/ext/google/protobuf_c/encode_decode.c

@@ -626,6 +626,14 @@ static bool uint32wrapper_handler(void* closure, const void* hd, uint32_t val) {
   return true;
   return true;
 }
 }
 
 
+static void* startstringwrapper_handler(void* closure, const void* hd,
+                                        size_t size_hint) {
+  VALUE* rbval = closure;
+  (void)size_hint;
+  *rbval = get_frozen_string(NULL, 0, false);
+  return closure;
+}
+
 static size_t stringwrapper_handler(void* closure, const void* hd,
 static size_t stringwrapper_handler(void* closure, const void* hd,
                                     const char* ptr, size_t len,
                                     const char* ptr, size_t len,
                                     const upb_bufhandle* handle) {
                                     const upb_bufhandle* handle) {
@@ -634,6 +642,14 @@ static size_t stringwrapper_handler(void* closure, const void* hd,
   return len;
   return len;
 }
 }
 
 
+static void* startbyteswrapper_handler(void* closure, const void* hd,
+                                       size_t size_hint) {
+  VALUE* rbval = closure;
+  (void)size_hint;
+  *rbval = get_frozen_string(NULL, 0, true);
+  return closure;
+}
+
 static size_t byteswrapper_handler(void* closure, const void* hd,
 static size_t byteswrapper_handler(void* closure, const void* hd,
                                    const char* ptr, size_t len,
                                    const char* ptr, size_t len,
                                    const upb_bufhandle* handle) {
                                    const upb_bufhandle* handle) {
@@ -760,9 +776,11 @@ static void add_handlers_for_wrapper(const upb_msgdef* msgdef,
       upb_handlers_setuint32(h, f, uint32wrapper_handler, NULL);
       upb_handlers_setuint32(h, f, uint32wrapper_handler, NULL);
       break;
       break;
     case UPB_WELLKNOWN_STRINGVALUE:
     case UPB_WELLKNOWN_STRINGVALUE:
+      upb_handlers_setstartstr(h, f, startstringwrapper_handler, NULL);
       upb_handlers_setstring(h, f, stringwrapper_handler, NULL);
       upb_handlers_setstring(h, f, stringwrapper_handler, NULL);
       break;
       break;
     case UPB_WELLKNOWN_BYTESVALUE:
     case UPB_WELLKNOWN_BYTESVALUE:
+      upb_handlers_setstartstr(h, f, startbyteswrapper_handler, NULL);
       upb_handlers_setstring(h, f, byteswrapper_handler, NULL);
       upb_handlers_setstring(h, f, byteswrapper_handler, NULL);
       break;
       break;
     case UPB_WELLKNOWN_BOOLVALUE:
     case UPB_WELLKNOWN_BOOLVALUE:

+ 0 - 1
ruby/tests/common_tests.rb

@@ -1411,7 +1411,6 @@ module CommonTests
     run_test.call(m)
     run_test.call(m)
     m.oneof_bytes_as_value = 'fun'
     m.oneof_bytes_as_value = 'fun'
     run_test.call(m)
     run_test.call(m)
-    puts m
   end
   end
 
 
   def test_top_level_wrappers
   def test_top_level_wrappers