google-protobuf 3.19.1 → 3.21.5

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