google-protobuf 3.20.0.rc.1 → 3.20.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: deb2618df4d80bce774d4aa3114327b80e098ccbe6ec4b337c96f93137cb2576
4
- data.tar.gz: a09de36f1d04b8fc90774c3b4d96c5fc040fcde819b847d8a9db768969e85cd8
3
+ metadata.gz: e0eaa0e9490c0ca710f54751ec4484ee577061c3713ebfb01c49f61a6c12793f
4
+ data.tar.gz: 6c2740af26293911ba980f6a303055763382ca1f4315a404e4e77a51a603ad16
5
5
  SHA512:
6
- metadata.gz: 50ccb5a50378630bf39a0b7ba3141c5ee362062ea19fb5173137d9bfbb0dc8eac5880c8cf9697368d36bac4228c24ec51c6d895bb45e2614babe81cd84078d23
7
- data.tar.gz: 958b5976cb6a6b901a5de108529ef460c8a8ca97cd2a1822334c1ca607e8d39b0c6acc4fe1b427072c976366bcb525b1eb486edd0da64df7e40e373d88da5ba7
6
+ metadata.gz: a8b72735dc34f30fd2bee0eb251724237dbd05bb0408af0748b8a352926a9d1d1a54d90bfaca4e7c3af7909e88ea6c87037e39859b0e7d1cd92dc2630c0166cf
7
+ data.tar.gz: 50f1f1bc894b82557e66d733789b5d092defc0895c8af87ee43d38e05e886695ca1120e4046020284cc7c2301defc82875c8d6c7e96daea45090aea417ec3fc8
@@ -340,19 +340,19 @@ uint64_t Msgval_GetHash(upb_MessageValue val, TypeInfo type_info,
340
340
  uint64_t seed) {
341
341
  switch (type_info.type) {
342
342
  case kUpb_CType_Bool:
343
- return Wyhash(&val, 1, seed, kWyhashSalt);
343
+ return _upb_Hash(&val, 1, seed);
344
344
  case kUpb_CType_Float:
345
345
  case kUpb_CType_Int32:
346
346
  case kUpb_CType_UInt32:
347
347
  case kUpb_CType_Enum:
348
- return Wyhash(&val, 4, seed, kWyhashSalt);
348
+ return _upb_Hash(&val, 4, seed);
349
349
  case kUpb_CType_Double:
350
350
  case kUpb_CType_Int64:
351
351
  case kUpb_CType_UInt64:
352
- return Wyhash(&val, 8, seed, kWyhashSalt);
352
+ return _upb_Hash(&val, 8, seed);
353
353
  case kUpb_CType_String:
354
354
  case kUpb_CType_Bytes:
355
- return Wyhash(val.str_val.data, val.str_val.size, seed, kWyhashSalt);
355
+ return _upb_Hash(val.str_val.data, val.str_val.size, seed);
356
356
  case kUpb_CType_Message:
357
357
  return Message_Hash(val.msg_val, type_info.def.msgdef, seed);
358
358
  default:
@@ -159,6 +159,7 @@ VALUE DescriptorPool_add_serialized_file(VALUE _self,
159
159
  rb_raise(cTypeError, "Unable to build file to DescriptorPool: %s",
160
160
  upb_Status_ErrorMessage(&status));
161
161
  }
162
+ RB_GC_GUARD(arena_rb);
162
163
  return get_filedef_obj(_self, filedef);
163
164
  }
164
165
 
@@ -23,6 +23,6 @@ $INCFLAGS << "$(srcdir)/third_party/utf8_range"
23
23
 
24
24
  $srcs = ["protobuf.c", "convert.c", "defs.c", "message.c",
25
25
  "repeated_field.c", "map.c", "ruby-upb.c", "wrap_memcpy.c",
26
- "utf8_range.c"]
26
+ "naive.c", "range2-neon.c", "range2-sse.c"]
27
27
 
28
28
  create_makefile(ext_name)
@@ -161,10 +161,8 @@ void Message_PrintMessage(StringBuilder* b, const upb_Message* msg,
161
161
 
162
162
  if (upb_FieldDef_IsMap(field)) {
163
163
  const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(field);
164
- const upb_FieldDef* key_f =
165
- upb_MessageDef_FindFieldByNumberWithSize(entry_m, 1);
166
- const upb_FieldDef* val_f =
167
- upb_MessageDef_FindFieldByNumberWithSize(entry_m, 2);
164
+ const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry_m, 1);
165
+ const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry_m, 2);
168
166
  TypeInfo val_info = TypeInfo_get(val_f);
