google-protobuf 3.17.0 → 3.23.3

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.

Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/ext/google/protobuf_c/convert.c +128 -116
  3. data/ext/google/protobuf_c/convert.h +12 -9
  4. data/ext/google/protobuf_c/defs.c +235 -1529
  5. data/ext/google/protobuf_c/defs.h +19 -19
  6. data/ext/google/protobuf_c/extconf.rb +12 -6
  7. data/ext/google/protobuf_c/map.c +108 -110
  8. data/ext/google/protobuf_c/map.h +7 -7
  9. data/ext/google/protobuf_c/message.c +456 -343
  10. data/ext/google/protobuf_c/message.h +22 -19
  11. data/ext/google/protobuf_c/protobuf.c +78 -56
  12. data/ext/google/protobuf_c/protobuf.h +16 -9
  13. data/ext/google/protobuf_c/repeated_field.c +85 -85
  14. data/ext/google/protobuf_c/repeated_field.h +6 -5
  15. data/ext/google/protobuf_c/ruby-upb.c +11806 -6746
  16. data/ext/google/protobuf_c/ruby-upb.h +10860 -3532
  17. data/ext/google/protobuf_c/third_party/utf8_range/LICENSE +22 -0
  18. data/ext/google/protobuf_c/third_party/utf8_range/naive.c +92 -0
  19. data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +157 -0
  20. data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +170 -0
  21. data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +21 -0
  22. data/ext/google/protobuf_c/wrap_memcpy.c +4 -3
  23. data/lib/google/protobuf/any_pb.rb +24 -5
  24. data/lib/google/protobuf/api_pb.rb +27 -23
  25. data/lib/google/protobuf/descriptor_dsl.rb +465 -0
  26. data/lib/google/protobuf/descriptor_pb.rb +75 -0
  27. data/lib/google/protobuf/duration_pb.rb +24 -5
  28. data/lib/google/protobuf/empty_pb.rb +24 -3
  29. data/lib/google/protobuf/field_mask_pb.rb +24 -4
  30. data/lib/google/protobuf/message_exts.rb +7 -2
  31. data/lib/google/protobuf/plugin_pb.rb +47 -0
  32. data/lib/google/protobuf/repeated_field.rb +15 -2
  33. data/lib/google/protobuf/source_context_pb.rb +24 -4
  34. data/lib/google/protobuf/struct_pb.rb +24 -20
  35. data/lib/google/protobuf/timestamp_pb.rb +24 -5
  36. data/lib/google/protobuf/type_pb.rb +27 -68
  37. data/lib/google/protobuf/well_known_types.rb +12 -2
  38. data/lib/google/protobuf/wrappers_pb.rb +24 -28
  39. data/lib/google/protobuf.rb +5 -73
  40. metadata +17 -36
  41. data/ext/google/protobuf_c/third_party/wyhash/wyhash.h +0 -145
  42. data/tests/basic.rb +0 -604
  43. data/tests/generated_code_test.rb +0 -23
  44. data/tests/stress.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5131500da162694226d8492cbdc5c0b72720cef60a961271a5ce3f9c51b4697
4
- data.tar.gz: e26dfaa3b4ab33ed758e7d7e2dbd57e35941d03595b3f2ddb457b9dac52cf59d
3
+ metadata.gz: 50c81aca55482dbeb28e0b9def873a386d8ffa21c27486c524261a30df8afde1
4
+ data.tar.gz: 3dec5edc021d4b55d6728d84a34dd30bd85b4942fe3d23646f4538e963c0d1ac
5
5
  SHA512:
