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
@@ -36,55 +36,58 @@
|
|
36
36
|
#include "protobuf.h"
|
37
37
|
#include "ruby-upb.h"
|
38
38
|
|
39
|
-
// Gets the underlying
|
40
|
-
// wrapper. Requires that |value| is indeed a message object.
|
41
|
-
const
|
39
|
+
// Gets the underlying upb_Message* and upb_MessageDef for the given Ruby
|
40
|
+
// message wrapper. Requires that |value| is indeed a message object.
|
41
|
+
const upb_Message* Message_Get(VALUE value, const upb_MessageDef** m);
|
42
42
|
|
43
43
|
// Like Message_Get(), but checks that the object is not frozen and returns a
|
44
44
|
// mutable pointer.
|
45
|
-
|
45
|
+
upb_Message* Message_GetMutable(VALUE value, const upb_MessageDef** m);
|
46
46
|
|
47
47
|
// Returns the Arena object for this message.
|
48
48
|
VALUE Message_GetArena(VALUE value);
|
49
49
|
|
50
|
-
// Converts |value| into a
|
51
|
-
// raising an error if this is not possible. Used when assigning |value|
|
52
|
-
// field of another message, which means the message must be of a
|
53
|
-
// type.
|
50
|
+
// Converts |value| into a upb_Message value of the expected upb_MessageDef
|
51
|
+
// type, raising an error if this is not possible. Used when assigning |value|
|
52
|
+
// to a field of another message, which means the message must be of a
|
53
|
+
// particular type.
|
54
54
|
//
|
55
55
|
// This will perform automatic conversions in some cases (for example, Time ->
|
56
56
|
// Google::Protobuf::Timestamp). If any new message is created, it will be
|
57
57
|
// created on |arena|, and any existing message will have its arena fused with
|
58
58
|
// |arena|.
|
59
|
-
const
|
60
|
-
|
59
|
+
const upb_Message* Message_GetUpbMessage(VALUE value, const upb_MessageDef* m,
|
60
|
+
const char* name, upb_Arena* arena);
|
61
61
|
|
62
62
|
// Gets or constructs a Ruby wrapper object for the given message. The wrapper
|
63
63
|
// object will reference |arena| and ensure that it outlives this object.
|
64
|
-
VALUE Message_GetRubyWrapper(
|
64
|
+
VALUE Message_GetRubyWrapper(upb_Message* msg, const upb_MessageDef* m,
|
65
|
+
VALUE arena);
|
65
66
|
|
66
67
|
// Gets the given field from this message.
|
67
|
-
VALUE Message_getfield(VALUE _self, const
|
68
|
+
VALUE Message_getfield(VALUE _self, const upb_FieldDef* f);
|
68
69
|
|
69
70
|
// Implements #inspect for this message, printing the text to |b|.
|
70
|
-
void Message_PrintMessage(StringBuilder* b, const
|
71
|
-
const
|
71
|
+
void Message_PrintMessage(StringBuilder* b, const upb_Message* msg,
|
72
|
+
const upb_MessageDef* m);
|
72
73
|
|
73
74
|
// Returns a hash value for the given message.
|
74
|
-
uint64_t Message_Hash(const
|
75
|
+
uint64_t Message_Hash(const upb_Message* msg, const upb_MessageDef* m,
|
76
|
+
uint64_t seed);
|
75
77
|
|
76
78
|
// Returns a deep copy of the given message.
|
77
|
-
|
78
|
-
|
79
|
+
upb_Message* Message_deep_copy(const upb_Message* msg, const upb_MessageDef* m,
|
80
|
+
upb_Arena* arena);
|
79
81
|
|
80
82
|
// Returns true if these two messages are equal.
|
81
|
-
bool Message_Equal(const
|
83
|
+
bool Message_Equal(const upb_Message* m1, const upb_Message* m2,
|
84
|
+
const upb_MessageDef* m);
|
82
85
|
|
83
86
|
// Checks that this Ruby object is a message, and raises an exception if not.
|
84
87
|
void Message_CheckClass(VALUE klass);
|
85
88
|
|
86
89
|
// Returns a new Hash object containing the contents of this message.
|
87
|
-
VALUE Scalar_CreateHash(
|
90
|
+
VALUE Scalar_CreateHash(upb_MessageValue val, TypeInfo type_info);
|
88
91
|
|
89
92
|
// Creates a message class or enum module for this descriptor, respectively.
|
90
93
|
VALUE build_class_from_descriptor(VALUE descriptor);
|
@@ -40,14 +40,14 @@
|
|
40
40
|
VALUE cParseError;
|
41
41
|
VALUE cTypeError;
|
42
42
|
|
43
|
-
const
|
44
|
-
const
|
45
|
-
return
|
43
|
+
const upb_FieldDef *map_field_key(const upb_FieldDef *field) {
|
44
|
+
const upb_MessageDef *entry = upb_FieldDef_MessageSubDef(field);
|
45
|
+
return upb_MessageDef_FindFieldByNumber(entry, 1);
|
46
46
|
}
|
47
47
|
|
48
|
-
const
|
49
|
-
const
|
50
|
-
return
|
48
|
+
const upb_FieldDef *map_field_value(const upb_FieldDef *field) {
|
49
|
+
const upb_MessageDef *entry = upb_FieldDef_MessageSubDef(field);
|
50
|
+
return upb_MessageDef_FindFieldByNumber(entry, 2);
|
51
51
|
}
|
52
52
|
|
53
53
|
// -----------------------------------------------------------------------------
|
@@ -66,21 +66,21 @@ static size_t StringBuilder_SizeOf(size_t cap) {
|
|
66
66
|
return sizeof(StringBuilder) + cap;
|
67
67
|
}
|
68
68
|
|
69
|
-
StringBuilder*
|
69
|
+
StringBuilder *StringBuilder_New() {
|
70
70
|
const size_t cap = 128;
|
71
|
-
StringBuilder*
|
71
|
+
StringBuilder *builder = malloc(sizeof(*builder));
|
72
72
|
builder->size = 0;
|
73
73
|
builder->cap = cap;
|
74
74
|
builder->data = malloc(builder->cap);
|
75
75
|
return builder;
|
76
76
|
}
|
77
77
|
|
78
|
-
void StringBuilder_Free(StringBuilder*
|
78
|
+
void StringBuilder_Free(StringBuilder *b) {
|
79
79
|
free(b->data);
|
80
80
|
free(b);
|
81
81
|
}
|
82
82
|
|
83
|
-
void StringBuilder_Printf(StringBuilder*
|
83
|
+
void StringBuilder_Printf(StringBuilder *b, const char *fmt, ...) {
|
84
84
|
size_t have = b->cap - b->size;
|
85
85
|
size_t n;
|
86
86
|
va_list args;
|
@@ -104,60 +104,62 @@ void StringBuilder_Printf(StringBuilder* b, const char *fmt, ...) {
|
|
104
104
|
b->size += n;
|
105
105
|
}
|
106
106
|
|
107
|
-
VALUE StringBuilder_ToRubyString(StringBuilder*
|
107
|
+
VALUE StringBuilder_ToRubyString(StringBuilder *b) {
|
108
108
|
VALUE ret = rb_str_new(b->data, b->size);
|
109
109
|
rb_enc_associate(ret, rb_utf8_encoding());
|
110
110
|
return ret;
|
111
111
|
}
|
112
112
|
|
113
|
-
static void StringBuilder_PrintEnum(StringBuilder*
|
114
|
-
const
|
115
|
-
const
|
116
|
-
if (
|
117
|
-
StringBuilder_Printf(b, ":%s",
|
113
|
+
static void StringBuilder_PrintEnum(StringBuilder *b, int32_t val,
|
114
|
+
const upb_EnumDef *e) {
|
115
|
+
const upb_EnumValueDef *ev = upb_EnumDef_FindValueByNumber(e, val);
|
116
|
+
if (ev) {
|
117
|
+
StringBuilder_Printf(b, ":%s", upb_EnumValueDef_Name(ev));
|
118
118
|
} else {
|
119
119
|
StringBuilder_Printf(b, "%" PRId32, val);
|
120
120
|
}
|
121
121
|
}
|
122
122
|
|
123
|
-
void StringBuilder_PrintMsgval(StringBuilder*
|
123
|
+
void StringBuilder_PrintMsgval(StringBuilder *b, upb_MessageValue val,
|
124
124
|
TypeInfo info) {
|
125
125
|
switch (info.type) {
|
126
|
-
case
|
126
|
+
case kUpb_CType_Bool:
|
127
127
|
StringBuilder_Printf(b, "%s", val.bool_val ? "true" : "false");
|
128
128
|
break;
|
129
|
-
case
|
129
|
+
case kUpb_CType_Float: {
|
130
130
|
VALUE str = rb_inspect(DBL2NUM(val.float_val));
|
131
131
|
StringBuilder_Printf(b, "%s", RSTRING_PTR(str));
|
132
132
|
break;
|
133
133
|
}
|
134
|
-
case
|
134
|
+
case kUpb_CType_Double: {
|
135
135
|
VALUE str = rb_inspect(DBL2NUM(val.double_val));
|
136
136
|
StringBuilder_Printf(b, "%s", RSTRING_PTR(str));
|
137
137
|
break;
|
138
138
|
}
|
139
|
-
case
|
139
|
+
case kUpb_CType_Int32:
|
140
140
|
StringBuilder_Printf(b, "%" PRId32, val.int32_val);
|
141
141
|
break;
|
142
|
-
case
|
142
|
+
case kUpb_CType_UInt32:
|
143
143
|
StringBuilder_Printf(b, "%" PRIu32, val.uint32_val);
|
144
144
|
break;
|
145
|
-
case
|
145
|
+
case kUpb_CType_Int64:
|
146
146
|
StringBuilder_Printf(b, "%" PRId64, val.int64_val);
|
147
147
|
break;
|
148
|
-
case
|
148
|
+
case kUpb_CType_UInt64:
|
149
149
|
StringBuilder_Printf(b, "%" PRIu64, val.uint64_val);
|
150
150
|
break;
|
151
|
-
case
|
152
|
-
StringBuilder_Printf(b, "\"%.*s\"", (int)val.str_val.size,
|
151
|
+
case kUpb_CType_String:
|
152
|
+
StringBuilder_Printf(b, "\"%.*s\"", (int)val.str_val.size,
|
153
|
+
val.str_val.data);
|
153
154
|
break;
|
154
|
-
case
|
155
|
-
StringBuilder_Printf(b, "\"%.*s\"", (int)val.str_val.size,
|
155
|
+
case kUpb_CType_Bytes:
|
156
|
+
StringBuilder_Printf(b, "\"%.*s\"", (int)val.str_val.size,
|
157
|
+
val.str_val.data);
|
156
158
|
break;
|
157
|
-
case
|
159
|
+
case kUpb_CType_Enum:
|
158
160
|
StringBuilder_PrintEnum(b, val.int32_val, info.def.enumdef);
|
159
161
|
break;
|
160
|
-
case
|
162
|
+
case kUpb_CType_Message:
|
161
163
|
Message_PrintMessage(b, val.msg_val, info.def.msgdef);
|
162
164
|
break;
|
163
165
|
}
|
@@ -168,7 +170,9 @@ void StringBuilder_PrintMsgval(StringBuilder* b, upb_msgval val,
|
|
168
170
|
// -----------------------------------------------------------------------------
|
169
171
|
|
170
172
|
typedef struct {
|
171
|
-
|
173
|
+
upb_Arena *arena;
|
174
|
+
// IMPORTANT: WB_PROTECTED objects must only use the RB_OBJ_WRITE()
|
175
|
+
// macro to update VALUE references, as to trigger write barriers.
|
172
176
|
VALUE pinned_objs;
|
173
177
|
} Arena;
|
174
178
|
|
@@ -179,40 +183,59 @@ static void Arena_mark(void *data) {
|
|
179
183
|
|
180
184
|
static void Arena_free(void *data) {
|
181
185
|
Arena *arena = data;
|
182
|
-
|
186
|
+
upb_Arena_Free(arena->arena);
|
183
187
|
xfree(arena);
|
184
188
|
}
|
185
189
|
|
186
190
|
static VALUE cArena;
|
187
191
|
|
188
192
|
const rb_data_type_t Arena_type = {
|
189
|
-
|
190
|
-
|
191
|
-
|
193
|
+
"Google::Protobuf::Internal::Arena",
|
194
|
+
{Arena_mark, Arena_free, NULL},
|
195
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
192
196
|
};
|
193
197
|
|
198
|
+
static void* ruby_upb_allocfunc(upb_alloc* alloc, void* ptr, size_t oldsize, size_t size) {
|
199
|
+
if (size == 0) {
|
200
|
+
xfree(ptr);
|
201
|
+
return NULL;
|
202
|
+
} else {
|
203
|
+
return xrealloc(ptr, size);
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
upb_alloc ruby_upb_alloc = {&ruby_upb_allocfunc};
|
208
|
+
|
194
209
|
static VALUE Arena_alloc(VALUE klass) {
|
195
210
|
Arena *arena = ALLOC(Arena);
|
196
|
-
arena->arena =
|
211
|
+
arena->arena = upb_Arena_Init(NULL, 0, &ruby_upb_alloc);
|
197
212
|
arena->pinned_objs = Qnil;
|
198
213
|
return TypedData_Wrap_Struct(klass, &Arena_type, arena);
|
199
214
|
}
|
200
215
|
|
201
|
-
|
216
|
+
upb_Arena *Arena_get(VALUE _arena) {
|
202
217
|
Arena *arena;
|
203
218
|
TypedData_Get_Struct(_arena, Arena, &Arena_type, arena);
|
204
219
|
return arena->arena;
|
205
220
|
}
|
206
221
|
|
207
|
-
VALUE
|
208
|
-
|
222
|
+
void Arena_fuse(VALUE _arena, upb_Arena *other) {
|
223
|
+
Arena *arena;
|
224
|
+
TypedData_Get_Struct(_arena, Arena, &Arena_type, arena);
|
225
|
+
if (!upb_Arena_Fuse(arena->arena, other)) {
|
226
|
+
rb_raise(rb_eRuntimeError,
|
227
|
+
"Unable to fuse arenas. This should never happen since Ruby does "
|
228
|
+
"not use initial blocks");
|
229
|
+
}
|
209
230
|
}
|
210
231
|
|
232
|
+
VALUE Arena_new() { return Arena_alloc(cArena); }
|
233
|
+
|
211
234
|
void Arena_Pin(VALUE _arena, VALUE obj) {
|
212
235
|
Arena *arena;
|
213
236
|
TypedData_Get_Struct(_arena, Arena, &Arena_type, arena);
|
214
237
|
if (arena->pinned_objs == Qnil) {
|
215
|
-
arena->pinned_objs
|
238
|
+
RB_OBJ_WRITE(_arena, &arena->pinned_objs, rb_ary_new());
|
216
239
|
}
|
217
240
|
rb_ary_push(arena->pinned_objs, obj);
|
218
241
|
}
|
@@ -323,8 +346,8 @@ static void SecondaryMap_MaybeGC() {
|
|
323
346
|
// avoid O(N^2) CPU costs.
|
324
347
|
size_t threshold = PBRUBY_MAX(secondary_len * 0.2, 2000);
|
325
348
|
if (waste > threshold) {
|
326
|
-
rb_funcall(gc_secondary_map_lambda, rb_intern("call"), 2,
|
327
|
-
|
349
|
+
rb_funcall(gc_secondary_map_lambda, rb_intern("call"), 2, secondary_map,
|
350
|
+
weak_obj_cache);
|
328
351
|
}
|
329
352
|
}
|
330
353
|
|
@@ -343,7 +366,7 @@ static VALUE SecondaryMap_Get(VALUE key, bool create) {
|
|
343
366
|
#endif
|
344
367
|
|
345
368
|
// Requires: secondary_map_mutex is held by this thread iff create == true.
|
346
|
-
static VALUE ObjectCache_GetKey(const void*
|
369
|
+
static VALUE ObjectCache_GetKey(const void *key, bool create) {
|
347
370
|
VALUE key_val = (VALUE)key;
|
348
371
|
PBRUBY_ASSERT((key_val & 3) == 0);
|
349
372
|
VALUE ret = LL2NUM(key_val >> 2);
|
@@ -370,7 +393,7 @@ static void ObjectCache_Init() {
|
|
370
393
|
#endif
|
371
394
|
}
|
372
395
|
|
373
|
-
void ObjectCache_Add(const void*
|
396
|
+
void ObjectCache_Add(const void *key, VALUE val) {
|
374
397
|
PBRUBY_ASSERT(ObjectCache_Get(key) == Qnil);
|
375
398
|
#if USE_SECONDARY_MAP
|
376
399
|
rb_mutex_lock(secondary_map_mutex);
|
@@ -384,7 +407,7 @@ void ObjectCache_Add(const void* key, VALUE val) {
|
|
384
407
|
}
|
385
408
|
|
386
409
|
// Returns the cached object for this key, if any. Otherwise returns Qnil.
|
387
|
-
VALUE ObjectCache_Get(const void*
|
410
|
+
VALUE ObjectCache_Get(const void *key) {
|
388
411
|
VALUE key_rb = ObjectCache_GetKey(key, false);
|
389
412
|
return rb_funcall(weak_obj_cache, item_get, 1, key_rb);
|
390
413
|
}
|
@@ -397,9 +420,9 @@ VALUE ObjectCache_Get(const void* key) {
|
|
397
420
|
* unknown fields in submessages.
|
398
421
|
*/
|
399
422
|
static VALUE Google_Protobuf_discard_unknown(VALUE self, VALUE msg_rb) {
|
400
|
-
const
|
401
|
-
|
402
|
-
if (!
|
423
|
+
const upb_MessageDef *m;
|
424
|
+
upb_Message *msg = Message_GetMutable(msg_rb, &m);
|
425
|
+
if (!upb_Message_DiscardUnknown(msg, m, 128)) {
|
403
426
|
rb_raise(rb_eRuntimeError, "Messages nested too deeply.");
|
404
427
|
}
|
405
428
|
|
@@ -421,10 +444,10 @@ VALUE Google_Protobuf_deep_copy(VALUE self, VALUE obj) {
|
|
421
444
|
return Map_deep_copy(obj);
|
422
445
|
} else {
|
423
446
|
VALUE new_arena_rb = Arena_new();
|
424
|
-
|
425
|
-
const
|
426
|
-
const
|
427
|
-
|
447
|
+
upb_Arena *new_arena = Arena_get(new_arena_rb);
|
448
|
+
const upb_MessageDef *m;
|
449
|
+
const upb_Message *msg = Message_Get(obj, &m);
|
450
|
+
upb_Message *new_msg = Message_deep_copy(msg, m, new_arena);
|
428
451
|
return Message_GetRubyWrapper(new_msg, m, new_arena_rb);
|
429
452
|
}
|
430
453
|
}
|
@@ -435,8 +458,7 @@ VALUE Google_Protobuf_deep_copy(VALUE self, VALUE obj) {
|
|
435
458
|
|
436
459
|
// This must be named "Init_protobuf_c" because the Ruby module is named
|
437
460
|
// "protobuf_c" -- the VM looks for this symbol in our .so.
|
438
|
-
__attribute__
|
439
|
-
void Init_protobuf_c() {
|
461
|
+
__attribute__((visibility("default"))) void Init_protobuf_c() {
|
440
462
|
ObjectCache_Init();
|
441
463
|
|
442
464
|
VALUE google = rb_define_module("Google");
|
@@ -455,6 +477,6 @@ void Init_protobuf_c() {
|
|
455
477
|
|
456
478
|
rb_define_singleton_method(protobuf, "discard_unknown",
|
457
479
|
Google_Protobuf_discard_unknown, 1);
|
458
|
-
rb_define_singleton_method(protobuf, "deep_copy",
|
459
|
-
|
480
|
+
rb_define_singleton_method(protobuf, "deep_copy", Google_Protobuf_deep_copy,
|
481
|
+
1);
|
460
482
|
}
|
@@ -31,29 +31,33 @@
|
|
31
31
|
#ifndef __GOOGLE_PROTOBUF_RUBY_PROTOBUF_H__
|
32
32
|
#define __GOOGLE_PROTOBUF_RUBY_PROTOBUF_H__
|
33
33
|
|
34
|
+
#include <ruby/encoding.h>
|
34
35
|
#include <ruby/ruby.h>
|
35
36
|
#include <ruby/vm.h>
|
36
|
-
#include <ruby/encoding.h>
|
37
37
|
|
38
|
-
#include "ruby-upb.h"
|
39
38
|
#include "defs.h"
|
39
|
+
#include "ruby-upb.h"
|
40
40
|
|
41
41
|
// These operate on a map field (i.e., a repeated field of submessages whose
|
42
42
|
// submessage type is a map-entry msgdef).
|
43
|
-
const
|
44
|
-
const
|
43
|
+
const upb_FieldDef* map_field_key(const upb_FieldDef* field);
|
44
|
+
const upb_FieldDef* map_field_value(const upb_FieldDef* field);
|
45
45
|
|
46
46
|
// -----------------------------------------------------------------------------
|
47
47
|
// Arena
|
48
48
|
// -----------------------------------------------------------------------------
|
49
49
|
|
50
|
-
// A Ruby object that wraps an underlying
|
50
|
+
// A Ruby object that wraps an underlying upb_Arena. Any objects that are
|
51
51
|
// allocated from this arena should reference the Arena in rb_gc_mark(), to
|
52
52
|
// ensure that the object's underlying memory outlives any Ruby object that can
|
53
53
|
// reach it.
|
54
54
|
|
55
55
|
VALUE Arena_new();
|
56
|
-
|
56
|
+
upb_Arena* Arena_get(VALUE arena);
|
57
|
+
|
58
|
+
// Fuses this arena to another, throwing a Ruby exception if this is not
|
59
|
+
// possible.
|
60
|
+
void Arena_fuse(VALUE arena, upb_Arena* other);
|
57
61
|
|
58
62
|
// Pins this Ruby object to the lifetime of this arena, so that as long as the
|
59
63
|
// arena is alive this object will not be collected.
|
@@ -89,10 +93,11 @@ typedef struct StringBuilder StringBuilder;
|
|
89
93
|
|
90
94
|
StringBuilder* StringBuilder_New();
|
91
95
|
void StringBuilder_Free(StringBuilder* b);
|
92
|
-
void StringBuilder_Printf(StringBuilder* b, const char
|
96
|
+
void StringBuilder_Printf(StringBuilder* b, const char* fmt, ...);
|
93
97
|
VALUE StringBuilder_ToRubyString(StringBuilder* b);
|
94
98
|
|
95
|
-
void StringBuilder_PrintMsgval(StringBuilder* b,
|
99
|
+
void StringBuilder_PrintMsgval(StringBuilder* b, upb_MessageValue val,
|
100
|
+
TypeInfo info);
|
96
101
|
|
97
102
|
// -----------------------------------------------------------------------------
|
98
103
|
// Utilities.
|
@@ -101,7 +106,9 @@ void StringBuilder_PrintMsgval(StringBuilder* b, upb_msgval val, TypeInfo info);
|
|
101
106
|
extern VALUE cTypeError;
|
102
107
|
|
103
108
|
#ifdef NDEBUG
|
104
|
-
#define PBRUBY_ASSERT(expr)
|
109
|
+
#define PBRUBY_ASSERT(expr) \
|
110
|
+
do { \
|
111
|
+
} while (false && (expr))
|
105
112
|
#else
|
106
113
|
#define PBRUBY_ASSERT(expr) assert(expr)
|
107
114
|
#endif
|