169
167
  Map_Inspect(b, msgval.map_val, upb_FieldDef_CType(key_f), val_info);
170
168
  } else if (upb_FieldDef_IsRepeated(field)) {
@@ -365,7 +363,7 @@ static VALUE Message_field_accessor(VALUE _self, const upb_FieldDef* f,
365
363
  upb_MessageValue wrapper = upb_Message_Get(self->msg, f);
366
364
  const upb_MessageDef* wrapper_m = upb_FieldDef_MessageSubDef(f);
367
365
  const upb_FieldDef* value_f =
368
- upb_MessageDef_FindFieldByNumberWithSize(wrapper_m, 1);
366
+ upb_MessageDef_FindFieldByNumber(wrapper_m, 1);
369
367
  upb_MessageValue value = upb_Message_Get(wrapper.msg_val, value_f);
370
368
  return Convert_UpbToRuby(value, TypeInfo_get(value_f), self->arena);
371
369
  } else {
@@ -377,8 +375,8 @@ static VALUE Message_field_accessor(VALUE _self, const upb_FieldDef* f,
377
375
  if (argv[1] == Qnil) {
378
376
  upb_Message_ClearField(msg, f);
379
377
  } else {
380
- const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumberWithSize(
381
- upb_FieldDef_MessageSubDef(f), 1);
378
+ const upb_FieldDef* val_f =
379
+ upb_MessageDef_FindFieldByNumber(upb_FieldDef_MessageSubDef(f), 1);
382
380
  upb_MessageValue msgval = Convert_RubyToUpb(
383
381
  argv[1], upb_FieldDef_Name(f), TypeInfo_get(val_f), arena);
384
382
  upb_Message* wrapper = upb_Message_Mutable(msg, f, arena).msg;
@@ -527,10 +525,8 @@ static int Map_initialize_kwarg(VALUE key, VALUE val, VALUE _self) {
527
525
  static void Map_InitFromValue(upb_Map* map, const upb_FieldDef* f, VALUE val,
528
526
  upb_Arena* arena) {
529
527
  const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(f);
530
- const upb_FieldDef* key_f =
531
- upb_MessageDef_FindFieldByNumberWithSize(entry_m, 1);
532
- const upb_FieldDef* val_f =
533
- upb_MessageDef_FindFieldByNumberWithSize(entry_m, 2);
528
+ const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry_m, 1);
529
+ const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry_m, 2);
534
530
  if (TYPE(val) != T_HASH) {
535
531
  rb_raise(rb_eArgError,
536
532
  "Expected Hash object as initializer value for map field '%s' "
@@ -748,7 +744,7 @@ uint64_t Message_Hash(const upb_Message* msg, const upb_MessageDef* m,
748
744
  &size);
749
745
 
750
746
  if (data) {
751
- uint64_t ret = Wyhash(data, size, seed, kWyhashSalt);
747
+ uint64_t ret = _upb_Hash(data, size, seed);
752
748
  upb_Arena_Free(arena);
753
749
  return ret;
754
750
  } else {
@@ -847,10 +843,8 @@ static VALUE Message_CreateHash(const upb_Message* msg,
847
843
 
848
844
  if (upb_FieldDef_IsMap(field)) {
849
845
  const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(field);
850
- const upb_FieldDef* key_f =
851
- upb_MessageDef_FindFieldByNumberWithSize(entry_m, 1);
852
- const upb_FieldDef* val_f =
853
- upb_MessageDef_FindFieldByNumberWithSize(entry_m, 2);
846
+ const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry_m, 1);
847
+ const upb_FieldDef* val_f = upb_MessageDef_FindFieldByNumber(entry_m, 2);
854
848
  upb_CType key_type = upb_FieldDef_CType(key_f);
855
849
  msg_value = Map_CreateHash(msgval.map_val, key_type, TypeInfo_get(val_f));
856
850
  } else if (upb_FieldDef_IsRepeated(field)) {
@@ -1141,7 +1135,11 @@ static VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
1141
1135
  if (argc == 2) {
1142
1136
  VALUE hash_args = argv[1];
1143
1137
  if (TYPE(hash_args) != T_HASH) {
1144
- rb_raise(rb_eArgError, "Expected hash arguments.");
1138
+ if (RTEST(rb_funcall(hash_args, rb_intern("respond_to?"), 1, rb_str_new2("to_h")))) {
1139
+ hash_args = rb_funcall(hash_args, rb_intern("to_h"), 0);
1140
+ } else {
1141
+ rb_raise(rb_eArgError, "Expected hash arguments.");
1142
+ }
1145
1143
  }
1146
1144
 
1147
1145
  if (RTEST(rb_hash_lookup2(hash_args,
@@ -1353,10 +1351,8 @@ const upb_Message* Message_GetUpbMessage(VALUE value, const upb_MessageDef* m,
1353
1351
  upb_Message* msg = upb_Message_New(m, arena);
1354
1352
  upb_MessageValue sec, nsec;
1355
1353
  struct timespec time;
1356
- const upb_FieldDef* sec_f =
1357
- upb_MessageDef_FindFieldByNumberWithSize(m, 1);
1358
- const upb_FieldDef* nsec_f =
1359
- upb_MessageDef_FindFieldByNumberWithSize(m, 2);
1354
+ const upb_FieldDef* sec_f = upb_MessageDef_FindFieldByNumber(m, 1);
1355
+ const upb_FieldDef* nsec_f = upb_MessageDef_FindFieldByNumber(m, 2);
1360
1356
 
1361
1357
  if (!rb_obj_is_kind_of(value, rb_cTime)) goto badtype;
1362
1358
 
@@ -1371,10 +1367,8 @@ const upb_Message* Message_GetUpbMessage(VALUE value, const upb_MessageDef* m,
1371
1367
  // Numeric -> Google::Protobuf::Duration
1372
1368
  upb_Message* msg = upb_Message_New(m, arena);
1373
1369
  upb_MessageValue sec, nsec;
1374
- const upb_FieldDef* sec_f =
1375
- upb_MessageDef_FindFieldByNumberWithSize(m, 1);
1376
- const upb_FieldDef* nsec_f =
1377
- upb_MessageDef_FindFieldByNumberWithSize(m, 2);
1370
+ const upb_FieldDef* sec_f = upb_MessageDef_FindFieldByNumber(m, 1);
1371
+ const upb_FieldDef* nsec_f = upb_MessageDef_FindFieldByNumber(m, 2);
1378
1372
 
1379
1373
  if (!rb_obj_is_kind_of(value, rb_cNumeric)) goto badtype;
1380
1374
 
@@ -42,12 +42,12 @@ VALUE cTypeError;
42
42
 
43
43
  const upb_FieldDef *map_field_key(const upb_FieldDef *field) {
44
44
  const upb_MessageDef *entry = upb_FieldDef_MessageSubDef(field);
45
- return upb_MessageDef_FindFieldByNumberWithSize(entry, 1);
45
+ return upb_MessageDef_FindFieldByNumber(entry, 1);
46
46
  }
47
47
 
48
48
  const upb_FieldDef *map_field_value(const upb_FieldDef *field) {
49
49
  const upb_MessageDef *entry = upb_FieldDef_MessageSubDef(field);
50
- return upb_MessageDef_FindFieldByNumberWithSize(entry, 2);
50
+ return upb_MessageDef_FindFieldByNumber(entry, 2);
51
51
  }
52
52
 
53
53
  // -----------------------------------------------------------------------------
@@ -193,9 +193,20 @@ const rb_data_type_t Arena_type = {
193
193
  .flags = RUBY_TYPED_FREE_IMMEDIATELY,
194
194
  };
195
195
 
196
+ static void* ruby_upb_allocfunc(upb_alloc* alloc, void* ptr, size_t oldsize, size_t size) {
197
+ if (size == 0) {
198
+ xfree(ptr);
199
+ return NULL;
200
+ } else {
201
+ return xrealloc(ptr, size);
202
+ }
203
+ }
204
+
205
+ upb_alloc ruby_upb_alloc = {&ruby_upb_allocfunc};
206
+
196
207
  static VALUE Arena_alloc(VALUE klass) {
197
208
  Arena *arena = ALLOC(Arena);
198
- arena->arena = upb_Arena_New();
209
+ arena->arena = upb_Arena_Init(NULL, 0, &ruby_upb_alloc);
199
210
  arena->pinned_objs = Qnil;
200
211
  return TypedData_Wrap_Struct(klass, &Arena_type, arena);
201
212
  }