google-protobuf 4.31.0.rc.1-x86-linux-musl
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.
- checksums.yaml +7 -0
- data/ext/google/protobuf_c/Rakefile +3 -0
- data/ext/google/protobuf_c/convert.c +335 -0
- data/ext/google/protobuf_c/convert.h +50 -0
- data/ext/google/protobuf_c/defs.c +1932 -0
- data/ext/google/protobuf_c/defs.h +82 -0
- data/ext/google/protobuf_c/extconf.rb +44 -0
- data/ext/google/protobuf_c/glue.c +135 -0
- data/ext/google/protobuf_c/map.c +731 -0
- data/ext/google/protobuf_c/map.h +48 -0
- data/ext/google/protobuf_c/message.c +1426 -0
- data/ext/google/protobuf_c/message.h +82 -0
- data/ext/google/protobuf_c/protobuf.c +357 -0
- data/ext/google/protobuf_c/protobuf.h +102 -0
- data/ext/google/protobuf_c/repeated_field.c +691 -0
- data/ext/google/protobuf_c/repeated_field.h +45 -0
- data/ext/google/protobuf_c/ruby-upb.c +18305 -0
- data/ext/google/protobuf_c/ruby-upb.h +16315 -0
- data/ext/google/protobuf_c/shared_convert.c +69 -0
- data/ext/google/protobuf_c/shared_convert.h +26 -0
- data/ext/google/protobuf_c/shared_message.c +37 -0
- data/ext/google/protobuf_c/shared_message.h +21 -0
- data/ext/google/protobuf_c/third_party/utf8_range/LICENSE +22 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.c +207 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range.h +22 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range_neon.inc +117 -0
- data/ext/google/protobuf_c/third_party/utf8_range/utf8_range_sse.inc +272 -0
- data/ext/google/protobuf_c/wrap_memcpy.c +29 -0
- data/lib/google/3.1/protobuf_c.so +0 -0
- data/lib/google/3.2/protobuf_c.so +0 -0
- data/lib/google/3.3/protobuf_c.so +0 -0
- data/lib/google/3.4/protobuf_c.so +0 -0
- data/lib/google/protobuf/any_pb.rb +17 -0
- data/lib/google/protobuf/api_pb.rb +22 -0
- data/lib/google/protobuf/descriptor_pb.rb +70 -0
- data/lib/google/protobuf/duration_pb.rb +17 -0
- data/lib/google/protobuf/empty_pb.rb +17 -0
- data/lib/google/protobuf/ffi/descriptor.rb +175 -0
- data/lib/google/protobuf/ffi/descriptor_pool.rb +79 -0
- data/lib/google/protobuf/ffi/enum_descriptor.rb +183 -0
- data/lib/google/protobuf/ffi/ffi.rb +214 -0
- data/lib/google/protobuf/ffi/field_descriptor.rb +346 -0
- data/lib/google/protobuf/ffi/file_descriptor.rb +85 -0
- data/lib/google/protobuf/ffi/internal/arena.rb +60 -0
- data/lib/google/protobuf/ffi/internal/convert.rb +292 -0
- data/lib/google/protobuf/ffi/internal/pointer_helper.rb +36 -0
- data/lib/google/protobuf/ffi/internal/type_safety.rb +25 -0
- data/lib/google/protobuf/ffi/map.rb +433 -0
- data/lib/google/protobuf/ffi/message.rb +783 -0
- data/lib/google/protobuf/ffi/method_descriptor.rb +124 -0
- data/lib/google/protobuf/ffi/object_cache.rb +30 -0
- data/lib/google/protobuf/ffi/oneof_descriptor.rb +107 -0
- data/lib/google/protobuf/ffi/repeated_field.rb +411 -0
- data/lib/google/protobuf/ffi/service_descriptor.rb +117 -0
- data/lib/google/protobuf/field_mask_pb.rb +17 -0
- data/lib/google/protobuf/internal/object_cache.rb +99 -0
- data/lib/google/protobuf/message_exts.rb +39 -0
- data/lib/google/protobuf/plugin_pb.rb +25 -0
- data/lib/google/protobuf/repeated_field.rb +177 -0
- data/lib/google/protobuf/source_context_pb.rb +17 -0
- data/lib/google/protobuf/struct_pb.rb +20 -0
- data/lib/google/protobuf/timestamp_pb.rb +17 -0
- data/lib/google/protobuf/type_pb.rb +27 -0
- data/lib/google/protobuf/well_known_types.rb +211 -0
- data/lib/google/protobuf/wrappers_pb.rb +25 -0
- data/lib/google/protobuf.rb +61 -0
- data/lib/google/protobuf_ffi.rb +52 -0
- data/lib/google/protobuf_native.rb +19 -0
- data/lib/google/tasks/ffi.rake +100 -0
- metadata +215 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 86fb3a12cf2f5f959c423d633fb1cbdf0ed30ce90b50545bf2d3fd3b2bb2118a
|
4
|
+
data.tar.gz: fea3428e2417b5eb3ccfcd7cd6783a70c81fb613a609a87d153a82cc43158846
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9137a3f8e9d67848ac8c6f46dd8e3dee9dac399ad14fc57f1e1c6b178f14e4e529792a8646a35c272c91e4cc393f817344603caa8d085ac7cf9727d3cadb8908
|
7
|
+
data.tar.gz: a98f606131ca66835876433f9232a018a70550c9596ef955e7fe4c8424c174f585f62068da7e90c6c883cdb3bda1f2019d45311a2696f32598c498e1701eb3aa
|
@@ -0,0 +1,335 @@
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
2
|
+
// Copyright 2008 Google Inc. All rights reserved.
|
3
|
+
//
|
4
|
+
// Use of this source code is governed by a BSD-style
|
5
|
+
// license that can be found in the LICENSE file or at
|
6
|
+
// https://developers.google.com/open-source/licenses/bsd
|
7
|
+
|
8
|
+
// -----------------------------------------------------------------------------
|
9
|
+
// Ruby <-> upb data conversion functions.
|
10
|
+
//
|
11
|
+
// This file Also contains a few other assorted algorithms on upb_MessageValue.
|
12
|
+
//
|
13
|
+
// None of the algorithms in this file require any access to the internal
|
14
|
+
// representation of Ruby or upb objects.
|
15
|
+
// -----------------------------------------------------------------------------
|
16
|
+
|
17
|
+
#include "convert.h"
|
18
|
+
|
19
|
+
#include "message.h"
|
20
|
+
#include "protobuf.h"
|
21
|
+
#include "shared_convert.h"
|
22
|
+
|
23
|
+
static upb_StringView Convert_StringData(VALUE str, upb_Arena* arena) {
|
24
|
+
upb_StringView ret;
|
25
|
+
if (arena) {
|
26
|
+
char* ptr = upb_Arena_Malloc(arena, RSTRING_LEN(str));
|
27
|
+
memcpy(ptr, RSTRING_PTR(str), RSTRING_LEN(str));
|
28
|
+
ret.data = ptr;
|
29
|
+
} else {
|
30
|
+
// Data is only needed temporarily (within map lookup).
|
31
|
+
ret.data = RSTRING_PTR(str);
|
32
|
+
}
|
33
|
+
ret.size = RSTRING_LEN(str);
|
34
|
+
return ret;
|
35
|
+
}
|
36
|
+
|
37
|
+
static bool is_ruby_num(VALUE value) {
|
38
|
+
return (TYPE(value) == T_FLOAT || TYPE(value) == T_FIXNUM ||
|
39
|
+
TYPE(value) == T_BIGNUM);
|
40
|
+
}
|
41
|
+
|
42
|
+
static void Convert_CheckInt(const char* name, upb_CType type, VALUE val) {
|
43
|
+
if (!is_ruby_num(val)) {
|
44
|
+
rb_raise(cTypeError,
|
45
|
+
"Expected number type for integral field '%s' (given %s).", name,
|
46
|
+
rb_class2name(CLASS_OF(val)));
|
47
|
+
}
|
48
|
+
|
49
|
+
// NUM2{INT,UINT,LL,ULL} macros do the appropriate range checks on upper
|
50
|
+
// bound; we just need to do precision checks (i.e., disallow rounding) and
|
51
|
+
// check for < 0 on unsigned types.
|
52
|
+
if (TYPE(val) == T_FLOAT) {
|
53
|
+
double dbl_val = NUM2DBL(val);
|
54
|
+
if (floor(dbl_val) != dbl_val) {
|
55
|
+
rb_raise(rb_eRangeError,
|
56
|
+
"Non-integral floating point value assigned to integer field "
|
57
|
+
"'%s' (given %s).",
|
58
|
+
name, rb_class2name(CLASS_OF(val)));
|
59
|
+
}
|
60
|
+
}
|
61
|
+
if (type == kUpb_CType_UInt32 || type == kUpb_CType_UInt64) {
|
62
|
+
if (NUM2DBL(val) < 0) {
|
63
|
+
rb_raise(
|
64
|
+
rb_eRangeError,
|
65
|
+
"Assigning negative value to unsigned integer field '%s' (given %s).",
|
66
|
+
name, rb_class2name(CLASS_OF(val)));
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
static int32_t Convert_ToEnum(VALUE value, const char* name,
|
72
|
+
const upb_EnumDef* e) {
|
73
|
+
int32_t val;
|
74
|
+
|
75
|
+
switch (TYPE(value)) {
|
76
|
+
case T_FLOAT:
|
77
|
+
case T_FIXNUM:
|
78
|
+
case T_BIGNUM:
|
79
|
+
Convert_CheckInt(name, kUpb_CType_Int32, value);
|
80
|
+
val = NUM2INT(value);
|
81
|
+
break;
|
82
|
+
case T_STRING: {
|
83
|
+
const upb_EnumValueDef* ev = upb_EnumDef_FindValueByNameWithSize(
|
84
|
+
e, RSTRING_PTR(value), RSTRING_LEN(value));
|
85
|
+
if (!ev) goto unknownval;
|
86
|
+
val = upb_EnumValueDef_Number(ev);
|
87
|
+
break;
|
88
|
+
}
|
89
|
+
case T_SYMBOL: {
|
90
|
+
const upb_EnumValueDef* ev =
|
91
|
+
upb_EnumDef_FindValueByName(e, rb_id2name(SYM2ID(value)));
|
92
|
+
if (!ev) goto unknownval;
|
93
|
+
val = upb_EnumValueDef_Number(ev);
|
94
|
+
break;
|
95
|
+
}
|
96
|
+
default:
|
97
|
+
rb_raise(cTypeError,
|
98
|
+
"Expected number or symbol type for enum field '%s'.", name);
|
99
|
+
}
|
100
|
+
|
101
|
+
return val;
|
102
|
+
|
103
|
+
unknownval:
|
104
|
+
rb_raise(rb_eRangeError, "Unknown symbol value for enum field '%s'.", name);
|
105
|
+
}
|
106
|
+
|
107
|
+
VALUE Convert_CheckStringUtf8(VALUE str) {
|
108
|
+
VALUE utf8 = rb_enc_from_encoding(rb_utf8_encoding());
|
109
|
+
|
110
|
+
if (rb_obj_encoding(str) == utf8) {
|
111
|
+
// Note: Just because a string is marked as having UTF-8 encoding does
|
112
|
+
// not mean that it is *valid* UTF-8. We have to check separately
|
113
|
+
// whether it is valid.
|
114
|
+
if (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN) {
|
115
|
+
VALUE exc = rb_const_get_at(
|
116
|
+
rb_cEncoding, rb_intern("InvalidByteSequenceError"));
|
117
|
+
rb_raise(exc, "String is invalid UTF-8");
|
118
|
+
}
|
119
|
+
} else {
|
120
|
+
// Note: this will not duplicate underlying string data unless
|
121
|
+
// necessary.
|
122
|
+
//
|
123
|
+
// This will throw an exception if the conversion cannot be performed:
|
124
|
+
// - Encoding::UndefinedConversionError if certain characters cannot be
|
125
|
+
// converted to UTF-8.
|
126
|
+
// - Encoding::InvalidByteSequenceError if certain characters were invalid
|
127
|
+
// in the source encoding.
|
128
|
+
str = rb_str_encode(str, utf8, 0, Qnil);
|
129
|
+
PBRUBY_ASSERT(rb_enc_str_coderange(str) != ENC_CODERANGE_BROKEN);
|
130
|
+
}
|
131
|
+
|
132
|
+
return str;
|
133
|
+
}
|
134
|
+
|
135
|
+
upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
|
136
|
+
TypeInfo type_info, upb_Arena* arena) {
|
137
|
+
upb_MessageValue ret;
|
138
|
+
|
139
|
+
switch (type_info.type) {
|
140
|
+
case kUpb_CType_Float:
|
141
|
+
if (!is_ruby_num(value)) {
|
142
|
+
rb_raise(cTypeError,
|
143
|
+
"Expected number type for float field '%s' (given %s).", name,
|
144
|
+
rb_class2name(CLASS_OF(value)));
|
145
|
+
}
|
146
|
+
ret.float_val = NUM2DBL(value);
|
147
|
+
break;
|
148
|
+
case kUpb_CType_Double:
|
149
|
+
if (!is_ruby_num(value)) {
|
150
|
+
rb_raise(cTypeError,
|
151
|
+
"Expected number type for double field '%s' (given %s).", name,
|
152
|
+
rb_class2name(CLASS_OF(value)));
|
153
|
+
}
|
154
|
+
ret.double_val = NUM2DBL(value);
|
155
|
+
break;
|
156
|
+
case kUpb_CType_Bool: {
|
157
|
+
if (value == Qtrue) {
|
158
|
+
ret.bool_val = 1;
|
159
|
+
} else if (value == Qfalse) {
|
160
|
+
ret.bool_val = 0;
|
161
|
+
} else {
|
162
|
+
rb_raise(cTypeError,
|
163
|
+
"Invalid argument for boolean field '%s' (given %s).", name,
|
164
|
+
rb_class2name(CLASS_OF(value)));
|
165
|
+
}
|
166
|
+
break;
|
167
|
+
}
|
168
|
+
case kUpb_CType_String:
|
169
|
+
if (rb_obj_class(value) == rb_cSymbol) {
|
170
|
+
value = rb_funcall(value, rb_intern("to_s"), 0);
|
171
|
+
} else if (!rb_obj_is_kind_of(value, rb_cString)) {
|
172
|
+
rb_raise(cTypeError,
|
173
|
+
"Invalid argument for string field '%s' (given %s).", name,
|
174
|
+
rb_class2name(CLASS_OF(value)));
|
175
|
+
}
|
176
|
+
|
177
|
+
value = Convert_CheckStringUtf8(value);
|
178
|
+
ret.str_val = Convert_StringData(value, arena);
|
179
|
+
break;
|
180
|
+
case kUpb_CType_Bytes: {
|
181
|
+
VALUE bytes = rb_enc_from_encoding(rb_ascii8bit_encoding());
|
182
|
+
if (rb_obj_class(value) != rb_cString) {
|
183
|
+
rb_raise(cTypeError,
|
184
|
+
"Invalid argument for bytes field '%s' (given %s).", name,
|
185
|
+
rb_class2name(CLASS_OF(value)));
|
186
|
+
}
|
187
|
+
|
188
|
+
if (rb_obj_encoding(value) != bytes) {
|
189
|
+
// Note: this will not duplicate underlying string data unless
|
190
|
+
// necessary.
|
191
|
+
// TODO: is this really necessary to get raw bytes?
|
192
|
+
value = rb_str_encode(value, bytes, 0, Qnil);
|
193
|
+
}
|
194
|
+
|
195
|
+
ret.str_val = Convert_StringData(value, arena);
|
196
|
+
break;
|
197
|
+
}
|
198
|
+
case kUpb_CType_Message:
|
199
|
+
ret.msg_val =
|
200
|
+
Message_GetUpbMessage(value, type_info.def.msgdef, name, arena);
|
201
|
+
break;
|
202
|
+
case kUpb_CType_Enum:
|
203
|
+
ret.int32_val = Convert_ToEnum(value, name, type_info.def.enumdef);
|
204
|
+
break;
|
205
|
+
case kUpb_CType_Int32:
|
206
|
+
case kUpb_CType_Int64:
|
207
|
+
case kUpb_CType_UInt32:
|
208
|
+
case kUpb_CType_UInt64:
|
209
|
+
Convert_CheckInt(name, type_info.type, value);
|
210
|
+
switch (type_info.type) {
|
211
|
+
case kUpb_CType_Int32:
|
212
|
+
ret.int32_val = NUM2INT(value);
|
213
|
+
break;
|
214
|
+
case kUpb_CType_Int64:
|
215
|
+
ret.int64_val = NUM2LL(value);
|
216
|
+
break;
|
217
|
+
case kUpb_CType_UInt32:
|
218
|
+
ret.uint32_val = NUM2UINT(value);
|
219
|
+
break;
|
220
|
+
case kUpb_CType_UInt64:
|
221
|
+
ret.uint64_val = NUM2ULL(value);
|
222
|
+
break;
|
223
|
+
default:
|
224
|
+
rb_raise(cTypeError, "Convert_RubyToUpb(): Unexpected type %d",
|
225
|
+
(int)type_info.type);
|
226
|
+
}
|
227
|
+
break;
|
228
|
+
default:
|
229
|
+
rb_raise(cTypeError,
|
230
|
+
"Convert_RubyToUpb(): Unexpected type %d", (int)type_info.type);
|
231
|
+
}
|
232
|
+
|
233
|
+
return ret;
|
234
|
+
}
|
235
|
+
|
236
|
+
VALUE Convert_UpbToRuby(upb_MessageValue upb_val, TypeInfo type_info,
|
237
|
+
VALUE arena) {
|
238
|
+
switch (type_info.type) {
|
239
|
+
case kUpb_CType_Float:
|
240
|
+
return DBL2NUM(upb_val.float_val);
|
241
|
+
case kUpb_CType_Double:
|
242
|
+
return DBL2NUM(upb_val.double_val);
|
243
|
+
case kUpb_CType_Bool:
|
244
|
+
return upb_val.bool_val ? Qtrue : Qfalse;
|
245
|
+
case kUpb_CType_Int32:
|
246
|
+
return INT2NUM(upb_val.int32_val);
|
247
|
+
case kUpb_CType_Int64:
|
248
|
+
return LL2NUM(upb_val.int64_val);
|
249
|
+
case kUpb_CType_UInt32:
|
250
|
+
return UINT2NUM(upb_val.uint32_val);
|
251
|
+
case kUpb_CType_UInt64:
|
252
|
+
return ULL2NUM(upb_val.int64_val);
|
253
|
+
case kUpb_CType_Enum: {
|
254
|
+
const upb_EnumValueDef* ev = upb_EnumDef_FindValueByNumber(
|
255
|
+
type_info.def.enumdef, upb_val.int32_val);
|
256
|
+
if (ev) {
|
257
|
+
return ID2SYM(rb_intern(upb_EnumValueDef_Name(ev)));
|
258
|
+
} else {
|
259
|
+
return INT2NUM(upb_val.int32_val);
|
260
|
+
}
|
261
|
+
}
|
262
|
+
case kUpb_CType_String: {
|
263
|
+
VALUE str_rb = rb_str_new(upb_val.str_val.data, upb_val.str_val.size);
|
264
|
+
rb_enc_associate(str_rb, rb_utf8_encoding());
|
265
|
+
rb_obj_freeze(str_rb);
|
266
|
+
return str_rb;
|
267
|
+
}
|
268
|
+
case kUpb_CType_Bytes: {
|
269
|
+
VALUE str_rb = rb_str_new(upb_val.str_val.data, upb_val.str_val.size);
|
270
|
+
rb_enc_associate(str_rb, rb_ascii8bit_encoding());
|
271
|
+
rb_obj_freeze(str_rb);
|
272
|
+
return str_rb;
|
273
|
+
}
|
274
|
+
case kUpb_CType_Message:
|
275
|
+
return Message_GetRubyWrapper((upb_Message*)upb_val.msg_val,
|
276
|
+
type_info.def.msgdef, arena);
|
277
|
+
default:
|
278
|
+
rb_raise(rb_eRuntimeError, "Convert_UpbToRuby(): Unexpected type %d",
|
279
|
+
(int)type_info.type);
|
280
|
+
}
|
281
|
+
}
|
282
|
+
|
283
|
+
upb_MessageValue Msgval_DeepCopy(upb_MessageValue msgval, TypeInfo type_info,
|
284
|
+
upb_Arena* arena) {
|
285
|
+
upb_MessageValue new_msgval;
|
286
|
+
|
287
|
+
switch (type_info.type) {
|
288
|
+
default:
|
289
|
+
memcpy(&new_msgval, &msgval, sizeof(msgval));
|
290
|
+
break;
|
291
|
+
case kUpb_CType_String:
|
292
|
+
case kUpb_CType_Bytes: {
|
293
|
+
size_t n = msgval.str_val.size;
|
294
|
+
char* mem = upb_Arena_Malloc(arena, n);
|
295
|
+
new_msgval.str_val.data = mem;
|
296
|
+
new_msgval.str_val.size = n;
|
297
|
+
memcpy(mem, msgval.str_val.data, n);
|
298
|
+
break;
|
299
|
+
}
|
300
|
+
case kUpb_CType_Message:
|
301
|
+
new_msgval.msg_val =
|
302
|
+
Message_deep_copy(msgval.msg_val, type_info.def.msgdef, arena);
|
303
|
+
break;
|
304
|
+
}
|
305
|
+
|
306
|
+
return new_msgval;
|
307
|
+
}
|
308
|
+
|
309
|
+
bool Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2,
|
310
|
+
TypeInfo type_info) {
|
311
|
+
upb_Status status;
|
312
|
+
upb_Status_Clear(&status);
|
313
|
+
bool return_value = shared_Msgval_IsEqual(val1, val2, type_info.type,
|
314
|
+
type_info.def.msgdef, &status);
|
315
|
+
if (upb_Status_IsOk(&status)) {
|
316
|
+
return return_value;
|
317
|
+
} else {
|
318
|
+
rb_raise(rb_eRuntimeError, "Msgval_IsEqual(): %s",
|
319
|
+
upb_Status_ErrorMessage(&status));
|
320
|
+
}
|
321
|
+
}
|
322
|
+
|
323
|
+
uint64_t Msgval_GetHash(upb_MessageValue val, TypeInfo type_info,
|
324
|
+
uint64_t seed) {
|
325
|
+
upb_Status status;
|
326
|
+
upb_Status_Clear(&status);
|
327
|
+
uint64_t return_value = shared_Msgval_GetHash(
|
328
|
+
val, type_info.type, type_info.def.msgdef, seed, &status);
|
329
|
+
if (upb_Status_IsOk(&status)) {
|
330
|
+
return return_value;
|
331
|
+
} else {
|
332
|
+
rb_raise(rb_eRuntimeError, "Msgval_GetHash(): %s",
|
333
|
+
upb_Status_ErrorMessage(&status));
|
334
|
+
}
|
335
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
2
|
+
// Copyright 2008 Google Inc. All rights reserved.
|
3
|
+
//
|
4
|
+
// Use of this source code is governed by a BSD-style
|
5
|
+
// license that can be found in the LICENSE file or at
|
6
|
+
// https://developers.google.com/open-source/licenses/bsd
|
7
|
+
|
8
|
+
#ifndef RUBY_PROTOBUF_CONVERT_H_
|
9
|
+
#define RUBY_PROTOBUF_CONVERT_H_
|
10
|
+
|
11
|
+
#include "protobuf.h"
|
12
|
+
#include "ruby-upb.h"
|
13
|
+
|
14
|
+
// Converts |ruby_val| to a upb_MessageValue according to |type_info|.
|
15
|
+
//
|
16
|
+
// The |arena| parameter indicates the lifetime of the container where this
|
17
|
+
// value will be assigned. It is used as follows:
|
18
|
+
// - If type is string or bytes, the string data will be copied into |arena|.
|
19
|
+
// - If type is message, and we need to auto-construct a message due to implicit
|
20
|
+
// conversions (eg. Time -> Google::Protobuf::Timestamp), the new message
|
21
|
+
// will be created in |arena|.
|
22
|
+
// - If type is message and the Ruby value is a message instance, we will fuse
|
23
|
+
// the message's arena into |arena|, to ensure that this message outlives the
|
24
|
+
// container.
|
25
|
+
upb_MessageValue Convert_RubyToUpb(VALUE ruby_val, const char *name,
|
26
|
+
TypeInfo type_info, upb_Arena *arena);
|
27
|
+
|
28
|
+
// Converts |upb_val| to a Ruby VALUE according to |type_info|. This may involve
|
29
|
+
// creating a Ruby wrapper object.
|
30
|
+
//
|
31
|
+
// The |arena| parameter indicates the arena that owns the lifetime of
|
32
|
+
// |upb_val|. Any Ruby wrapper object that is created will reference |arena|
|
33
|
+
// and ensure it outlives the wrapper.
|
34
|
+
VALUE Convert_UpbToRuby(upb_MessageValue upb_val, TypeInfo type_info,
|
35
|
+
VALUE arena);
|
36
|
+
|
37
|
+
// Creates a deep copy of |msgval| in |arena|.
|
38
|
+
upb_MessageValue Msgval_DeepCopy(upb_MessageValue msgval, TypeInfo type_info,
|
39
|
+
upb_Arena *arena);
|
40
|
+
|
41
|
+
// Returns true if |val1| and |val2| are equal. Their type is given by
|
42
|
+
// |type_info|.
|
43
|
+
bool Msgval_IsEqual(upb_MessageValue val1, upb_MessageValue val2,
|
44
|
+
TypeInfo type_info);
|
45
|
+
|
46
|
+
// Returns a hash value for the given upb_MessageValue.
|
47
|
+
uint64_t Msgval_GetHash(upb_MessageValue val, TypeInfo type_info,
|
48
|
+
uint64_t seed);
|
49
|
+
|
50
|
+
#endif // RUBY_PROTOBUF_CONVERT_H_
|