google-protobuf 3.17.0 → 3.23.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of google-protobuf might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/convert.c +128 -116
- data/ext/google/protobuf_c/convert.h +12 -9
- data/ext/google/protobuf_c/defs.c +235 -1529
- data/ext/google/protobuf_c/defs.h +19 -19
- data/ext/google/protobuf_c/extconf.rb +12 -6
- data/ext/google/protobuf_c/map.c +108 -110
- data/ext/google/protobuf_c/map.h +7 -7
- data/ext/google/protobuf_c/message.c +456 -343
- data/ext/google/protobuf_c/message.h +22 -19
- data/ext/google/protobuf_c/protobuf.c +78 -56
- data/ext/google/protobuf_c/protobuf.h +16 -9
- data/ext/google/protobuf_c/repeated_field.c +85 -85
- data/ext/google/protobuf_c/repeated_field.h +6 -5
- data/ext/google/protobuf_c/ruby-upb.c +11806 -6746
- data/ext/google/protobuf_c/ruby-upb.h +10860 -3532
- data/ext/google/protobuf_c/third_party/utf8_range/LICENSE +22 -0
- data/ext/google/protobuf_c/third_party/utf8_range/naive.c +92 -0
- data/ext/google/protobuf_c/third_party/utf8_range/range2-neon.c +157 -0
- data/ext/google/protobuf_c/third_party/utf8_range/range2-sse.c +170 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +21 -0
- data/ext/google/protobuf_c/wrap_memcpy.c +4 -3
- data/lib/google/protobuf/any_pb.rb +24 -5
- data/lib/google/protobuf/api_pb.rb +27 -23
- data/lib/google/protobuf/descriptor_dsl.rb +465 -0
- data/lib/google/protobuf/descriptor_pb.rb +75 -0
- data/lib/google/protobuf/duration_pb.rb +24 -5
- data/lib/google/protobuf/empty_pb.rb +24 -3
- data/lib/google/protobuf/field_mask_pb.rb +24 -4
- data/lib/google/protobuf/message_exts.rb +7 -2
- data/lib/google/protobuf/plugin_pb.rb +47 -0
- data/lib/google/protobuf/repeated_field.rb +15 -2
- data/lib/google/protobuf/source_context_pb.rb +24 -4
- data/lib/google/protobuf/struct_pb.rb +24 -20
- data/lib/google/protobuf/timestamp_pb.rb +24 -5
- data/lib/google/protobuf/type_pb.rb +27 -68
- data/lib/google/protobuf/well_known_types.rb +12 -2
- data/lib/google/protobuf/wrappers_pb.rb +24 -28
- data/lib/google/protobuf.rb +5 -73
- metadata +17 -36
- data/ext/google/protobuf_c/third_party/wyhash/wyhash.h +0 -145
- data/tests/basic.rb +0 -604
- data/tests/generated_code_test.rb +0 -23
- data/tests/stress.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50c81aca55482dbeb28e0b9def873a386d8ffa21c27486c524261a30df8afde1
|
4
|
+
data.tar.gz: 3dec5edc021d4b55d6728d84a34dd30bd85b4942fe3d23646f4538e963c0d1ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
47
|
-
|
45
|
+
static upb_StringView Convert_StringData(VALUE str, upb_Arena* arena) {
|
46
|
+
upb_StringView ret;
|
48
47
|
if (arena) {
|
49
|
-
char
|
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,
|
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 ==
|
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
|
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,
|
101
|
+
Convert_CheckInt(name, kUpb_CType_Int32, value);
|
105
102
|
val = NUM2INT(value);
|
106
103
|
break;
|
107
|
-
case T_STRING:
|
108
|
-
|
109
|
-
|
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
|
-
|
113
|
-
|
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
|
-
|
129
|
-
|
130
|
-
|
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
|
135
|
+
case kUpb_CType_Float:
|
134
136
|
if (!is_ruby_num(value)) {
|
135
|
-
rb_raise(cTypeError,
|
136
|
-
|
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
|
143
|
+
case kUpb_CType_Double:
|
141
144
|
if (!is_ruby_num(value)) {
|
142
|
-
rb_raise(cTypeError,
|
143
|
-
|
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
|
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,
|
154
|
-
|
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
|
163
|
+
case kUpb_CType_String: {
|
159
164
|
VALUE utf8 = rb_enc_from_encoding(rb_utf8_encoding());
|
160
|
-
if (
|
165
|
+
if (rb_obj_class(value) == rb_cSymbol) {
|
161
166
|
value = rb_funcall(value, rb_intern("to_s"), 0);
|
162
|
-
} else if (
|
163
|
-
rb_raise(cTypeError,
|
164
|
-
|
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
|
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
|
186
|
+
case kUpb_CType_Bytes: {
|
180
187
|
VALUE bytes = rb_enc_from_encoding(rb_ascii8bit_encoding());
|
181
|
-
if (
|
182
|
-
rb_raise(cTypeError,
|
183
|
-
|
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
|
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
|
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
|
208
|
+
case kUpb_CType_Enum:
|
200
209
|
ret.int32_val = Convert_ToEnum(value, name, type_info.def.enumdef);
|
201
210
|
break;
|
202
|
-
case
|
203
|
-
case
|
204
|
-
case
|
205
|
-
case
|
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
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
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(
|
240
|
+
VALUE Convert_UpbToRuby(upb_MessageValue upb_val, TypeInfo type_info,
|
241
|
+
VALUE arena) {
|
232
242
|
switch (type_info.type) {
|
233
|
-
case
|
243
|
+
case kUpb_CType_Float:
|
234
244
|
return DBL2NUM(upb_val.float_val);
|
235
|
-
case
|
245
|
+
case kUpb_CType_Double:
|
236
246
|
return DBL2NUM(upb_val.double_val);
|
237
|
-
case
|
247
|
+
case kUpb_CType_Bool:
|
238
248
|
return upb_val.bool_val ? Qtrue : Qfalse;
|
239
|
-
case
|
249
|
+
case kUpb_CType_Int32:
|
240
250
|
return INT2NUM(upb_val.int32_val);
|
241
|
-
case
|
251
|
+
case kUpb_CType_Int64:
|
242
252
|
return LL2NUM(upb_val.int64_val);
|
243
|
-
case
|
253
|
+
case kUpb_CType_UInt32:
|
244
254
|
return UINT2NUM(upb_val.uint32_val);
|
245
|
-
case
|
255
|
+
case kUpb_CType_UInt64:
|
246
256
|
return ULL2NUM(upb_val.int64_val);
|
247
|
-
case
|
248
|
-
const
|
249
|
-
|
250
|
-
if (
|
251
|
-
return ID2SYM(rb_intern(
|
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
|
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
|
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
|
269
|
-
return Message_GetRubyWrapper((
|
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
|
-
|
278
|
-
|
279
|
-
|
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
|
286
|
-
case
|
295
|
+
case kUpb_CType_String:
|
296
|
+
case kUpb_CType_Bytes: {
|
287
297
|
size_t n = msgval.str_val.size;
|
288
|
-
char
|
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
|
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(
|
313
|
+
bool Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2,
|
314
|
+
TypeInfo type_info) {
|
304
315
|
switch (type_info.type) {
|
305
|
-
case
|
316
|
+
case kUpb_CType_Bool:
|
306
317
|
return memcmp(&val1, &val2, 1) == 0;
|
307
|
-
case
|
308
|
-
case
|
309
|
-
case
|
310
|
-
case
|
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
|
313
|
-
case
|
314
|
-
case
|
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
|
317
|
-
case
|
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
|
-
|
321
|
-
case
|
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(
|
339
|
+
uint64_t Msgval_GetHash(upb_MessageValue val, TypeInfo type_info,
|
340
|
+
uint64_t seed) {
|
329
341
|
switch (type_info.type) {
|
330
|
-
case
|
331
|
-
return
|
332
|
-
case
|
333
|
-
case
|
334
|
-
case
|
335
|
-
case
|
336
|
-
return
|
337
|
-
case
|
338
|
-
case
|
339
|
-
case
|
340
|
-
return
|
341
|
-
case
|
342
|
-
case
|
343
|
-
return
|
344
|
-
case
|
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
|
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
|
-
|
51
|
-
|
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(
|
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
|
-
|
63
|
-
|
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(
|
68
|
+
bool Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2,
|
69
|
+
TypeInfo type_info);
|
68
70
|
|
69
|
-
// Returns a hash value for the given
|
70
|
-
uint64_t Msgval_GetHash(
|
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_
|