6
- metadata.gz: 85d8ac015b74431996035cadcfe1d3d66c2b13f0516c2486da7fe682ef75fd71d75b7b0961004b707b936ab76cbd079fee9868b2e7a9447852fe5ea7faf8e930
7
- data.tar.gz: 3c343fb3710530ebe8ee4c4d7d3b6adaf549c60ff53e821a1e9e2a3ce812e2e30dd7b2208da0e3b7d00cc720bc58e6667a9d8b0f122bb0a3d373de2c6bcaf169
6
+ metadata.gz: c0a787ca87a5cbdf434a4162aa3d25b83c1c741fe6388bc81c8ca525f15f20eb435c09b6c5d794922af9f00258872ec78093ae6702c14d53c0d8f2e22f24c07a
7
+ data.tar.gz: 1cfc4f0b25605d3c9314c63a98fb3720a00c0f9845b7f7010b4a4d4ec277ded8b0ea035d111e1e96b70ec01368bbb1d45828237dd18bac508d64b68f97ec063b
@@ -31,7 +31,7 @@
31
31
  // -----------------------------------------------------------------------------
32
32
  // Ruby <-> upb data conversion functions.
33
33
  //
34
- // This file Also contains a few other assorted algorithms on upb_msgval.
34
+ // This file Also contains a few other assorted algorithms on upb_MessageValue.
35
35
  //
36
36
  // None of the algorithms in this file require any access to the internal
37
37
  // representation of Ruby or upb objects.
@@ -41,12 +41,11 @@
41
41
 
42
42
  #include "message.h"
43
43
  #include "protobuf.h"
44
- #include "third_party/wyhash/wyhash.h"
45
44
 
