google-protobuf 3.19.2 → 3.20.0.rc.1

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.

@@ -41,11 +41,11 @@
41
41
  // instances.
42
42
  // -----------------------------------------------------------------------------
43
43
 
44
- static VALUE get_msgdef_obj(VALUE descriptor_pool, const upb_msgdef* def);
45
- static VALUE get_enumdef_obj(VALUE descriptor_pool, const upb_enumdef* def);
46
- static VALUE get_fielddef_obj(VALUE descriptor_pool, const upb_fielddef* def);
47
- static VALUE get_filedef_obj(VALUE descriptor_pool, const upb_filedef* def);
48
- static VALUE get_oneofdef_obj(VALUE descriptor_pool, const upb_oneofdef* def);
44
+ static VALUE get_msgdef_obj(VALUE descriptor_pool, const upb_MessageDef* def);
45
+ static VALUE get_enumdef_obj(VALUE descriptor_pool, const upb_EnumDef* def);
46
+ static VALUE get_fielddef_obj(VALUE descriptor_pool, const upb_FieldDef* def);
47
+ static VALUE get_filedef_obj(VALUE descriptor_pool, const upb_FileDef* def);
48
+ static VALUE get_oneofdef_obj(VALUE descriptor_pool, const upb_OneofDef* def);
49
49
 
50
50
  // A distinct object that is not accessible from Ruby. We use this as a
51
51
  // constructor argument to enforce that certain objects cannot be created from