46
- static upb_strview Convert_StringData(VALUE str, upb_arena *arena) {
47
- upb_strview ret;
45
+ static upb_StringView Convert_StringData(VALUE str, upb_Arena* arena) {
46
+ upb_StringView ret;
48
47
  if (arena) {
49
- char *ptr = upb_arena_malloc(arena, RSTRING_LEN(str));
48
+ char* ptr = upb_Arena_Malloc(arena, RSTRING_LEN(str));
50
49
  memcpy(ptr, RSTRING_PTR(str), RSTRING_LEN(str));
51
50
  ret.data = ptr;
52
51
  } else {
@@ -58,13 +57,11 @@ static upb_strview Convert_StringData(VALUE str, upb_arena *arena) {
58
57
  }
59
58
 
60
59
  static bool is_ruby_num(VALUE value) {
61
- return (TYPE(value) == T_FLOAT ||
62
- TYPE(value) == T_FIXNUM ||
60
+ return (TYPE(value) == T_FLOAT || TYPE(value) == T_FIXNUM ||
63
61
  TYPE(value) == T_BIGNUM);
64
62
  }
65
63
 
66
- static void Convert_CheckInt(const char* name, upb_fieldtype_t type,
67
- VALUE val) {
64
+ static void Convert_CheckInt(const char* name, upb_CType type, VALUE val) {
68
65
  if (!is_ruby_num(val)) {
69
66
  rb_raise(cTypeError,
70
67
  "Expected number type for integral field '%s' (given %s).", name,
@@ -83,7 +80,7 @@ static void Convert_CheckInt(const char* name, upb_fieldtype_t type,
83
80
  name, rb_class2name(CLASS_OF(val)));
84
81
  }
85
82
  }
86
- if (type == UPB_TYPE_UINT32 || type == UPB_TYPE_UINT64) {
83
+ if (type == kUpb_CType_UInt32 || type == kUpb_CType_UInt64) {
87
84
  if (NUM2DBL(val) < 0) {
88
85
  rb_raise(
89
86
  rb_eRangeError,
@@ -94,26 +91,31 @@ static void Convert_CheckInt(const char* name, upb_fieldtype_t type,
94
91
  }
95
92
 
96
93
  static int32_t Convert_ToEnum(VALUE value, const char* name,
97
- const upb_enumdef* e) {
94
+ const upb_EnumDef* e) {
98
95
  int32_t val;
99
96
 
100
97
  switch (TYPE(value)) {
101
98
  case T_FLOAT:
102
99
  case T_FIXNUM:
103
100
  case T_BIGNUM:
104
- Convert_CheckInt(name, UPB_TYPE_INT32, value);
101
+ Convert_CheckInt(name, kUpb_CType_Int32, value);
105
102
  val = NUM2INT(value);
106
103
  break;
107
- case T_STRING:
108
- if (!upb_enumdef_ntoi(e, RSTRING_PTR(value), RSTRING_LEN(value), &val)) {
109
- goto unknownval;
110
- }
104
+ case T_STRING: {
105
+ const upb_EnumValueDef* ev = upb_EnumDef_FindValueByNameWithSize(
106
+ e, RSTRING_PTR(value), RSTRING_LEN(value));
107
+ if (!ev) goto unknownval;
108
+ val = upb_EnumValueDef_Number(ev);
111
109
  break;
112
- case T_SYMBOL:
113
- if (!upb_enumdef_ntoiz(e, rb_id2name(SYM2ID(value)), &val)) {
110
+ }
111
+ case T_SYMBOL: {
112
+ const upb_EnumValueDef* ev =
113
+ upb_EnumDef_FindValueByName(e, rb_id2name(SYM2ID(value)));
114
+ if (!ev)
114
115
  goto unknownval;
115
- }
116
+ val = upb_EnumValueDef_Number(ev);
116
117
  break;
118
+ }
117
119
  default:
118
120
  rb_raise(cTypeError,
119
121
  "Expected number or symbol type for enum field '%s'.", name);
@@ -125,47 +127,52 @@ unknownval:
125
127
  rb_raise(rb_eRangeError, "Unknown symbol value for enum field '%s'.", name);
126
128
  }
127
129
 
128
- upb_msgval Convert_RubyToUpb(VALUE value, const char* name, TypeInfo type_info,
129
- upb_arena* arena) {
130
- upb_msgval ret;
130
+ upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
131
+ TypeInfo type_info, upb_Arena* arena) {
132
+ upb_MessageValue ret;
131
133
 
132
134
  switch (type_info.type) {
133
- case UPB_TYPE_FLOAT:
135
+ case kUpb_CType_Float:
134
136
  if (!is_ruby_num(value)) {
135
- rb_raise(cTypeError, "Expected number type for float field '%s' (given %s).",
136
- name, rb_class2name(CLASS_OF(value)));
137
+ rb_raise(cTypeError,
138
+ "Expected number type for float field '%s' (given %s).", name,
139
+ rb_class2name(CLASS_OF(value)));
137
140
  }
138
141
  ret.float_val = NUM2DBL(value);
139
142
  break;
140
- case UPB_TYPE_DOUBLE:
143
+ case kUpb_CType_Double:
141
144
  if (!is_ruby_num(value)) {
142
- rb_raise(cTypeError, "Expected number type for double field '%s' (given %s).",
143
- name, rb_class2name(CLASS_OF(value)));
145
+ rb_raise(cTypeError,
146
+ "Expected number type for double field '%s' (given %s).", name,
147
+ rb_class2name(CLASS_OF(value)));
144
148
  }
145
149
  ret.double_val = NUM2DBL(value);
146
150
  break;
147
- case UPB_TYPE_BOOL: {
151
+ case kUpb_CType_Bool: {
148
152
  if (value == Qtrue) {
149
153
  ret.bool_val = 1;
150
154
  } else if (value == Qfalse) {
151
155
  ret.bool_val = 0;
152
156
  } else {
153
- rb_raise(cTypeError, "Invalid argument for boolean field '%s' (given %s).",
154
- name, rb_class2name(CLASS_OF(value)));
157
+ rb_raise(cTypeError,
158
+ "Invalid argument for boolean field '%s' (given %s).", name,
159
+ rb_class2name(CLASS_OF(value)));
155
160
  }
156
161
  break;
157
162
  }
158
- case UPB_TYPE_STRING: {
163
+ case kUpb_CType_String: {
159
164
  VALUE utf8 = rb_enc_from_encoding(rb_utf8_encoding());
160
- if (CLASS_OF(value) == rb_cSymbol) {
165
+ if (rb_obj_class(value) == rb_cSymbol) {
161
166
  value = rb_funcall(value, rb_intern("to_s"), 0);
162
- } else if (CLASS_OF(value) != rb_cString) {
163
- rb_raise(cTypeError, "Invalid argument for string field '%s' (given %s).",
164
- name, rb_class2name(CLASS_OF(value)));
167
+ } else if (rb_obj_class(value) != rb_cString) {
168
+ rb_raise(cTypeError,
169
+ "Invalid argument for string field '%s' (given %s).", name,
170
+ rb_class2name(CLASS_OF(value)));
165
171
  }
166
172
 
167
173
  if (rb_obj_encoding(value) != utf8) {
168
- // Note: this will not duplicate underlying string data unless necessary.
174
+ // Note: this will not duplicate underlying string data unless
175
+ // necessary.
169
176
  value = rb_str_encode(value, utf8, 0, Qnil);
170
177
 
171
178
  if (rb_enc_str_coderange(value) == ENC_CODERANGE_BROKEN) {
@@ -176,15 +183,17 @@ upb_msgval Convert_RubyToUpb(VALUE value, const char* name, TypeInfo type_info,
176
183
  ret.str_val = Convert_StringData(value, arena);
177
184
  break;
178
185
  }
179
- case UPB_TYPE_BYTES: {
186
+ case kUpb_CType_Bytes: {
180
187
  VALUE bytes = rb_enc_from_encoding(rb_ascii8bit_encoding());
181
- if (CLASS_OF(value) != rb_cString) {
182
- rb_raise(cTypeError, "Invalid argument for bytes field '%s' (given %s).",
183
- name, rb_class2name(CLASS_OF(value)));
188
+ if (rb_obj_class(value) != rb_cString) {
189
+ rb_raise(cTypeError,
190
+ "Invalid argument for bytes field '%s' (given %s).", name,
191
+ rb_class2name(CLASS_OF(value)));
184
192
  }
185
193
 
186
194
  if (rb_obj_encoding(value) != bytes) {
187
- // Note: this will not duplicate underlying string data unless necessary.
195
+ // Note: this will not duplicate underlying string data unless
196
+ // necessary.
188
197
  // TODO(haberman): is this really necessary to get raw bytes?
189
198
  value = rb_str_encode(value, bytes, 0, Qnil);
190
199
  }
@@ -192,33 +201,33 @@ upb_msgval Convert_RubyToUpb(VALUE value, const char* name, TypeInfo type_info,
192
201
  ret.str_val = Convert_StringData(value, arena);
193
202
  break;
194
203
  }
195
- case UPB_TYPE_MESSAGE:
204
+ case kUpb_CType_Message:
196
205
  ret.msg_val =
197
206
  Message_GetUpbMessage(value, type_info.def.msgdef, name, arena);
198
207
  break;
199
- case UPB_TYPE_ENUM:
208
+ case kUpb_CType_Enum:
200
209
  ret.int32_val = Convert_ToEnum(value, name, type_info.def.enumdef);
201
210
  break;
202
- case UPB_TYPE_INT32:
203
- case UPB_TYPE_INT64:
204
- case UPB_TYPE_UINT32:
205
- case UPB_TYPE_UINT64:
211
+ case kUpb_CType_Int32:
212
+ case kUpb_CType_Int64:
213
+ case kUpb_CType_UInt32:
214
+ case kUpb_CType_UInt64:
206
215
  Convert_CheckInt(name, type_info.type, value);
207
216
  switch (type_info.type) {
208
- case UPB_TYPE_INT32:
209
- ret.int32_val = NUM2INT(value);
210
- break;
211
- case UPB_TYPE_INT64:
212
- ret.int64_val = NUM2LL(value);
213
- break;
214
- case UPB_TYPE_UINT32:
215
- ret.uint32_val = NUM2UINT(value);
216
- break;
217
- case UPB_TYPE_UINT64:
218
- ret.uint64_val = NUM2ULL(value);
219
- break;
220
- default:
221
- break;
217
+ case kUpb_CType_Int32:
218
+ ret.int32_val = NUM2INT(value);
219
+ break;
220
+ case kUpb_CType_Int64:
221
+ ret.int64_val = NUM2LL(value);
222
+ break;
223
+ case kUpb_CType_UInt32:
224
+ ret.uint32_val = NUM2UINT(value);
225
+ break;
226
+ case kUpb_CType_UInt64:
227
+ ret.uint64_val = NUM2ULL(value);
228
+ break;
229
+ default:
230
+ break;
222
231
  }
223
232
  break;
224
233
  default:
@@ -228,45 +237,46 @@ upb_msgval Convert_RubyToUpb(VALUE value, const char* name, TypeInfo type_info,
228
237
  return ret;
229
238
  }
230
239
 
231
- VALUE Convert_UpbToRuby(upb_msgval upb_val, TypeInfo type_info, VALUE arena) {
240
+ VALUE Convert_UpbToRuby(upb_MessageValue upb_val, TypeInfo type_info,
241
+ VALUE arena) {
232
242
  switch (type_info.type) {
233
- case UPB_TYPE_FLOAT:
243
+ case kUpb_CType_Float:
234
244
  return DBL2NUM(upb_val.float_val);
235
- case UPB_TYPE_DOUBLE:
245
+ case kUpb_CType_Double:
236
246
  return DBL2NUM(upb_val.double_val);
237
- case UPB_TYPE_BOOL:
247
+ case kUpb_CType_Bool:
238
248
  return upb_val.bool_val ? Qtrue : Qfalse;
239
- case UPB_TYPE_INT32:
249
+ case kUpb_CType_Int32:
240
250
  return INT2NUM(upb_val.int32_val);
241
- case UPB_TYPE_INT64:
251
+ case kUpb_CType_Int64:
242
252
  return LL2NUM(upb_val.int64_val);
243
- case UPB_TYPE_UINT32:
253
+ case kUpb_CType_UInt32:
244
254
  return UINT2NUM(upb_val.uint32_val);
245
- case UPB_TYPE_UINT64:
255
+ case kUpb_CType_UInt64:
246
256
  return ULL2NUM(upb_val.int64_val);
247
- case UPB_TYPE_ENUM: {
248
- const char* name =
249
- upb_enumdef_iton(type_info.def.enumdef, upb_val.int32_val);
250
- if (name) {
251
- return ID2SYM(rb_intern(name));
257
+ case kUpb_CType_Enum: {
258
+ const upb_EnumValueDef *ev = upb_EnumDef_FindValueByNumber(
259
+ type_info.def.enumdef, upb_val.int32_val);
260
+ if (ev) {
261
+ return ID2SYM(rb_intern(upb_EnumValueDef_Name(ev)));
252
262
  } else {
253
263
  return INT2NUM(upb_val.int32_val);
254
264
  }
255
265
  }
256
- case UPB_TYPE_STRING: {
266
+ case kUpb_CType_String: {
257
267
  VALUE str_rb = rb_str_new(upb_val.str_val.data, upb_val.str_val.size);
258
268
  rb_enc_associate(str_rb, rb_utf8_encoding());
259
269
  rb_obj_freeze(str_rb);
260
270
  return str_rb;
261
271
  }
262
- case UPB_TYPE_BYTES: {
272
+ case kUpb_CType_Bytes: {
263
273
  VALUE str_rb = rb_str_new(upb_val.str_val.data, upb_val.str_val.size);
264
274
  rb_enc_associate(str_rb, rb_ascii8bit_encoding());
265
275
  rb_obj_freeze(str_rb);
266
276
  return str_rb;
267
277
  }
268
- case UPB_TYPE_MESSAGE:
269
- return Message_GetRubyWrapper((upb_msg*)upb_val.msg_val,
278
+ case kUpb_CType_Message:
279
+ return Message_GetRubyWrapper((upb_Message*)upb_val.msg_val,
270
280
  type_info.def.msgdef, arena);
271
281
  default:
272
282
  rb_raise(rb_eRuntimeError, "Convert_UpbToRuby(): Unexpected type %d",
@@ -274,24 +284,24 @@ VALUE Convert_UpbToRuby(upb_msgval upb_val, TypeInfo type_info, VALUE arena) {
274
284
  }
275
285
  }
276
286
 
277
- upb_msgval Msgval_DeepCopy(upb_msgval msgval, TypeInfo type_info,
278
- upb_arena* arena) {
279
- upb_msgval new_msgval;
287
+ upb_MessageValue Msgval_DeepCopy(upb_MessageValue msgval, TypeInfo type_info,
288
+ upb_Arena* arena) {
289
+ upb_MessageValue new_msgval;
280
290
 
281
291
  switch (type_info.type) {
282
292
  default:
283
293
  memcpy(&new_msgval, &msgval, sizeof(msgval));
284
294
  break;
285
- case UPB_TYPE_STRING:
286
- case UPB_TYPE_BYTES: {
295
+ case kUpb_CType_String:
296
+ case kUpb_CType_Bytes: {
287
297
  size_t n = msgval.str_val.size;
288
- char *mem = upb_arena_malloc(arena, n);
298
+ char* mem = upb_Arena_Malloc(arena, n);
289
299
  new_msgval.str_val.data = mem;
290
300
  new_msgval.str_val.size = n;
291
301
  memcpy(mem, msgval.str_val.data, n);
292
302
  break;
293
303
  }
294
- case UPB_TYPE_MESSAGE:
304
+ case kUpb_CType_Message:
295
305
  new_msgval.msg_val =
296
306
  Message_deep_copy(msgval.msg_val, type_info.def.msgdef, arena);
297
307
  break;
@@ -300,48 +310,50 @@ upb_msgval Msgval_DeepCopy(upb_msgval msgval, TypeInfo type_info,
300
310
  return new_msgval;
301
311
  }
302
312
 
303
- bool Msgval_IsEqual(upb_msgval val1, upb_msgval val2, TypeInfo type_info) {
313
+ bool Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2,
314
+ TypeInfo type_info) {
304
315
  switch (type_info.type) {
305
- case UPB_TYPE_BOOL:
316
+ case kUpb_CType_Bool:
306
317
  return memcmp(&val1, &val2, 1) == 0;
307
- case UPB_TYPE_FLOAT:
308
- case UPB_TYPE_INT32:
309
- case UPB_TYPE_UINT32:
310
- case UPB_TYPE_ENUM:
318
+ case kUpb_CType_Float:
319
+ case kUpb_CType_Int32:
320
+ case kUpb_CType_UInt32:
321
+ case kUpb_CType_Enum:
311
322
  return memcmp(&val1, &val2, 4) == 0;
312
- case UPB_TYPE_DOUBLE:
313
- case UPB_TYPE_INT64:
314
- case UPB_TYPE_UINT64:
323
+ case kUpb_CType_Double:
324
+ case kUpb_CType_Int64:
325
+ case kUpb_CType_UInt64:
315
326
  return memcmp(&val1, &val2, 8) == 0;
316
- case UPB_TYPE_STRING:
317
- case UPB_TYPE_BYTES:
327
+ case kUpb_CType_String:
328
+ case kUpb_CType_Bytes:
318
329
  return val1.str_val.size == val2.str_val.size &&
319
- memcmp(val1.str_val.data, val2.str_val.data,
320
- val1.str_val.size) == 0;
321
- case UPB_TYPE_MESSAGE:
330
+ memcmp(val1.str_val.data, val2.str_val.data, val1.str_val.size) ==
331
+ 0;
332
+ case kUpb_CType_Message:
322
333
  return Message_Equal(val1.msg_val, val2.msg_val, type_info.def.msgdef);
323
334
  default:
324
335
  rb_raise(rb_eRuntimeError, "Internal error, unexpected type");
325
336
  }
326
337
  }
327
338
 
328
- uint64_t Msgval_GetHash(upb_msgval val, TypeInfo type_info, uint64_t seed) {
339
+ uint64_t Msgval_GetHash(upb_MessageValue val, TypeInfo type_info,
340
+ uint64_t seed) {
329
341
  switch (type_info.type) {
330
- case UPB_TYPE_BOOL:
331
- return wyhash(&val, 1, seed, _wyp);
332
- case UPB_TYPE_FLOAT:
333
- case UPB_TYPE_INT32:
334
- case UPB_TYPE_UINT32:
335
- case UPB_TYPE_ENUM:
336
- return wyhash(&val, 4, seed, _wyp);
337
- case UPB_TYPE_DOUBLE:
338
- case UPB_TYPE_INT64:
339
- case UPB_TYPE_UINT64:
340
- return wyhash(&val, 8, seed, _wyp);
341
- case UPB_TYPE_STRING:
342
- case UPB_TYPE_BYTES:
343
- return wyhash(val.str_val.data, val.str_val.size, seed, _wyp);
344
- case UPB_TYPE_MESSAGE:
342
+ case kUpb_CType_Bool:
343
+ return _upb_Hash(&val, 1, seed);
344
+ case kUpb_CType_Float:
345
+ case kUpb_CType_Int32:
346
+ case kUpb_CType_UInt32:
347
+ case kUpb_CType_Enum:
348
+ return _upb_Hash(&val, 4, seed);
349
+ case kUpb_CType_Double:
350
+ case kUpb_CType_Int64:
351
+ case kUpb_CType_UInt64:
352
+ return _upb_Hash(&val, 8, seed);
353
+ case kUpb_CType_String:
354
+ case kUpb_CType_Bytes:
355
+ return _upb_Hash(val.str_val.data, val.str_val.size, seed);
356
+ case kUpb_CType_Message:
345
357
  return Message_Hash(val.msg_val, type_info.def.msgdef, seed);
346
358
  default:
347
359
  rb_raise(rb_eRuntimeError, "Internal error, unexpected type");
@@ -36,7 +36,7 @@
36
36
  #include "protobuf.h"
37
37
  #include "ruby-upb.h"
38
38
 
39
- // Converts |ruby_val| to a upb_msgval according to |type_info|.
39
+ // Converts |ruby_val| to a upb_MessageValue according to |type_info|.
40
40
  //
41
41
  // The |arena| parameter indicates the lifetime of the container where this
42
42
  // value will be assigned. It is used as follows:
@@ -47,8 +47,8 @@
47
47
  // - If type is message and the Ruby value is a message instance, we will fuse
48
48
  // the message's arena into |arena|, to ensure that this message outlives the
49
49
  // container.
50
- upb_msgval Convert_RubyToUpb(VALUE ruby_val, const char *name,
51
- TypeInfo type_info, upb_arena *arena);
50
+ upb_MessageValue Convert_RubyToUpb(VALUE ruby_val, const char *name,
51
+ TypeInfo type_info, upb_Arena *arena);
52
52
 
53
53
  // Converts |upb_val| to a Ruby VALUE according to |type_info|. This may involve
54
54
  // creating a Ruby wrapper object.
@@ -56,17 +56,20 @@ upb_msgval Convert_RubyToUpb(VALUE ruby_val, const char *name,
56
56
  // The |arena| parameter indicates the arena that owns the lifetime of
57
57
  // |upb_val|. Any Ruby wrapper object that is created will reference |arena|
58
58
  // and ensure it outlives the wrapper.
59
- VALUE Convert_UpbToRuby(upb_msgval upb_val, TypeInfo type_info, VALUE arena);
59
+ VALUE Convert_UpbToRuby(upb_MessageValue upb_val, TypeInfo type_info,
60
+ VALUE arena);
60
61
 
61
62
  // Creates a deep copy of |msgval| in |arena|.
62
- upb_msgval Msgval_DeepCopy(upb_msgval msgval, TypeInfo type_info,
63
- upb_arena *arena);
63
+ upb_MessageValue Msgval_DeepCopy(upb_MessageValue msgval, TypeInfo type_info,
64
+ upb_Arena *arena);
64
65
 
65
66
  // Returns true if |val1| and |val2| are equal. Their type is given by
66
67
  // |type_info|.
67
- bool Msgval_IsEqual(upb_msgval val1, upb_msgval val2, TypeInfo type_info);
68
+ bool Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2,
69
+ TypeInfo type_info);
68
70
 
69
- // Returns a hash value for the given upb_msgval.
70
- uint64_t Msgval_GetHash(upb_msgval val, TypeInfo type_info, uint64_t seed);
71
+ // Returns a hash value for the given upb_MessageValue.
72
+ uint64_t Msgval_GetHash(upb_MessageValue val, TypeInfo type_info,
73
+ uint64_t seed);
71
74
 
72
75
  #endif // RUBY_PROTOBUF_CONVERT_H_