@@ -74,7 +74,7 @@ static VALUE rb_str_maybe_null(const char* s) {
74
74
 
75
75
  typedef struct {
76
76
  VALUE def_to_descriptor; // Hash table of def* -> Ruby descriptor.
77
- upb_symtab* symtab;
77
+ upb_DefPool* symtab;
78
78
  } DescriptorPool;
79
79
 
80
80
  VALUE cDescriptorPool = Qnil;
@@ -90,14 +90,14 @@ static void DescriptorPool_mark(void* _self) {
90
90
 
91
91
  static void DescriptorPool_free(void* _self) {
92
92
  DescriptorPool* self = _self;
93
- upb_symtab_free(self->symtab);
93
+ upb_DefPool_Free(self->symtab);
94
94
  xfree(self);
95
95
  }
96
96
 
97
97
  static const rb_data_type_t DescriptorPool_type = {
98
- "Google::Protobuf::DescriptorPool",
99
- {DescriptorPool_mark, DescriptorPool_free, NULL},
100
- .flags = RUBY_TYPED_FREE_IMMEDIATELY,
98
+ "Google::Protobuf::DescriptorPool",
99
+ {DescriptorPool_mark, DescriptorPool_free, NULL},
100
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
101
101
  };
102
102
 
103
103
  static DescriptorPool* ruby_to_DescriptorPool(VALUE val) {
@@ -107,8 +107,8 @@ static DescriptorPool* ruby_to_DescriptorPool(VALUE val) {
107
107
  }
108
108
 
109
109
  // Exposed to other modules in defs.h.
110
- const upb_symtab *DescriptorPool_GetSymtab(VALUE desc_pool_rb) {
111
- DescriptorPool *pool = ruby_to_DescriptorPool(desc_pool_rb);
110
+ const upb_DefPool* DescriptorPool_GetSymtab(VALUE desc_pool_rb) {
111
+ DescriptorPool* pool = ruby_to_DescriptorPool(desc_pool_rb);
112
112
  return pool->symtab;
113
113
  }
114
114
 
@@ -126,7 +126,7 @@ static VALUE DescriptorPool_alloc(VALUE klass) {
126
126
  ret = TypedData_Wrap_Struct(klass, &DescriptorPool_type, self);
127
127
 
128
128
  self->def_to_descriptor = rb_hash_new();
129
- self->symtab = upb_symtab_new();
129
+ self->symtab = upb_DefPool_New();
130
130
  ObjectCache_Add(self->symtab, ret);
131
131
 
132
132
  return ret;
@@ -143,7 +143,7 @@ VALUE DescriptorPool_add_serialized_file(VALUE _self,
143
143
  DescriptorPool* self = ruby_to_DescriptorPool(_self);
144
144
  Check_Type(serialized_file_proto, T_STRING);
145
145
  VALUE arena_rb = Arena_new();
146
- upb_arena *arena = Arena_get(arena_rb);
146
+ upb_Arena* arena = Arena_get(arena_rb);
147
147
  google_protobuf_FileDescriptorProto* file_proto =
148
148
  google_protobuf_FileDescriptorProto_parse(
149
149
  RSTRING_PTR(serialized_file_proto),
@@ -151,13 +151,13 @@ VALUE DescriptorPool_add_serialized_file(VALUE _self,
151
151
  if (!file_proto) {
152
152
  rb_raise(rb_eArgError, "Unable to parse FileDescriptorProto");
153
153
  }
154
- upb_status status;
155
- upb_status_clear(&status);
156
- const upb_filedef* filedef =
157
- upb_symtab_addfile(self->symtab, file_proto, &status);
154
+ upb_Status status;
155
+ upb_Status_Clear(&status);
156
+ const upb_FileDef* filedef =
157
+ upb_DefPool_AddFile(self->symtab, file_proto, &status);
158
158
  if (!filedef) {
159
159
  rb_raise(cTypeError, "Unable to build file to DescriptorPool: %s",
160
- upb_status_errmsg(&status));
160
+ upb_Status_ErrorMessage(&status));
161
161
  }
162
162
  return get_filedef_obj(_self, filedef);
163
163
  }
@@ -172,15 +172,15 @@ VALUE DescriptorPool_add_serialized_file(VALUE _self,
172
172
  static VALUE DescriptorPool_lookup(VALUE _self, VALUE name) {
173
173
  DescriptorPool* self = ruby_to_DescriptorPool(_self);
174
174
  const char* name_str = get_str(name);
175
- const upb_msgdef* msgdef;
176
- const upb_enumdef* enumdef;
175
+ const upb_MessageDef* msgdef;
176
+ const upb_EnumDef* enumdef;
177
177
 
178
- msgdef = upb_symtab_lookupmsg(self->symtab, name_str);
178
+ msgdef = upb_DefPool_FindMessageByName(self->symtab, name_str);
179
179
  if (msgdef) {
180
180
  return get_msgdef_obj(_self, msgdef);
181
181
  }
182
182
 
183
- enumdef = upb_symtab_lookupenum(self->symtab, name_str);
183
+ enumdef = upb_DefPool_FindEnumByName(self->symtab, name_str);
184
184
  if (enumdef) {
185
185
  return get_enumdef_obj(_self, enumdef);
186
186
  }
@@ -202,8 +202,7 @@ static VALUE DescriptorPool_generated_pool(VALUE _self) {
202
202
  }
203
203
 
204
204
  static void DescriptorPool_register(VALUE module) {
205
- VALUE klass = rb_define_class_under(
206
- module, "DescriptorPool", rb_cObject);
205
+ VALUE klass = rb_define_class_under(module, "DescriptorPool", rb_cObject);
207
206
  rb_define_alloc_func(klass, DescriptorPool_alloc);
208
207
  rb_define_method(klass, "add_serialized_file",
209
208
  DescriptorPool_add_serialized_file, 1);
@@ -222,7 +221,7 @@ static void DescriptorPool_register(VALUE module) {
222
221
  // -----------------------------------------------------------------------------
223
222
 
224
223
  typedef struct {
225
- const upb_msgdef* msgdef;
224
+ const upb_MessageDef* msgdef;
226
225
  VALUE klass;
227
226
  VALUE descriptor_pool;
228
227
  } Descriptor;
@@ -236,9 +235,9 @@ static void Descriptor_mark(void* _self) {
236
235
  }
237
236
 
238
237
  static const rb_data_type_t Descriptor_type = {
239
- "Google::Protobuf::Descriptor",
240
- {Descriptor_mark, RUBY_DEFAULT_FREE, NULL},
241
- .flags = RUBY_TYPED_FREE_IMMEDIATELY,
238
+ "Google::Protobuf::Descriptor",
239
+ {Descriptor_mark, RUBY_DEFAULT_FREE, NULL},
240
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
242
241
  };
243
242
 
244
243
  static Descriptor* ruby_to_Descriptor(VALUE val) {
@@ -281,7 +280,7 @@ static VALUE Descriptor_initialize(VALUE _self, VALUE cookie,
281
280
  }
282
281
 
283
282
  self->descriptor_pool = descriptor_pool;
284
- self->msgdef = (const upb_msgdef*)NUM2ULL(ptr);
283
+ self->msgdef = (const upb_MessageDef*)NUM2ULL(ptr);
285
284
 
286
285
  return Qnil;
287
286
  }
@@ -294,7 +293,8 @@ static VALUE Descriptor_initialize(VALUE _self, VALUE cookie,
294
293
  */
295
294
  static VALUE Descriptor_file_descriptor(VALUE _self) {
296
295
  Descriptor* self = ruby_to_Descriptor(_self);
297
- return get_filedef_obj(self->descriptor_pool, upb_msgdef_file(self->msgdef));
296
+ return get_filedef_obj(self->descriptor_pool,
297
+ upb_MessageDef_File(self->msgdef));
298
298
  }
299
299
 
300
300
  /*
@@ -306,7 +306,7 @@ static VALUE Descriptor_file_descriptor(VALUE _self) {
306
306
  */
307
307
  static VALUE Descriptor_name(VALUE _self) {
308
308
  Descriptor* self = ruby_to_Descriptor(_self);
309
- return rb_str_maybe_null(upb_msgdef_fullname(self->msgdef));
309
+ return rb_str_maybe_null(upb_MessageDef_FullName(self->msgdef));
310
310
  }
311
311
 
312
312
  /*
@@ -318,11 +318,9 @@ static VALUE Descriptor_name(VALUE _self) {
318
318
  static VALUE Descriptor_each(VALUE _self) {
319
319
  Descriptor* self = ruby_to_Descriptor(_self);
320
320
 
321
- upb_msg_field_iter it;
322
- for (upb_msg_field_begin(&it, self->msgdef);
323
- !upb_msg_field_done(&it);
324
- upb_msg_field_next(&it)) {
325
- const upb_fielddef* field = upb_msg_iter_field(&it);
321
+ int n = upb_MessageDef_FieldCount(self->msgdef);
322
+ for (int i = 0; i < n; i++) {
323
+ const upb_FieldDef* field = upb_MessageDef_Field(self->msgdef, i);
326
324
  VALUE obj = get_fielddef_obj(self->descriptor_pool, field);
327
325
  rb_yield(obj);
328
326
  }
@@ -339,7 +337,7 @@ static VALUE Descriptor_each(VALUE _self) {
339
337
  static VALUE Descriptor_lookup(VALUE _self, VALUE name) {
340
338
  Descriptor* self = ruby_to_Descriptor(_self);
341
339
  const char* s = get_str(name);
342
- const upb_fielddef* field = upb_msgdef_ntofz(self->msgdef, s);
340
+ const upb_FieldDef* field = upb_MessageDef_FindFieldByName(self->msgdef, s);
343
341
  if (field == NULL) {
344
342
  return Qnil;
345
343
  }
@@ -356,11 +354,9 @@ static VALUE Descriptor_lookup(VALUE _self, VALUE name) {
356
354
  static VALUE Descriptor_each_oneof(VALUE _self) {
357
355
  Descriptor* self = ruby_to_Descriptor(_self);
358
356
 
359
- upb_msg_oneof_iter it;
360
- for (upb_msg_oneof_begin(&it, self->msgdef);
361
- !upb_msg_oneof_done(&it);
362
- upb_msg_oneof_next(&it)) {
363
- const upb_oneofdef* oneof = upb_msg_iter_oneof(&it);
357
+ int n = upb_MessageDef_OneofCount(self->msgdef);
358
+ for (int i = 0; i < n; i++) {
359
+ const upb_OneofDef* oneof = upb_MessageDef_Oneof(self->msgdef, i);
364
360
  VALUE obj = get_oneofdef_obj(self->descriptor_pool, oneof);
365
361
  rb_yield(obj);
366
362
  }
@@ -377,7 +373,7 @@ static VALUE Descriptor_each_oneof(VALUE _self) {
377
373
  static VALUE Descriptor_lookup_oneof(VALUE _self, VALUE name) {
378
374
  Descriptor* self = ruby_to_Descriptor(_self);
379
375
  const char* s = get_str(name);
380
- const upb_oneofdef* oneof = upb_msgdef_ntooz(self->msgdef, s);
376
+ const upb_OneofDef* oneof = upb_MessageDef_FindOneofByName(self->msgdef, s);
381
377
  if (oneof == NULL) {
382
378
  return Qnil;
383
379
  }
@@ -399,8 +395,7 @@ static VALUE Descriptor_msgclass(VALUE _self) {
399
395
  }
400
396
 
401
397
  static void Descriptor_register(VALUE module) {
402
- VALUE klass = rb_define_class_under(
403
- module, "Descriptor", rb_cObject);
398
+ VALUE klass = rb_define_class_under(module, "Descriptor", rb_cObject);
404
399
  rb_define_alloc_func(klass, Descriptor_alloc);
405
400
  rb_define_method(klass, "initialize", Descriptor_initialize, 3);
406
401
  rb_define_method(klass, "each", Descriptor_each, 0);
@@ -420,8 +415,8 @@ static void Descriptor_register(VALUE module) {
420
415
  // -----------------------------------------------------------------------------
421
416
 
422
417
  typedef struct {
423
- const upb_filedef* filedef;
424
- VALUE descriptor_pool; // Owns the upb_filedef.
418
+ const upb_FileDef* filedef;
419
+ VALUE descriptor_pool; // Owns the upb_FileDef.
425
420
  } FileDescriptor;
426
421
 
427
422
  static VALUE cFileDescriptor = Qnil;
@@ -432,9 +427,9 @@ static void FileDescriptor_mark(void* _self) {
432
427
  }
433
428
 
434
429
  static const rb_data_type_t FileDescriptor_type = {
435
- "Google::Protobuf::FileDescriptor",
436
- {FileDescriptor_mark, RUBY_DEFAULT_FREE, NULL},
437
- .flags = RUBY_TYPED_FREE_IMMEDIATELY,
430
+ "Google::Protobuf::FileDescriptor",
431
+ {FileDescriptor_mark, RUBY_DEFAULT_FREE, NULL},
432
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
438
433
  };
439
434
 
440
435
  static FileDescriptor* ruby_to_FileDescriptor(VALUE val) {
@@ -459,7 +454,7 @@ static VALUE FileDescriptor_alloc(VALUE klass) {
459
454
  * to a builder.
460
455
  */
461
456
  static VALUE FileDescriptor_initialize(VALUE _self, VALUE cookie,
462
- VALUE descriptor_pool, VALUE ptr) {
457
+ VALUE descriptor_pool, VALUE ptr) {
463
458
  FileDescriptor* self = ruby_to_FileDescriptor(_self);
464
459
 
465
460
  if (cookie != c_only_cookie) {
@@ -468,7 +463,7 @@ static VALUE FileDescriptor_initialize(VALUE _self, VALUE cookie,
468
463
  }
469
464
 
470
465
  self->descriptor_pool = descriptor_pool;
471
- self->filedef = (const upb_filedef*)NUM2ULL(ptr);
466
+ self->filedef = (const upb_FileDef*)NUM2ULL(ptr);
472
467
 
473
468
  return Qnil;
474
469
  }
@@ -481,7 +476,7 @@ static VALUE FileDescriptor_initialize(VALUE _self, VALUE cookie,
481
476
  */
482
477
  static VALUE FileDescriptor_name(VALUE _self) {
483
478
  FileDescriptor* self = ruby_to_FileDescriptor(_self);
484
- const char* name = upb_filedef_name(self->filedef);
479
+ const char* name = upb_FileDef_Name(self->filedef);
485
480
  return name == NULL ? Qnil : rb_str_new2(name);
486
481
  }
487
482
 
@@ -497,16 +492,18 @@ static VALUE FileDescriptor_name(VALUE _self) {
497
492
  static VALUE FileDescriptor_syntax(VALUE _self) {
498
493
  FileDescriptor* self = ruby_to_FileDescriptor(_self);
499
494
 
500
- switch (upb_filedef_syntax(self->filedef)) {
501
- case UPB_SYNTAX_PROTO3: return ID2SYM(rb_intern("proto3"));
502
- case UPB_SYNTAX_PROTO2: return ID2SYM(rb_intern("proto2"));
503
- default: return Qnil;
495
+ switch (upb_FileDef_Syntax(self->filedef)) {
496
+ case kUpb_Syntax_Proto3:
497
+ return ID2SYM(rb_intern("proto3"));
498
+ case kUpb_Syntax_Proto2:
499
+ return ID2SYM(rb_intern("proto2"));
500
+ default:
501
+ return Qnil;
504
502
  }
505
503
  }
506
504
 
507
505
  static void FileDescriptor_register(VALUE module) {
508
- VALUE klass = rb_define_class_under(
509
- module, "FileDescriptor", rb_cObject);
506
+ VALUE klass = rb_define_class_under(module, "FileDescriptor", rb_cObject);
510
507
  rb_define_alloc_func(klass, FileDescriptor_alloc);
511
508
  rb_define_method(klass, "initialize", FileDescriptor_initialize, 3);
512
509
  rb_define_method(klass, "name", FileDescriptor_name, 0);
@@ -520,8 +517,8 @@ static void FileDescriptor_register(VALUE module) {
520
517
  // -----------------------------------------------------------------------------
521
518
 
522
519
  typedef struct {
523
- const upb_fielddef* fielddef;
524
- VALUE descriptor_pool; // Owns the upb_fielddef.
520
+ const upb_FieldDef* fielddef;
521
+ VALUE descriptor_pool; // Owns the upb_FieldDef.
525
522
  } FieldDescriptor;
526
523
 
527
524
  static VALUE cFieldDescriptor = Qnil;
@@ -532,9 +529,9 @@ static void FieldDescriptor_mark(void* _self) {
532
529
  }
533
530
 
534
531
  static const rb_data_type_t FieldDescriptor_type = {
535
- "Google::Protobuf::FieldDescriptor",
536
- {FieldDescriptor_mark, RUBY_DEFAULT_FREE, NULL},
537
- .flags = RUBY_TYPED_FREE_IMMEDIATELY,
532
+ "Google::Protobuf::FieldDescriptor",
533
+ {FieldDescriptor_mark, RUBY_DEFAULT_FREE, NULL},
534
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
538
535
  };
539
536
 
540
537
  static FieldDescriptor* ruby_to_FieldDescriptor(VALUE val) {
@@ -573,7 +570,7 @@ static VALUE FieldDescriptor_initialize(VALUE _self, VALUE cookie,
573
570
  }
574
571
 
575
572
  self->descriptor_pool = descriptor_pool;
576
- self->fielddef = (const upb_fielddef*)NUM2ULL(ptr);
573
+ self->fielddef = (const upb_FieldDef*)NUM2ULL(ptr);
577
574
 
578
575
  return Qnil;
579
576
  }
@@ -586,31 +583,31 @@ static VALUE FieldDescriptor_initialize(VALUE _self, VALUE cookie,
586
583
  */
587
584
  static VALUE FieldDescriptor_name(VALUE _self) {
588
585
  FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
589
- return rb_str_maybe_null(upb_fielddef_name(self->fielddef));
586
+ return rb_str_maybe_null(upb_FieldDef_Name(self->fielddef));
590
587
  }
591
588
 
592
589
  // Non-static, exposed to other .c files.
593
- upb_fieldtype_t ruby_to_fieldtype(VALUE type) {
590
+ upb_CType ruby_to_fieldtype(VALUE type) {
594
591
  if (TYPE(type) != T_SYMBOL) {
595
592
  rb_raise(rb_eArgError, "Expected symbol for field type.");
596
593
  }
597
594
 
598
- #define CONVERT(upb, ruby) \
599
- if (SYM2ID(type) == rb_intern( # ruby )) { \
600
- return UPB_TYPE_ ## upb; \
595
+ #define CONVERT(upb, ruby) \
596
+ if (SYM2ID(type) == rb_intern(#ruby)) { \
597
+ return kUpb_CType_##upb; \
601
598
  }
602
599
 
603
- CONVERT(FLOAT, float);
604
- CONVERT(DOUBLE, double);
605
- CONVERT(BOOL, bool);
606
- CONVERT(STRING, string);
607
- CONVERT(BYTES, bytes);
608
- CONVERT(MESSAGE, message);
609
- CONVERT(ENUM, enum);
610
- CONVERT(INT32, int32);
611
- CONVERT(INT64, int64);
612
- CONVERT(UINT32, uint32);
613
- CONVERT(UINT64, uint64);
600
+ CONVERT(Float, float);
601
+ CONVERT(Double, double);
602
+ CONVERT(Bool, bool);
603
+ CONVERT(String, string);
604
+ CONVERT(Bytes, bytes);
605
+ CONVERT(Message, message);
606
+ CONVERT(Enum, enum);
607
+ CONVERT(Int32, int32);
608
+ CONVERT(Int64, int64);
609
+ CONVERT(UInt32, uint32);
610
+ CONVERT(UInt64, uint64);
614
611
 
615
612
  #undef CONVERT
616
613
 
@@ -618,28 +615,29 @@ upb_fieldtype_t ruby_to_fieldtype(VALUE type) {
618
615
  return 0;
619
616
  }
620
617
 
621
- static VALUE descriptortype_to_ruby(upb_descriptortype_t type) {
618
+ static VALUE descriptortype_to_ruby(upb_FieldType type) {
622
619
  switch (type) {
623
- #define CONVERT(upb, ruby) \
624
- case UPB_DESCRIPTOR_TYPE_ ## upb : return ID2SYM(rb_intern( # ruby ));
625
- CONVERT(FLOAT, float);
626
- CONVERT(DOUBLE, double);
627
- CONVERT(BOOL, bool);
628
- CONVERT(STRING, string);
629
- CONVERT(BYTES, bytes);
630
- CONVERT(MESSAGE, message);
631
- CONVERT(GROUP, group);
632
- CONVERT(ENUM, enum);
633
- CONVERT(INT32, int32);
634
- CONVERT(INT64, int64);
635
- CONVERT(UINT32, uint32);
636
- CONVERT(UINT64, uint64);
637
- CONVERT(SINT32, sint32);
638
- CONVERT(SINT64, sint64);
639
- CONVERT(FIXED32, fixed32);
640
- CONVERT(FIXED64, fixed64);
641
- CONVERT(SFIXED32, sfixed32);
642
- CONVERT(SFIXED64, sfixed64);
620
+ #define CONVERT(upb, ruby) \
621
+ case kUpb_FieldType_##upb: \
622
+ return ID2SYM(rb_intern(#ruby));
623
+ CONVERT(Float, float);
624
+ CONVERT(Double, double);
625
+ CONVERT(Bool, bool);
626
+ CONVERT(String, string);
627
+ CONVERT(Bytes, bytes);
628
+ CONVERT(Message, message);
629
+ CONVERT(Group, group);
630
+ CONVERT(Enum, enum);
631
+ CONVERT(Int32, int32);
632
+ CONVERT(Int64, int64);
633
+ CONVERT(UInt32, uint32);
634
+ CONVERT(UInt64, uint64);
635
+ CONVERT(SInt32, sint32);
636
+ CONVERT(SInt64, sint64);
637
+ CONVERT(Fixed32, fixed32);
638
+ CONVERT(Fixed64, fixed64);
639
+ CONVERT(SFixed32, sfixed32);
640
+ CONVERT(SFixed64, sfixed64);
643
641
  #undef CONVERT
644
642
  }
645
643
  return Qnil;
@@ -657,7 +655,7 @@ static VALUE descriptortype_to_ruby(upb_descriptortype_t type) {
657
655
  */
658
656
  static VALUE FieldDescriptor__type(VALUE _self) {
659
657
  FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
660
- return descriptortype_to_ruby(upb_fielddef_descriptortype(self->fielddef));
658
+ return descriptortype_to_ruby(upb_FieldDef_Type(self->fielddef));
661
659
  }
662
660
 
663
661
  /*
@@ -668,17 +666,16 @@ static VALUE FieldDescriptor__type(VALUE _self) {
668
666
  */
669
667
  static VALUE FieldDescriptor_default(VALUE _self) {
670
668
  FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
671
- const upb_fielddef *f = self->fielddef;
672
- upb_msgval default_val = {0};
673
- if (upb_fielddef_issubmsg(f)) {
669
+ const upb_FieldDef* f = self->fielddef;
670
+ upb_MessageValue default_val = {0};
671
+ if (upb_FieldDef_IsSubMessage(f)) {
674
672
  return Qnil;
675
- } else if (!upb_fielddef_isseq(f)) {
676
- default_val = upb_fielddef_default(f);
673
+ } else if (!upb_FieldDef_IsRepeated(f)) {
674
+ default_val = upb_FieldDef_Default(f);
677
675
  }
678
676
  return Convert_UpbToRuby(default_val, TypeInfo_get(self->fielddef), Qnil);
679
677
  }
680
678
 
681
-
682
679
  /*
683
680
  * call-seq:
684
681
  * FieldDescriptor.json_name => json_name
@@ -687,8 +684,8 @@ static VALUE FieldDescriptor_default(VALUE _self) {
687
684
  */
688
685
  static VALUE FieldDescriptor_json_name(VALUE _self) {
689
686
  FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
690
- const upb_fielddef *f = self->fielddef;
691
- const char *json_name = upb_fielddef_jsonname(f);
687
+ const upb_FieldDef* f = self->fielddef;
688
+ const char* json_name = upb_FieldDef_JsonName(f);
692
689
  return rb_str_new2(json_name);
693
690
  }
694
691
 
@@ -703,13 +700,14 @@ static VALUE FieldDescriptor_json_name(VALUE _self) {
703
700
  */
704
701
  static VALUE FieldDescriptor_label(VALUE _self) {
705
702
  FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
706
- switch (upb_fielddef_label(self->fielddef)) {
707
- #define CONVERT(upb, ruby) \
708
- case UPB_LABEL_ ## upb : return ID2SYM(rb_intern( # ruby ));
703
+ switch (upb_FieldDef_Label(self->fielddef)) {
704
+ #define CONVERT(upb, ruby) \
705
+ case kUpb_Label_##upb: \
706
+ return ID2SYM(rb_intern(#ruby));
709
707
 
710
- CONVERT(OPTIONAL, optional);
711
- CONVERT(REQUIRED, required);
712
- CONVERT(REPEATED, repeated);
708
+ CONVERT(Optional, optional);
709
+ CONVERT(Required, required);
710
+ CONVERT(Repeated, repeated);
713
711
 
714
712
  #undef CONVERT
715
713
  }
@@ -725,7 +723,7 @@ static VALUE FieldDescriptor_label(VALUE _self) {
725
723
  */
726
724
  static VALUE FieldDescriptor_number(VALUE _self) {
727
725
  FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
728
- return INT2NUM(upb_fielddef_number(self->fielddef));
726
+ return INT2NUM(upb_FieldDef_Number(self->fielddef));
729
727
  }
730
728
 
731
729
  /*
@@ -739,13 +737,13 @@ static VALUE FieldDescriptor_number(VALUE _self) {
739
737
  */
740
738
  static VALUE FieldDescriptor_submsg_name(VALUE _self) {
741
739
  FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
742
- switch (upb_fielddef_type(self->fielddef)) {
743
- case UPB_TYPE_ENUM:
740
+ switch (upb_FieldDef_CType(self->fielddef)) {
741
+ case kUpb_CType_Enum:
744
742
  return rb_str_new2(
745
- upb_enumdef_fullname(upb_fielddef_enumsubdef(self->fielddef)));
746
- case UPB_TYPE_MESSAGE:
743
+ upb_EnumDef_FullName(upb_FieldDef_EnumSubDef(self->fielddef)));
744
+ case kUpb_CType_Message:
747
745
  return rb_str_new2(
748
- upb_msgdef_fullname(upb_fielddef_msgsubdef(self->fielddef)));
746
+ upb_MessageDef_FullName(upb_FieldDef_MessageSubDef(self->fielddef)));
749
747
  default:
750
748
  return Qnil;
751
749
  }
@@ -762,13 +760,13 @@ static VALUE FieldDescriptor_submsg_name(VALUE _self) {
762
760
  */
763
761
  static VALUE FieldDescriptor_subtype(VALUE _self) {
764
762
  FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
765
- switch (upb_fielddef_type(self->fielddef)) {
766
- case UPB_TYPE_ENUM:
763
+ switch (upb_FieldDef_CType(self->fielddef)) {
764
+ case kUpb_CType_Enum:
767
765
  return get_enumdef_obj(self->descriptor_pool,
768
- upb_fielddef_enumsubdef(self->fielddef));
769
- case UPB_TYPE_MESSAGE:
766
+ upb_FieldDef_EnumSubDef(self->fielddef));
767
+ case kUpb_CType_Message:
770
768
  return get_msgdef_obj(self->descriptor_pool,
771
- upb_fielddef_msgsubdef(self->fielddef));
769
+ upb_FieldDef_MessageSubDef(self->fielddef));
772
770
  default:
773
771
  return Qnil;
774
772
  }
@@ -783,11 +781,11 @@ static VALUE FieldDescriptor_subtype(VALUE _self) {
783
781
  */
784
782
  static VALUE FieldDescriptor_get(VALUE _self, VALUE msg_rb) {
785
783
  FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
786
- const upb_msgdef *m;
784
+ const upb_MessageDef* m;
787
785
 
788
786
  Message_Get(msg_rb, &m);
789
787
 
790
- if (m != upb_fielddef_containingtype(self->fielddef)) {
788
+ if (m != upb_FieldDef_ContainingType(self->fielddef)) {
791
789
  rb_raise(cTypeError, "get method called on wrong message type");
792
790
  }
793
791
 
@@ -803,16 +801,16 @@ static VALUE FieldDescriptor_get(VALUE _self, VALUE msg_rb) {
803
801
  */
804
802
  static VALUE FieldDescriptor_has(VALUE _self, VALUE msg_rb) {
805
803
  FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
806
- const upb_msgdef *m;
807
- const upb_msgdef *msg = Message_Get(msg_rb, &m);
804
+ const upb_MessageDef* m;
805
+ const upb_MessageDef* msg = Message_Get(msg_rb, &m);
808
806
 
809
- if (m != upb_fielddef_containingtype(self->fielddef)) {
807
+ if (m != upb_FieldDef_ContainingType(self->fielddef)) {
810
808
  rb_raise(cTypeError, "has method called on wrong message type");
811
- } else if (!upb_fielddef_haspresence(self->fielddef)) {
809
+ } else if (!upb_FieldDef_HasPresence(self->fielddef)) {
812
810
  rb_raise(rb_eArgError, "does not track presence");
813
811
  }
814
812
 
815
- return upb_msg_has(msg, self->fielddef) ? Qtrue : Qfalse;
813
+ return upb_Message_Has(msg, self->fielddef) ? Qtrue : Qfalse;
816
814
  }
817
815
 
818
816
  /*
@@ -823,14 +821,14 @@ static VALUE FieldDescriptor_has(VALUE _self, VALUE msg_rb) {
823
821
  */
824
822
  static VALUE FieldDescriptor_clear(VALUE _self, VALUE msg_rb) {
825
823
  FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
826
- const upb_msgdef *m;
827
- upb_msgdef *msg = Message_GetMutable(msg_rb, &m);
824
+ const upb_MessageDef* m;
825
+ upb_MessageDef* msg = Message_GetMutable(msg_rb, &m);
828
826
 
829
- if (m != upb_fielddef_containingtype(self->fielddef)) {
827
+ if (m != upb_FieldDef_ContainingType(self->fielddef)) {
830
828
  rb_raise(cTypeError, "has method called on wrong message type");
831
829
  }
832
830
 
833
- upb_msg_clearfield(msg, self->fielddef);
831
+ upb_Message_ClearField(msg, self->fielddef);
834
832
  return Qnil;
835
833
  }
836
834
 
@@ -844,24 +842,23 @@ static VALUE FieldDescriptor_clear(VALUE _self, VALUE msg_rb) {
844
842
  */
845
843
  static VALUE FieldDescriptor_set(VALUE _self, VALUE msg_rb, VALUE value) {
846
844
  FieldDescriptor* self = ruby_to_FieldDescriptor(_self);
847
- const upb_msgdef *m;
848
- upb_msgdef *msg = Message_GetMutable(msg_rb, &m);
849
- upb_arena *arena = Arena_get(Message_GetArena(msg_rb));
850
- upb_msgval msgval;
845
+ const upb_MessageDef* m;
846
+ upb_MessageDef* msg = Message_GetMutable(msg_rb, &m);
847
+ upb_Arena* arena = Arena_get(Message_GetArena(msg_rb));
848
+ upb_MessageValue msgval;
851
849
 
852
- if (m != upb_fielddef_containingtype(self->fielddef)) {
850
+ if (m != upb_FieldDef_ContainingType(self->fielddef)) {
853
851
  rb_raise(cTypeError, "set method called on wrong message type");
854
852
  }
855
853
 
856
- msgval = Convert_RubyToUpb(value, upb_fielddef_name(self->fielddef),
854
+ msgval = Convert_RubyToUpb(value, upb_FieldDef_Name(self->fielddef),
857
855
  TypeInfo_get(self->fielddef), arena);
858
- upb_msg_set(msg, self->fielddef, msgval, arena);
856
+ upb_Message_Set(msg, self->fielddef, msgval, arena);
859
857
  return Qnil;
860
858
  }
861
859
 
862
860
  static void FieldDescriptor_register(VALUE module) {
863
- VALUE klass = rb_define_class_under(
864
- module, "FieldDescriptor", rb_cObject);
861
+ VALUE klass = rb_define_class_under(module, "FieldDescriptor", rb_cObject);
865
862
  rb_define_alloc_func(klass, FieldDescriptor_alloc);
866
863
  rb_define_method(klass, "initialize", FieldDescriptor_initialize, 3);
867
864
  rb_define_method(klass, "name", FieldDescriptor_name, 0);
@@ -885,8 +882,8 @@ static void FieldDescriptor_register(VALUE module) {
885
882
  // -----------------------------------------------------------------------------
886
883
 
887
884
  typedef struct {
888
- const upb_oneofdef* oneofdef;
889
- VALUE descriptor_pool; // Owns the upb_oneofdef.
885
+ const upb_OneofDef* oneofdef;
886
+ VALUE descriptor_pool; // Owns the upb_OneofDef.
890
887
  } OneofDescriptor;
891
888
 
892
889
  static VALUE cOneofDescriptor = Qnil;
@@ -930,7 +927,7 @@ static VALUE OneofDescriptor_alloc(VALUE klass) {
930
927
  * Creates a descriptor wrapper object. May only be called from C.
931
928
  */
932
929
  static VALUE OneofDescriptor_initialize(VALUE _self, VALUE cookie,
933
- VALUE descriptor_pool, VALUE ptr) {
930
+ VALUE descriptor_pool, VALUE ptr) {
934
931
  OneofDescriptor* self = ruby_to_OneofDescriptor(_self);
935
932
 
936
933
  if (cookie != c_only_cookie) {
@@ -939,7 +936,7 @@ static VALUE OneofDescriptor_initialize(VALUE _self, VALUE cookie,
939
936
  }
940
937
 
941
938
  self->descriptor_pool = descriptor_pool;
942
- self->oneofdef = (const upb_oneofdef*)NUM2ULL(ptr);
939
+ self->oneofdef = (const upb_OneofDef*)NUM2ULL(ptr);
943
940
 
944
941
  return Qnil;
945
942
  }
@@ -952,7 +949,7 @@ static VALUE OneofDescriptor_initialize(VALUE _self, VALUE cookie,
952
949
  */
953
950
  static VALUE OneofDescriptor_name(VALUE _self) {
954
951
  OneofDescriptor* self = ruby_to_OneofDescriptor(_self);
955
- return rb_str_maybe_null(upb_oneofdef_name(self->oneofdef));
952
+ return rb_str_maybe_null(upb_OneofDef_Name(self->oneofdef));
956
953
  }
957
954
 
958
955
  /*
@@ -963,11 +960,10 @@ static VALUE OneofDescriptor_name(VALUE _self) {
963
960
  */
964
961
  static VALUE OneofDescriptor_each(VALUE _self) {
965
962
  OneofDescriptor* self = ruby_to_OneofDescriptor(_self);
966
- upb_oneof_iter it;
967
- for (upb_oneof_begin(&it, self->oneofdef);
968
- !upb_oneof_done(&it);
969
- upb_oneof_next(&it)) {
970
- const upb_fielddef* f = upb_oneof_iter_field(&it);
963
+
964
+ int n = upb_OneofDef_FieldCount(self->oneofdef);
965
+ for (int i = 0; i < n; i++) {
966
+ const upb_FieldDef* f = upb_OneofDef_Field(self->oneofdef, i);
971
967
  VALUE obj = get_fielddef_obj(self->descriptor_pool, f);
972
968
  rb_yield(obj);
973
969
  }
@@ -975,8 +971,7 @@ static VALUE OneofDescriptor_each(VALUE _self) {
975
971
  }
976
972
 
977
973
  static void OneofDescriptor_register(VALUE module) {
978
- VALUE klass = rb_define_class_under(
979
- module, "OneofDescriptor", rb_cObject);
974
+ VALUE klass = rb_define_class_under(module, "OneofDescriptor", rb_cObject);
980
975
  rb_define_alloc_func(klass, OneofDescriptor_alloc);
981
976
  rb_define_method(klass, "initialize", OneofDescriptor_initialize, 3);
982
977
  rb_define_method(klass, "name", OneofDescriptor_name, 0);
@@ -991,9 +986,9 @@ static void OneofDescriptor_register(VALUE module) {
991
986
  // -----------------------------------------------------------------------------
992
987
 
993
988
  typedef struct {
994
- const upb_enumdef* enumdef;
995
- VALUE module; // begins as nil
996
- VALUE descriptor_pool; // Owns the upb_enumdef.
989
+ const upb_EnumDef* enumdef;
990
+ VALUE module; // begins as nil
991
+ VALUE descriptor_pool; // Owns the upb_EnumDef.
997
992
  } EnumDescriptor;
998
993
 
999
994
  static VALUE cEnumDescriptor = Qnil;
@@ -1005,9 +1000,9 @@ static void EnumDescriptor_mark(void* _self) {
1005
1000
  }
1006
1001
 
1007
1002
  static const rb_data_type_t EnumDescriptor_type = {
1008
- "Google::Protobuf::EnumDescriptor",
1009
- {EnumDescriptor_mark, RUBY_DEFAULT_FREE, NULL},
1010
- .flags = RUBY_TYPED_FREE_IMMEDIATELY,
1003
+ "Google::Protobuf::EnumDescriptor",
1004
+ {EnumDescriptor_mark, RUBY_DEFAULT_FREE, NULL},
1005
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
1011
1006
  };
1012
1007
 
1013
1008
  static EnumDescriptor* ruby_to_EnumDescriptor(VALUE val) {
@@ -1026,8 +1021,8 @@ static VALUE EnumDescriptor_alloc(VALUE klass) {
1026
1021
  }
1027
1022
 
1028
1023
  // Exposed to other modules in defs.h.
1029
- const upb_enumdef *EnumDescriptor_GetEnumDef(VALUE enum_desc_rb) {
1030
- EnumDescriptor *desc = ruby_to_EnumDescriptor(enum_desc_rb);
1024
+ const upb_EnumDef* EnumDescriptor_GetEnumDef(VALUE enum_desc_rb) {
1025
+ EnumDescriptor* desc = ruby_to_EnumDescriptor(enum_desc_rb);
1031
1026
  return desc->enumdef;
1032
1027
  }
1033
1028
 
@@ -1047,7 +1042,7 @@ static VALUE EnumDescriptor_initialize(VALUE _self, VALUE cookie,
1047
1042
  }
1048
1043
 
1049
1044
  self->descriptor_pool = descriptor_pool;
1050
- self->enumdef = (const upb_enumdef*)NUM2ULL(ptr);
1045
+ self->enumdef = (const upb_EnumDef*)NUM2ULL(ptr);
1051
1046
 
1052
1047
  return Qnil;
1053
1048
  }
@@ -1061,7 +1056,7 @@ static VALUE EnumDescriptor_initialize(VALUE _self, VALUE cookie,
1061
1056
  static VALUE EnumDescriptor_file_descriptor(VALUE _self) {
1062
1057
  EnumDescriptor* self = ruby_to_EnumDescriptor(_self);
1063
1058
  return get_filedef_obj(self->descriptor_pool,
1064
- upb_enumdef_file(self->enumdef));
1059
+ upb_EnumDef_File(self->enumdef));
1065
1060
  }
1066
1061
 
1067
1062
  /*
@@ -1072,7 +1067,7 @@ static VALUE EnumDescriptor_file_descriptor(VALUE _self) {
1072
1067
  */
1073
1068
  static VALUE EnumDescriptor_name(VALUE _self) {
1074
1069
  EnumDescriptor* self = ruby_to_EnumDescriptor(_self);
1075
- return rb_str_maybe_null(upb_enumdef_fullname(self->enumdef));
1070
+ return rb_str_maybe_null(upb_EnumDef_FullName(self->enumdef));
1076
1071
  }
1077
1072
 
1078
1073
  /*
@@ -1084,10 +1079,11 @@ static VALUE EnumDescriptor_name(VALUE _self) {
1084
1079
  */
1085
1080
  static VALUE EnumDescriptor_lookup_name(VALUE _self, VALUE name) {
1086
1081
  EnumDescriptor* self = ruby_to_EnumDescriptor(_self);
1087
- const char* name_str= rb_id2name(SYM2ID(name));
1088
- int32_t val = 0;
1089
- if (upb_enumdef_ntoiz(self->enumdef, name_str, &val)) {
1090
- return INT2NUM(val);
1082
+ const char* name_str = rb_id2name(SYM2ID(name));
1083
+ const upb_EnumValueDef *ev =
1084
+ upb_EnumDef_FindValueByName(self->enumdef, name_str);
1085
+ if (ev) {
1086
+ return INT2NUM(upb_EnumValueDef_Number(ev));
1091
1087
  } else {
1092
1088
  return Qnil;
1093
1089
  }
@@ -1103,9 +1099,9 @@ static VALUE EnumDescriptor_lookup_name(VALUE _self, VALUE name) {
1103
1099
  static VALUE EnumDescriptor_lookup_value(VALUE _self, VALUE number) {
1104
1100
  EnumDescriptor* self = ruby_to_EnumDescriptor(_self);
1105
1101
  int32_t val = NUM2INT(number);
1106
- const char* name = upb_enumdef_iton(self->enumdef, val);
1107
- if (name != NULL) {
1108
- return ID2SYM(rb_intern(name));
1102
+ const upb_EnumValueDef* ev = upb_EnumDef_FindValueByNumber(self->enumdef, val);
1103
+ if (ev) {
1104
+ return ID2SYM(rb_intern(upb_EnumValueDef_Name(ev)));
1109
1105
  } else {
1110
1106
  return Qnil;
1111
1107
  }
@@ -1121,12 +1117,11 @@ static VALUE EnumDescriptor_lookup_value(VALUE _self, VALUE number) {
1121
1117
  static VALUE EnumDescriptor_each(VALUE _self) {
1122
1118
  EnumDescriptor* self = ruby_to_EnumDescriptor(_self);
1123
1119
 
1124
- upb_enum_iter it;
1125
- for (upb_enum_begin(&it, self->enumdef);
1126
- !upb_enum_done(&it);
1127
- upb_enum_next(&it)) {
1128
- VALUE key = ID2SYM(rb_intern(upb_enum_iter_name(&it)));
1129
- VALUE number = INT2NUM(upb_enum_iter_number(&it));
1120
+ int n = upb_EnumDef_ValueCount(self->enumdef);
1121
+ for (int i = 0; i < n; i++) {
1122
+ const upb_EnumValueDef* ev = upb_EnumDef_Value(self->enumdef, i);
1123
+ VALUE key = ID2SYM(rb_intern(upb_EnumValueDef_Name(ev)));
1124
+ VALUE number = INT2NUM(upb_EnumValueDef_Number(ev));
1130
1125
  rb_yield_values(2, key, number);
1131
1126
  }
1132
1127
 
@@ -1148,8 +1143,7 @@ static VALUE EnumDescriptor_enummodule(VALUE _self) {
1148
1143
  }
1149
1144
 
1150
1145
  static void EnumDescriptor_register(VALUE module) {
1151
- VALUE klass = rb_define_class_under(
1152
- module, "EnumDescriptor", rb_cObject);
1146
+ VALUE klass = rb_define_class_under(module, "EnumDescriptor", rb_cObject);
1153
1147
  rb_define_alloc_func(klass, EnumDescriptor_alloc);
1154
1148
  rb_define_method(klass, "initialize", EnumDescriptor_initialize, 3);
1155
1149
  rb_define_method(klass, "name", EnumDescriptor_name, 0);
@@ -1176,7 +1170,7 @@ static VALUE get_def_obj(VALUE _descriptor_pool, const void* ptr, VALUE klass) {
1176
1170
 
1177
1171
  if (def == Qnil) {
1178
1172
  // Lazily create wrapper object.
1179
- VALUE args[3] = { c_only_cookie, _descriptor_pool, key };
1173
+ VALUE args[3] = {c_only_cookie, _descriptor_pool, key};
1180
1174
  def = rb_class_new_instance(3, args, klass);
1181
1175
  rb_hash_aset(descriptor_pool->def_to_descriptor, key, def);
1182
1176
  }
@@ -1184,23 +1178,23 @@ static VALUE get_def_obj(VALUE _descriptor_pool, const void* ptr, VALUE klass) {
1184
1178
  return def;
1185
1179
  }
1186
1180
 
1187
- static VALUE get_msgdef_obj(VALUE descriptor_pool, const upb_msgdef* def) {
1181
+ static VALUE get_msgdef_obj(VALUE descriptor_pool, const upb_MessageDef* def) {
1188
1182
  return get_def_obj(descriptor_pool, def, cDescriptor);
1189
1183
  }
1190
1184
 
1191
- static VALUE get_enumdef_obj(VALUE descriptor_pool, const upb_enumdef* def) {
1185
+ static VALUE get_enumdef_obj(VALUE descriptor_pool, const upb_EnumDef* def) {
1192
1186
  return get_def_obj(descriptor_pool, def, cEnumDescriptor);
1193
1187
  }
1194
1188
 
1195
- static VALUE get_fielddef_obj(VALUE descriptor_pool, const upb_fielddef* def) {
1189
+ static VALUE get_fielddef_obj(VALUE descriptor_pool, const upb_FieldDef* def) {
1196
1190
  return get_def_obj(descriptor_pool, def, cFieldDescriptor);
1197
1191
  }
1198
1192
 
1199
- static VALUE get_filedef_obj(VALUE descriptor_pool, const upb_filedef* def) {
1193
+ static VALUE get_filedef_obj(VALUE descriptor_pool, const upb_FileDef* def) {
1200
1194
  return get_def_obj(descriptor_pool, def, cFileDescriptor);
1201
1195
  }
1202
1196
 
1203
- static VALUE get_oneofdef_obj(VALUE descriptor_pool, const upb_oneofdef* def) {
1197
+ static VALUE get_oneofdef_obj(VALUE descriptor_pool, const upb_OneofDef* def) {
1204
1198
  return get_def_obj(descriptor_pool, def, cOneofDescriptor);
1205
1199
  }
1206
1200
 
@@ -1210,8 +1204,8 @@ static VALUE get_oneofdef_obj(VALUE descriptor_pool, const upb_oneofdef* def) {
1210
1204
 
1211
1205
  // Functions exposed to other modules in defs.h.
1212
1206
 
1213
- VALUE Descriptor_DefToClass(const upb_msgdef *m) {
1214
- const upb_symtab *symtab = upb_filedef_symtab(upb_msgdef_file(m));
1207
+ VALUE Descriptor_DefToClass(const upb_MessageDef* m) {
1208
+ const upb_DefPool* symtab = upb_FileDef_Pool(upb_MessageDef_File(m));
1215
1209
  VALUE pool = ObjectCache_Get(symtab);
1216
1210
  PBRUBY_ASSERT(pool != Qnil);
1217
1211
  VALUE desc_rb = get_msgdef_obj(pool, m);
@@ -1219,15 +1213,16 @@ VALUE Descriptor_DefToClass(const upb_msgdef *m) {
1219
1213
  return desc->klass;
1220
1214
  }
1221
1215
 
1222
- const upb_msgdef *Descriptor_GetMsgDef(VALUE desc_rb) {
1216
+ const upb_MessageDef* Descriptor_GetMsgDef(VALUE desc_rb) {
1223
1217
  const Descriptor* desc = ruby_to_Descriptor(desc_rb);
1224
1218
  return desc->msgdef;
1225
1219
  }
1226
1220
 
1227
- VALUE TypeInfo_InitArg(int argc, VALUE *argv, int skip_arg) {
1221
+ VALUE TypeInfo_InitArg(int argc, VALUE* argv, int skip_arg) {
1228
1222
  if (argc > skip_arg) {
1229
1223
  if (argc > 1 + skip_arg) {
1230
- rb_raise(rb_eArgError, "Expected a maximum of %d arguments.", skip_arg + 1);
1224
+ rb_raise(rb_eArgError, "Expected a maximum of %d arguments.",
1225
+ skip_arg + 1);
1231
1226
  }
1232
1227
  return argv[skip_arg];
1233
1228
  } else {
@@ -1239,7 +1234,7 @@ TypeInfo TypeInfo_FromClass(int argc, VALUE* argv, int skip_arg,
1239
1234
  VALUE* type_class, VALUE* init_arg) {
1240
1235
  TypeInfo ret = {ruby_to_fieldtype(argv[skip_arg])};
1241
1236
 
1242
- if (ret.type == UPB_TYPE_MESSAGE || ret.type == UPB_TYPE_ENUM) {
1237
+ if (ret.type == kUpb_CType_Message || ret.type == kUpb_CType_Enum) {
1243
1238
  *init_arg = TypeInfo_InitArg(argc, argv, skip_arg + 2);
1244
1239
 
1245
1240
  if (argc < 2 + skip_arg) {
@@ -1257,11 +1252,11 @@ TypeInfo TypeInfo_FromClass(int argc, VALUE* argv, int skip_arg,
1257
1252
  "class or enum as returned by the DescriptorPool.");
1258
1253
  }
1259
1254
 
1260
- if (ret.type == UPB_TYPE_MESSAGE) {
1255
+ if (ret.type == kUpb_CType_Message) {
1261
1256
  ret.def.msgdef = ruby_to_Descriptor(desc)->msgdef;
1262
1257
  Message_CheckClass(klass);
1263
1258
  } else {
1264
- PBRUBY_ASSERT(ret.type == UPB_TYPE_ENUM);
1259
+ PBRUBY_ASSERT(ret.type == kUpb_CType_Enum);
1265
1260
  ret.def.enumdef = ruby_to_EnumDescriptor(desc)->enumdef;
1266
1261
  }
1267
1262
  } else {