google-protobuf 4.26.1 → 4.28.0
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.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/convert.c +39 -14
- data/ext/google/protobuf_c/defs.c +327 -1
- data/ext/google/protobuf_c/glue.c +16 -0
- data/ext/google/protobuf_c/map.c +72 -20
- data/ext/google/protobuf_c/map.h +6 -2
- data/ext/google/protobuf_c/message.c +78 -50
- data/ext/google/protobuf_c/message.h +1 -5
- data/ext/google/protobuf_c/protobuf.c +11 -9
- data/ext/google/protobuf_c/protobuf.h +3 -7
- data/ext/google/protobuf_c/repeated_field.c +61 -17
- data/ext/google/protobuf_c/repeated_field.h +5 -1
- data/ext/google/protobuf_c/ruby-upb.c +1693 -475
- data/ext/google/protobuf_c/ruby-upb.h +2526 -1386
- data/ext/google/protobuf_c/shared_convert.c +5 -2
- data/ext/google/protobuf_c/shared_message.c +0 -30
- data/ext/google/protobuf_c/shared_message.h +0 -4
- data/lib/google/protobuf/descriptor_pb.rb +2 -1
- data/lib/google/protobuf/ffi/descriptor.rb +4 -3
- data/lib/google/protobuf/ffi/descriptor_pool.rb +3 -1
- data/lib/google/protobuf/ffi/enum_descriptor.rb +3 -1
- data/lib/google/protobuf/ffi/ffi.rb +0 -5
- data/lib/google/protobuf/ffi/field_descriptor.rb +4 -2
- data/lib/google/protobuf/ffi/file_descriptor.rb +3 -1
- data/lib/google/protobuf/ffi/internal/arena.rb +0 -6
- data/lib/google/protobuf/ffi/internal/convert.rb +14 -7
- data/lib/google/protobuf/ffi/map.rb +45 -21
- data/lib/google/protobuf/ffi/message.rb +182 -60
- data/lib/google/protobuf/ffi/method_descriptor.rb +114 -0
- data/lib/google/protobuf/ffi/oneof_descriptor.rb +3 -1
- data/lib/google/protobuf/ffi/repeated_field.rb +42 -16
- data/lib/google/protobuf/ffi/service_descriptor.rb +107 -0
- data/lib/google/protobuf/repeated_field.rb +3 -3
- data/lib/google/protobuf_ffi.rb +2 -0
- metadata +20 -4
@@ -113,17 +113,17 @@ Error, UINTPTR_MAX is undefined
|
|
113
113
|
|
114
114
|
// Macros for function attributes on compilers that support them.
|
115
115
|
#ifdef __GNUC__
|
116
|
-
#define UPB_FORCEINLINE __inline__ __attribute__((always_inline))
|
116
|
+
#define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static
|
117
117
|
#define UPB_NOINLINE __attribute__((noinline))
|
118
118
|
#define UPB_NORETURN __attribute__((__noreturn__))
|
119
119
|
#define UPB_PRINTF(str, first_vararg) __attribute__((format (printf, str, first_vararg)))
|
120
120
|
#elif defined(_MSC_VER)
|
121
121
|
#define UPB_NOINLINE
|
122
|
-
#define UPB_FORCEINLINE
|
122
|
+
#define UPB_FORCEINLINE static
|
123
123
|
#define UPB_NORETURN __declspec(noreturn)
|
124
124
|
#define UPB_PRINTF(str, first_vararg)
|
125
125
|
#else /* !defined(__GNUC__) */
|
126
|
-
#define UPB_FORCEINLINE
|
126
|
+
#define UPB_FORCEINLINE static
|
127
127
|
#define UPB_NOINLINE
|
128
128
|
#define UPB_NORETURN
|
129
129
|
#define UPB_PRINTF(str, first_vararg)
|
@@ -305,10 +305,10 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
|
|
305
305
|
|
306
306
|
/* Disable proto2 arena behavior (TEMPORARY) **********************************/
|
307
307
|
|
308
|
-
#ifdef
|
309
|
-
#define
|
308
|
+
#ifdef UPB_DISABLE_CLOSED_ENUM_CHECKING
|
309
|
+
#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 1
|
310
310
|
#else
|
311
|
-
#define
|
311
|
+
#define UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN 0
|
312
312
|
#endif
|
313
313
|
|
314
314
|
#if defined(__cplusplus)
|
@@ -342,6 +342,83 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
|
|
342
342
|
#endif
|
343
343
|
|
344
344
|
|
345
|
+
// Linker arrays combine elements from multiple translation units into a single
|
346
|
+
// array that can be iterated over at runtime.
|
347
|
+
//
|
348
|
+
// It is an alternative to pre-main "registration" functions.
|
349
|
+
//
|
350
|
+
// Usage:
|
351
|
+
//
|
352
|
+
// // In N translation units.
|
353
|
+
// UPB_LINKARR_APPEND(foo_array) static int elems[3] = {1, 2, 3};
|
354
|
+
//
|
355
|
+
// // At runtime:
|
356
|
+
// UPB_LINKARR_DECLARE(foo_array, int);
|
357
|
+
//
|
358
|
+
// void f() {
|
359
|
+
// const int* start = UPB_LINKARR_START(foo_array);
|
360
|
+
// const int* stop = UPB_LINKARR_STOP(foo_array);
|
361
|
+
// for (const int* p = start; p < stop; p++) {
|
362
|
+
// // Windows can introduce zero padding, so we have to skip zeroes.
|
363
|
+
// if (*p != 0) {
|
364
|
+
// vec.push_back(*p);
|
365
|
+
// }
|
366
|
+
// }
|
367
|
+
// }
|
368
|
+
|
369
|
+
#if defined(__ELF__) || defined(__wasm__)
|
370
|
+
|
371
|
+
#define UPB_LINKARR_APPEND(name) \
|
372
|
+
__attribute__((retain, used, section("linkarr_" #name)))
|
373
|
+
#define UPB_LINKARR_DECLARE(name, type) \
|
374
|
+
extern type const __start_linkarr_##name; \
|
375
|
+
extern type const __stop_linkarr_##name; \
|
376
|
+
UPB_LINKARR_APPEND(name) type UPB_linkarr_internal_empty_##name[1]
|
377
|
+
#define UPB_LINKARR_START(name) (&__start_linkarr_##name)
|
378
|
+
#define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
|
379
|
+
|
380
|
+
#elif defined(__MACH__)
|
381
|
+
|
382
|
+
/* As described in: https://stackoverflow.com/a/22366882 */
|
383
|
+
#define UPB_LINKARR_APPEND(name) \
|
384
|
+
__attribute__((retain, used, section("__DATA,__la_" #name)))
|
385
|
+
#define UPB_LINKARR_DECLARE(name, type) \
|
386
|
+
extern type const __start_linkarr_##name __asm( \
|
387
|
+
"section$start$__DATA$__la_" #name); \
|
388
|
+
extern type const __stop_linkarr_##name __asm( \
|
389
|
+
"section$end$__DATA$" \
|
390
|
+
"__la_" #name); \
|
391
|
+
UPB_LINKARR_APPEND(name) type UPB_linkarr_internal_empty_##name[1]
|
392
|
+
#define UPB_LINKARR_START(name) (&__start_linkarr_##name)
|
393
|
+
#define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
|
394
|
+
|
395
|
+
#elif defined(_MSC_VER) && defined(__clang__)
|
396
|
+
|
397
|
+
/* See:
|
398
|
+
* https://devblogs.microsoft.com/oldnewthing/20181107-00/?p=100155
|
399
|
+
* https://devblogs.microsoft.com/oldnewthing/20181108-00/?p=100165
|
400
|
+
* https://devblogs.microsoft.com/oldnewthing/20181109-00/?p=100175 */
|
401
|
+
|
402
|
+
// Usage of __attribute__ here probably means this is Clang-specific, and would
|
403
|
+
// not work on MSVC.
|
404
|
+
#define UPB_LINKARR_APPEND(name) \
|
405
|
+
__declspec(allocate("la_" #name "$j")) __attribute__((retain, used))
|
406
|
+
#define UPB_LINKARR_DECLARE(name, type) \
|
407
|
+
__declspec(allocate("la_" #name "$a")) type __start_linkarr_##name; \
|
408
|
+
__declspec(allocate("la_" #name "$z")) type __stop_linkarr_##name; \
|
409
|
+
UPB_LINKARR_APPEND(name) type UPB_linkarr_internal_empty_##name[1] = {0}
|
410
|
+
#define UPB_LINKARR_START(name) (&__start_linkarr_##name)
|
411
|
+
#define UPB_LINKARR_STOP(name) (&__stop_linkarr_##name)
|
412
|
+
|
413
|
+
#else
|
414
|
+
|
415
|
+
// Linker arrays are not supported on this platform. Make appends a no-op but
|
416
|
+
// don't define the other macros.
|
417
|
+
#define UPB_LINKARR_APPEND(name)
|
418
|
+
|
419
|
+
#endif
|
420
|
+
|
421
|
+
|
345
422
|
#include <errno.h>
|
346
423
|
#include <float.h>
|
347
424
|
#include <stdarg.h>
|
@@ -398,14 +475,16 @@ void upb_Status_VAppendErrorFormat(upb_Status* status, const char* fmt,
|
|
398
475
|
* google/protobuf/descriptor.proto
|
399
476
|
*
|
400
477
|
* Do not edit -- your changes will be discarded when the file is
|
401
|
-
* regenerated.
|
478
|
+
* regenerated.
|
479
|
+
* NO CHECKED-IN PROTOBUF GENCODE */
|
402
480
|
|
403
481
|
#include <stddef.h>
|
404
482
|
|
405
483
|
// Must be last.
|
406
484
|
|
407
|
-
|
408
|
-
|
485
|
+
extern const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_StaticallyTreeShaken);
|
486
|
+
static const upb_MiniTableSubInternal google_protobuf_FileDescriptorSet_submsgs[1] = {
|
487
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FileDescriptorProto_msg_init_ptr},
|
409
488
|
};
|
410
489
|
|
411
490
|
static const upb_MiniTableField google_protobuf_FileDescriptorSet__fields[1] = {
|
@@ -416,19 +495,23 @@ const upb_MiniTable google__protobuf__FileDescriptorSet_msg_init = {
|
|
416
495
|
&google_protobuf_FileDescriptorSet_submsgs[0],
|
417
496
|
&google_protobuf_FileDescriptorSet__fields[0],
|
418
497
|
16, 1, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(8), 0,
|
498
|
+
#ifdef UPB_TRACING_ENABLED
|
499
|
+
"google.protobuf.FileDescriptorSet",
|
500
|
+
#endif
|
419
501
|
UPB_FASTTABLE_INIT({
|
420
502
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
421
503
|
{0x000800003f00000a, &upb_prm_1bt_max192b},
|
422
504
|
})
|
423
505
|
};
|
424
506
|
|
425
|
-
|
426
|
-
|
427
|
-
{.UPB_PRIVATE(submsg) = &
|
428
|
-
{.UPB_PRIVATE(submsg) = &
|
429
|
-
{.UPB_PRIVATE(submsg) = &
|
430
|
-
{.UPB_PRIVATE(submsg) = &
|
431
|
-
{.UPB_PRIVATE(submsg) = &
|
507
|
+
const upb_MiniTable* google__protobuf__FileDescriptorSet_msg_init_ptr = &google__protobuf__FileDescriptorSet_msg_init;
|
508
|
+
static const upb_MiniTableSubInternal google_protobuf_FileDescriptorProto_submsgs[7] = {
|
509
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__DescriptorProto_msg_init_ptr},
|
510
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__EnumDescriptorProto_msg_init_ptr},
|
511
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__ServiceDescriptorProto_msg_init_ptr},
|
512
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FieldDescriptorProto_msg_init_ptr},
|
513
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FileOptions_msg_init_ptr},
|
514
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__SourceCodeInfo_msg_init_ptr},
|
432
515
|
{.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init},
|
433
516
|
};
|
434
517
|
|
@@ -452,6 +535,9 @@ const upb_MiniTable google__protobuf__FileDescriptorProto_msg_init = {
|
|
452
535
|
&google_protobuf_FileDescriptorProto_submsgs[0],
|
453
536
|
&google_protobuf_FileDescriptorProto__fields[0],
|
454
537
|
UPB_SIZE(80, 136), 13, kUpb_ExtMode_NonExtendable, 12, UPB_FASTTABLE_MASK(120), 0,
|
538
|
+
#ifdef UPB_TRACING_ENABLED
|
539
|
+
"google.protobuf.FileDescriptorProto",
|
540
|
+
#endif
|
455
541
|
UPB_FASTTABLE_INIT({
|
456
542
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
457
543
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -472,15 +558,16 @@ const upb_MiniTable google__protobuf__FileDescriptorProto_msg_init = {
|
|
472
558
|
})
|
473
559
|
};
|
474
560
|
|
475
|
-
|
476
|
-
|
477
|
-
{.UPB_PRIVATE(submsg) = &
|
478
|
-
{.UPB_PRIVATE(submsg) = &
|
479
|
-
{.UPB_PRIVATE(submsg) = &
|
480
|
-
{.UPB_PRIVATE(submsg) = &
|
481
|
-
{.UPB_PRIVATE(submsg) = &
|
482
|
-
{.UPB_PRIVATE(submsg) = &
|
483
|
-
{.UPB_PRIVATE(submsg) = &
|
561
|
+
const upb_MiniTable* google__protobuf__FileDescriptorProto_msg_init_ptr = &google__protobuf__FileDescriptorProto_msg_init;
|
562
|
+
static const upb_MiniTableSubInternal google_protobuf_DescriptorProto_submsgs[8] = {
|
563
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FieldDescriptorProto_msg_init_ptr},
|
564
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__DescriptorProto_msg_init_ptr},
|
565
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__EnumDescriptorProto_msg_init_ptr},
|
566
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__DescriptorProto__ExtensionRange_msg_init_ptr},
|
567
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FieldDescriptorProto_msg_init_ptr},
|
568
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__MessageOptions_msg_init_ptr},
|
569
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__OneofDescriptorProto_msg_init_ptr},
|
570
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__DescriptorProto__ReservedRange_msg_init_ptr},
|
484
571
|
};
|
485
572
|
|
486
573
|
static const upb_MiniTableField google_protobuf_DescriptorProto__fields[10] = {
|
@@ -500,6 +587,9 @@ const upb_MiniTable google__protobuf__DescriptorProto_msg_init = {
|
|
500
587
|
&google_protobuf_DescriptorProto_submsgs[0],
|
501
588
|
&google_protobuf_DescriptorProto__fields[0],
|
502
589
|
UPB_SIZE(56, 104), 10, kUpb_ExtMode_NonExtendable, 10, UPB_FASTTABLE_MASK(120), 0,
|
590
|
+
#ifdef UPB_TRACING_ENABLED
|
591
|
+
"google.protobuf.DescriptorProto",
|
592
|
+
#endif
|
503
593
|
UPB_FASTTABLE_INIT({
|
504
594
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
505
595
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -520,8 +610,9 @@ const upb_MiniTable google__protobuf__DescriptorProto_msg_init = {
|
|
520
610
|
})
|
521
611
|
};
|
522
612
|
|
523
|
-
|
524
|
-
|
613
|
+
const upb_MiniTable* google__protobuf__DescriptorProto_msg_init_ptr = &google__protobuf__DescriptorProto_msg_init;
|
614
|
+
static const upb_MiniTableSubInternal google_protobuf_DescriptorProto_ExtensionRange_submsgs[1] = {
|
615
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__ExtensionRangeOptions_msg_init_ptr},
|
525
616
|
};
|
526
617
|
|
527
618
|
static const upb_MiniTableField google_protobuf_DescriptorProto_ExtensionRange__fields[3] = {
|
@@ -534,8 +625,12 @@ const upb_MiniTable google__protobuf__DescriptorProto__ExtensionRange_msg_init =
|
|
534
625
|
&google_protobuf_DescriptorProto_ExtensionRange_submsgs[0],
|
535
626
|
&google_protobuf_DescriptorProto_ExtensionRange__fields[0],
|
536
627
|
UPB_SIZE(24, 32), 3, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(255), 0,
|
628
|
+
#ifdef UPB_TRACING_ENABLED
|
629
|
+
"google.protobuf.DescriptorProto.ExtensionRange",
|
630
|
+
#endif
|
537
631
|
};
|
538
632
|
|
633
|
+
const upb_MiniTable* google__protobuf__DescriptorProto__ExtensionRange_msg_init_ptr = &google__protobuf__DescriptorProto__ExtensionRange_msg_init;
|
539
634
|
static const upb_MiniTableField google_protobuf_DescriptorProto_ReservedRange__fields[2] = {
|
540
635
|
{1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
541
636
|
{2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
@@ -545,12 +640,16 @@ const upb_MiniTable google__protobuf__DescriptorProto__ReservedRange_msg_init =
|
|
545
640
|
NULL,
|
546
641
|
&google_protobuf_DescriptorProto_ReservedRange__fields[0],
|
547
642
|
24, 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(255), 0,
|
643
|
+
#ifdef UPB_TRACING_ENABLED
|
644
|
+
"google.protobuf.DescriptorProto.ReservedRange",
|
645
|
+
#endif
|
548
646
|
};
|
549
647
|
|
550
|
-
|
551
|
-
|
552
|
-
{.UPB_PRIVATE(submsg) = &
|
553
|
-
{.UPB_PRIVATE(submsg) = &
|
648
|
+
const upb_MiniTable* google__protobuf__DescriptorProto__ReservedRange_msg_init_ptr = &google__protobuf__DescriptorProto__ReservedRange_msg_init;
|
649
|
+
static const upb_MiniTableSubInternal google_protobuf_ExtensionRangeOptions_submsgs[4] = {
|
650
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__ExtensionRangeOptions__Declaration_msg_init_ptr},
|
651
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init_ptr},
|
652
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init_ptr},
|
554
653
|
{.UPB_PRIVATE(subenum) = &google_protobuf_ExtensionRangeOptions_VerificationState_enum_init},
|
555
654
|
};
|
556
655
|
|
@@ -565,6 +664,9 @@ const upb_MiniTable google__protobuf__ExtensionRangeOptions_msg_init = {
|
|
565
664
|
&google_protobuf_ExtensionRangeOptions_submsgs[0],
|
566
665
|
&google_protobuf_ExtensionRangeOptions__fields[0],
|
567
666
|
UPB_SIZE(32, 40), 4, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0,
|
667
|
+
#ifdef UPB_TRACING_ENABLED
|
668
|
+
"google.protobuf.ExtensionRangeOptions",
|
669
|
+
#endif
|
568
670
|
UPB_FASTTABLE_INIT({
|
569
671
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
570
672
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -601,6 +703,7 @@ const upb_MiniTable google__protobuf__ExtensionRangeOptions_msg_init = {
|
|
601
703
|
})
|
602
704
|
};
|
603
705
|
|
706
|
+
const upb_MiniTable* google__protobuf__ExtensionRangeOptions_msg_init_ptr = &google__protobuf__ExtensionRangeOptions_msg_init;
|
604
707
|
static const upb_MiniTableField google_protobuf_ExtensionRangeOptions_Declaration__fields[5] = {
|
605
708
|
{1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
606
709
|
{2, UPB_SIZE(20, 24), 65, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)},
|
@@ -613,10 +716,14 @@ const upb_MiniTable google__protobuf__ExtensionRangeOptions__Declaration_msg_ini
|
|
613
716
|
NULL,
|
614
717
|
&google_protobuf_ExtensionRangeOptions_Declaration__fields[0],
|
615
718
|
UPB_SIZE(40, 56), 5, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(255), 0,
|
719
|
+
#ifdef UPB_TRACING_ENABLED
|
720
|
+
"google.protobuf.ExtensionRangeOptions.Declaration",
|
721
|
+
#endif
|
616
722
|
};
|
617
723
|
|
618
|
-
|
619
|
-
|
724
|
+
const upb_MiniTable* google__protobuf__ExtensionRangeOptions__Declaration_msg_init_ptr = &google__protobuf__ExtensionRangeOptions__Declaration_msg_init;
|
725
|
+
static const upb_MiniTableSubInternal google_protobuf_FieldDescriptorProto_submsgs[3] = {
|
726
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FieldOptions_msg_init_ptr},
|
620
727
|
{.UPB_PRIVATE(subenum) = &google_protobuf_FieldDescriptorProto_Label_enum_init},
|
621
728
|
{.UPB_PRIVATE(subenum) = &google_protobuf_FieldDescriptorProto_Type_enum_init},
|
622
729
|
};
|
@@ -639,10 +746,14 @@ const upb_MiniTable google__protobuf__FieldDescriptorProto_msg_init = {
|
|
639
746
|
&google_protobuf_FieldDescriptorProto_submsgs[0],
|
640
747
|
&google_protobuf_FieldDescriptorProto__fields[0],
|
641
748
|
UPB_SIZE(80, 120), 11, kUpb_ExtMode_NonExtendable, 10, UPB_FASTTABLE_MASK(255), 0,
|
749
|
+
#ifdef UPB_TRACING_ENABLED
|
750
|
+
"google.protobuf.FieldDescriptorProto",
|
751
|
+
#endif
|
642
752
|
};
|
643
753
|
|
644
|
-
|
645
|
-
|
754
|
+
const upb_MiniTable* google__protobuf__FieldDescriptorProto_msg_init_ptr = &google__protobuf__FieldDescriptorProto_msg_init;
|
755
|
+
static const upb_MiniTableSubInternal google_protobuf_OneofDescriptorProto_submsgs[1] = {
|
756
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__OneofOptions_msg_init_ptr},
|
646
757
|
};
|
647
758
|
|
648
759
|
static const upb_MiniTableField google_protobuf_OneofDescriptorProto__fields[2] = {
|
@@ -654,12 +765,16 @@ const upb_MiniTable google__protobuf__OneofDescriptorProto_msg_init = {
|
|
654
765
|
&google_protobuf_OneofDescriptorProto_submsgs[0],
|
655
766
|
&google_protobuf_OneofDescriptorProto__fields[0],
|
656
767
|
UPB_SIZE(24, 40), 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(255), 0,
|
768
|
+
#ifdef UPB_TRACING_ENABLED
|
769
|
+
"google.protobuf.OneofDescriptorProto",
|
770
|
+
#endif
|
657
771
|
};
|
658
772
|
|
659
|
-
|
660
|
-
|
661
|
-
{.UPB_PRIVATE(submsg) = &
|
662
|
-
{.UPB_PRIVATE(submsg) = &
|
773
|
+
const upb_MiniTable* google__protobuf__OneofDescriptorProto_msg_init_ptr = &google__protobuf__OneofDescriptorProto_msg_init;
|
774
|
+
static const upb_MiniTableSubInternal google_protobuf_EnumDescriptorProto_submsgs[3] = {
|
775
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__EnumValueDescriptorProto_msg_init_ptr},
|
776
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__EnumOptions_msg_init_ptr},
|
777
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init_ptr},
|
663
778
|
};
|
664
779
|
|
665
780
|
static const upb_MiniTableField google_protobuf_EnumDescriptorProto__fields[5] = {
|
@@ -674,6 +789,9 @@ const upb_MiniTable google__protobuf__EnumDescriptorProto_msg_init = {
|
|
674
789
|
&google_protobuf_EnumDescriptorProto_submsgs[0],
|
675
790
|
&google_protobuf_EnumDescriptorProto__fields[0],
|
676
791
|
UPB_SIZE(40, 64), 5, kUpb_ExtMode_NonExtendable, 5, UPB_FASTTABLE_MASK(56), 0,
|
792
|
+
#ifdef UPB_TRACING_ENABLED
|
793
|
+
"google.protobuf.EnumDescriptorProto",
|
794
|
+
#endif
|
677
795
|
UPB_FASTTABLE_INIT({
|
678
796
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
679
797
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -686,6 +804,7 @@ const upb_MiniTable google__protobuf__EnumDescriptorProto_msg_init = {
|
|
686
804
|
})
|
687
805
|
};
|
688
806
|
|
807
|
+
const upb_MiniTable* google__protobuf__EnumDescriptorProto_msg_init_ptr = &google__protobuf__EnumDescriptorProto_msg_init;
|
689
808
|
static const upb_MiniTableField google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[2] = {
|
690
809
|
{1, 12, 64, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
691
810
|
{2, 16, 65, kUpb_NoSub, 5, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
@@ -695,10 +814,14 @@ const upb_MiniTable google__protobuf__EnumDescriptorProto__EnumReservedRange_msg
|
|
695
814
|
NULL,
|
696
815
|
&google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[0],
|
697
816
|
24, 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(255), 0,
|
817
|
+
#ifdef UPB_TRACING_ENABLED
|
818
|
+
"google.protobuf.EnumDescriptorProto.EnumReservedRange",
|
819
|
+
#endif
|
698
820
|
};
|
699
821
|
|
700
|
-
|
701
|
-
|
822
|
+
const upb_MiniTable* google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init_ptr = &google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init;
|
823
|
+
static const upb_MiniTableSubInternal google_protobuf_EnumValueDescriptorProto_submsgs[1] = {
|
824
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__EnumValueOptions_msg_init_ptr},
|
702
825
|
};
|
703
826
|
|
704
827
|
static const upb_MiniTableField google_protobuf_EnumValueDescriptorProto__fields[3] = {
|
@@ -711,11 +834,15 @@ const upb_MiniTable google__protobuf__EnumValueDescriptorProto_msg_init = {
|
|
711
834
|
&google_protobuf_EnumValueDescriptorProto_submsgs[0],
|
712
835
|
&google_protobuf_EnumValueDescriptorProto__fields[0],
|
713
836
|
UPB_SIZE(32, 40), 3, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(255), 0,
|
837
|
+
#ifdef UPB_TRACING_ENABLED
|
838
|
+
"google.protobuf.EnumValueDescriptorProto",
|
839
|
+
#endif
|
714
840
|
};
|
715
841
|
|
716
|
-
|
717
|
-
|
718
|
-
{.UPB_PRIVATE(submsg) = &
|
842
|
+
const upb_MiniTable* google__protobuf__EnumValueDescriptorProto_msg_init_ptr = &google__protobuf__EnumValueDescriptorProto_msg_init;
|
843
|
+
static const upb_MiniTableSubInternal google_protobuf_ServiceDescriptorProto_submsgs[2] = {
|
844
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__MethodDescriptorProto_msg_init_ptr},
|
845
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__ServiceOptions_msg_init_ptr},
|
719
846
|
};
|
720
847
|
|
721
848
|
static const upb_MiniTableField google_protobuf_ServiceDescriptorProto__fields[3] = {
|
@@ -728,6 +855,9 @@ const upb_MiniTable google__protobuf__ServiceDescriptorProto_msg_init = {
|
|
728
855
|
&google_protobuf_ServiceDescriptorProto_submsgs[0],
|
729
856
|
&google_protobuf_ServiceDescriptorProto__fields[0],
|
730
857
|
UPB_SIZE(32, 48), 3, kUpb_ExtMode_NonExtendable, 3, UPB_FASTTABLE_MASK(24), 0,
|
858
|
+
#ifdef UPB_TRACING_ENABLED
|
859
|
+
"google.protobuf.ServiceDescriptorProto",
|
860
|
+
#endif
|
731
861
|
UPB_FASTTABLE_INIT({
|
732
862
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
733
863
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -736,8 +866,9 @@ const upb_MiniTable google__protobuf__ServiceDescriptorProto_msg_init = {
|
|
736
866
|
})
|
737
867
|
};
|
738
868
|
|
739
|
-
|
740
|
-
|
869
|
+
const upb_MiniTable* google__protobuf__ServiceDescriptorProto_msg_init_ptr = &google__protobuf__ServiceDescriptorProto_msg_init;
|
870
|
+
static const upb_MiniTableSubInternal google_protobuf_MethodDescriptorProto_submsgs[1] = {
|
871
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__MethodOptions_msg_init_ptr},
|
741
872
|
};
|
742
873
|
|
743
874
|
static const upb_MiniTableField google_protobuf_MethodDescriptorProto__fields[6] = {
|
@@ -753,11 +884,15 @@ const upb_MiniTable google__protobuf__MethodDescriptorProto_msg_init = {
|
|
753
884
|
&google_protobuf_MethodDescriptorProto_submsgs[0],
|
754
885
|
&google_protobuf_MethodDescriptorProto__fields[0],
|
755
886
|
UPB_SIZE(48, 72), 6, kUpb_ExtMode_NonExtendable, 6, UPB_FASTTABLE_MASK(255), 0,
|
887
|
+
#ifdef UPB_TRACING_ENABLED
|
888
|
+
"google.protobuf.MethodDescriptorProto",
|
889
|
+
#endif
|
756
890
|
};
|
757
891
|
|
758
|
-
|
759
|
-
|
760
|
-
{.UPB_PRIVATE(submsg) = &
|
892
|
+
const upb_MiniTable* google__protobuf__MethodDescriptorProto_msg_init_ptr = &google__protobuf__MethodDescriptorProto_msg_init;
|
893
|
+
static const upb_MiniTableSubInternal google_protobuf_FileOptions_submsgs[3] = {
|
894
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init_ptr},
|
895
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init_ptr},
|
761
896
|
{.UPB_PRIVATE(subenum) = &google_protobuf_FileOptions_OptimizeMode_enum_init},
|
762
897
|
};
|
763
898
|
|
@@ -789,6 +924,9 @@ const upb_MiniTable google__protobuf__FileOptions_msg_init = {
|
|
789
924
|
&google_protobuf_FileOptions_submsgs[0],
|
790
925
|
&google_protobuf_FileOptions__fields[0],
|
791
926
|
UPB_SIZE(112, 200), 21, kUpb_ExtMode_Extendable, 1, UPB_FASTTABLE_MASK(248), 0,
|
927
|
+
#ifdef UPB_TRACING_ENABLED
|
928
|
+
"google.protobuf.FileOptions",
|
929
|
+
#endif
|
792
930
|
UPB_FASTTABLE_INIT({
|
793
931
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
794
932
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -825,9 +963,10 @@ const upb_MiniTable google__protobuf__FileOptions_msg_init = {
|
|
825
963
|
})
|
826
964
|
};
|
827
965
|
|
828
|
-
|
829
|
-
|
830
|
-
{.UPB_PRIVATE(submsg) = &
|
966
|
+
const upb_MiniTable* google__protobuf__FileOptions_msg_init_ptr = &google__protobuf__FileOptions_msg_init;
|
967
|
+
static const upb_MiniTableSubInternal google_protobuf_MessageOptions_submsgs[2] = {
|
968
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init_ptr},
|
969
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init_ptr},
|
831
970
|
};
|
832
971
|
|
833
972
|
static const upb_MiniTableField google_protobuf_MessageOptions__fields[7] = {
|
@@ -844,6 +983,9 @@ const upb_MiniTable google__protobuf__MessageOptions_msg_init = {
|
|
844
983
|
&google_protobuf_MessageOptions_submsgs[0],
|
845
984
|
&google_protobuf_MessageOptions__fields[0],
|
846
985
|
UPB_SIZE(24, 32), 7, kUpb_ExtMode_Extendable, 3, UPB_FASTTABLE_MASK(248), 0,
|
986
|
+
#ifdef UPB_TRACING_ENABLED
|
987
|
+
"google.protobuf.MessageOptions",
|
988
|
+
#endif
|
847
989
|
UPB_FASTTABLE_INIT({
|
848
990
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
849
991
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -880,36 +1022,42 @@ const upb_MiniTable google__protobuf__MessageOptions_msg_init = {
|
|
880
1022
|
})
|
881
1023
|
};
|
882
1024
|
|
883
|
-
|
884
|
-
|
885
|
-
{.UPB_PRIVATE(submsg) = &
|
886
|
-
{.UPB_PRIVATE(submsg) = &
|
1025
|
+
const upb_MiniTable* google__protobuf__MessageOptions_msg_init_ptr = &google__protobuf__MessageOptions_msg_init;
|
1026
|
+
static const upb_MiniTableSubInternal google_protobuf_FieldOptions_submsgs[8] = {
|
1027
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FieldOptions__EditionDefault_msg_init_ptr},
|
1028
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init_ptr},
|
1029
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FieldOptions__FeatureSupport_msg_init_ptr},
|
1030
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init_ptr},
|
887
1031
|
{.UPB_PRIVATE(subenum) = &google_protobuf_FieldOptions_CType_enum_init},
|
888
1032
|
{.UPB_PRIVATE(subenum) = &google_protobuf_FieldOptions_JSType_enum_init},
|
889
1033
|
{.UPB_PRIVATE(subenum) = &google_protobuf_FieldOptions_OptionRetention_enum_init},
|
890
1034
|
{.UPB_PRIVATE(subenum) = &google_protobuf_FieldOptions_OptionTargetType_enum_init},
|
891
1035
|
};
|
892
1036
|
|
893
|
-
static const upb_MiniTableField google_protobuf_FieldOptions__fields[
|
894
|
-
{1, 12, 64,
|
1037
|
+
static const upb_MiniTableField google_protobuf_FieldOptions__fields[14] = {
|
1038
|
+
{1, 12, 64, 4, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
895
1039
|
{2, 16, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)},
|
896
1040
|
{3, 17, 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)},
|
897
1041
|
{5, 18, 67, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)},
|
898
|
-
{6, 20, 68,
|
1042
|
+
{6, 20, 68, 5, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
899
1043
|
{10, 24, 69, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)},
|
900
1044
|
{15, 25, 70, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)},
|
901
1045
|
{16, 26, 71, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)},
|
902
|
-
{17, 28, 72,
|
903
|
-
{19, 32, 0,
|
1046
|
+
{17, 28, 72, 6, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
1047
|
+
{19, 32, 0, 7, 14, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)},
|
904
1048
|
{20, UPB_SIZE(36, 40), 0, 0, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)},
|
905
1049
|
{21, UPB_SIZE(40, 48), 73, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)},
|
906
|
-
{
|
1050
|
+
{22, UPB_SIZE(44, 56), 74, 2, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)},
|
1051
|
+
{999, UPB_SIZE(48, 64), 0, 3, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)},
|
907
1052
|
};
|
908
1053
|
|
909
1054
|
const upb_MiniTable google__protobuf__FieldOptions_msg_init = {
|
910
1055
|
&google_protobuf_FieldOptions_submsgs[0],
|
911
1056
|
&google_protobuf_FieldOptions__fields[0],
|
912
|
-
UPB_SIZE(
|
1057
|
+
UPB_SIZE(56, 72), 14, kUpb_ExtMode_Extendable, 3, UPB_FASTTABLE_MASK(248), 0,
|
1058
|
+
#ifdef UPB_TRACING_ENABLED
|
1059
|
+
"google.protobuf.FieldOptions",
|
1060
|
+
#endif
|
913
1061
|
UPB_FASTTABLE_INIT({
|
914
1062
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
915
1063
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -934,7 +1082,7 @@ const upb_MiniTable google__protobuf__FieldOptions_msg_init = {
|
|
934
1082
|
{0x002800003f0001a2, &upb_prm_2bt_max64b},
|
935
1083
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
936
1084
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
937
|
-
{
|
1085
|
+
{0x004000003f033eba, &upb_prm_2bt_max128b},
|
938
1086
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
939
1087
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
940
1088
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -946,7 +1094,8 @@ const upb_MiniTable google__protobuf__FieldOptions_msg_init = {
|
|
946
1094
|
})
|
947
1095
|
};
|
948
1096
|
|
949
|
-
|
1097
|
+
const upb_MiniTable* google__protobuf__FieldOptions_msg_init_ptr = &google__protobuf__FieldOptions_msg_init;
|
1098
|
+
static const upb_MiniTableSubInternal google_protobuf_FieldOptions_EditionDefault_submsgs[1] = {
|
950
1099
|
{.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init},
|
951
1100
|
};
|
952
1101
|
|
@@ -959,11 +1108,38 @@ const upb_MiniTable google__protobuf__FieldOptions__EditionDefault_msg_init = {
|
|
959
1108
|
&google_protobuf_FieldOptions_EditionDefault_submsgs[0],
|
960
1109
|
&google_protobuf_FieldOptions_EditionDefault__fields[0],
|
961
1110
|
UPB_SIZE(24, 32), 2, kUpb_ExtMode_NonExtendable, 0, UPB_FASTTABLE_MASK(255), 0,
|
1111
|
+
#ifdef UPB_TRACING_ENABLED
|
1112
|
+
"google.protobuf.FieldOptions.EditionDefault",
|
1113
|
+
#endif
|
1114
|
+
};
|
1115
|
+
|
1116
|
+
const upb_MiniTable* google__protobuf__FieldOptions__EditionDefault_msg_init_ptr = &google__protobuf__FieldOptions__EditionDefault_msg_init;
|
1117
|
+
static const upb_MiniTableSubInternal google_protobuf_FieldOptions_FeatureSupport_submsgs[3] = {
|
1118
|
+
{.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init},
|
1119
|
+
{.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init},
|
1120
|
+
{.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init},
|
1121
|
+
};
|
1122
|
+
|
1123
|
+
static const upb_MiniTableField google_protobuf_FieldOptions_FeatureSupport__fields[4] = {
|
1124
|
+
{1, 12, 64, 0, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
1125
|
+
{2, 16, 65, 1, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
1126
|
+
{3, 24, 66, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)},
|
1127
|
+
{4, 20, 67, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
1128
|
+
};
|
1129
|
+
|
1130
|
+
const upb_MiniTable google__protobuf__FieldOptions__FeatureSupport_msg_init = {
|
1131
|
+
&google_protobuf_FieldOptions_FeatureSupport_submsgs[0],
|
1132
|
+
&google_protobuf_FieldOptions_FeatureSupport__fields[0],
|
1133
|
+
UPB_SIZE(32, 40), 4, kUpb_ExtMode_NonExtendable, 4, UPB_FASTTABLE_MASK(255), 0,
|
1134
|
+
#ifdef UPB_TRACING_ENABLED
|
1135
|
+
"google.protobuf.FieldOptions.FeatureSupport",
|
1136
|
+
#endif
|
962
1137
|
};
|
963
1138
|
|
964
|
-
|
965
|
-
|
966
|
-
{.UPB_PRIVATE(submsg) = &
|
1139
|
+
const upb_MiniTable* google__protobuf__FieldOptions__FeatureSupport_msg_init_ptr = &google__protobuf__FieldOptions__FeatureSupport_msg_init;
|
1140
|
+
static const upb_MiniTableSubInternal google_protobuf_OneofOptions_submsgs[2] = {
|
1141
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init_ptr},
|
1142
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init_ptr},
|
967
1143
|
};
|
968
1144
|
|
969
1145
|
static const upb_MiniTableField google_protobuf_OneofOptions__fields[2] = {
|
@@ -975,6 +1151,9 @@ const upb_MiniTable google__protobuf__OneofOptions_msg_init = {
|
|
975
1151
|
&google_protobuf_OneofOptions_submsgs[0],
|
976
1152
|
&google_protobuf_OneofOptions__fields[0],
|
977
1153
|
UPB_SIZE(24, 32), 2, kUpb_ExtMode_Extendable, 1, UPB_FASTTABLE_MASK(248), 0,
|
1154
|
+
#ifdef UPB_TRACING_ENABLED
|
1155
|
+
"google.protobuf.OneofOptions",
|
1156
|
+
#endif
|
978
1157
|
UPB_FASTTABLE_INIT({
|
979
1158
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
980
1159
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -1011,9 +1190,10 @@ const upb_MiniTable google__protobuf__OneofOptions_msg_init = {
|
|
1011
1190
|
})
|
1012
1191
|
};
|
1013
1192
|
|
1014
|
-
|
1015
|
-
|
1016
|
-
{.UPB_PRIVATE(submsg) = &
|
1193
|
+
const upb_MiniTable* google__protobuf__OneofOptions_msg_init_ptr = &google__protobuf__OneofOptions_msg_init;
|
1194
|
+
static const upb_MiniTableSubInternal google_protobuf_EnumOptions_submsgs[2] = {
|
1195
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init_ptr},
|
1196
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init_ptr},
|
1017
1197
|
};
|
1018
1198
|
|
1019
1199
|
static const upb_MiniTableField google_protobuf_EnumOptions__fields[5] = {
|
@@ -1028,6 +1208,9 @@ const upb_MiniTable google__protobuf__EnumOptions_msg_init = {
|
|
1028
1208
|
&google_protobuf_EnumOptions_submsgs[0],
|
1029
1209
|
&google_protobuf_EnumOptions__fields[0],
|
1030
1210
|
UPB_SIZE(24, 32), 5, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0,
|
1211
|
+
#ifdef UPB_TRACING_ENABLED
|
1212
|
+
"google.protobuf.EnumOptions",
|
1213
|
+
#endif
|
1031
1214
|
UPB_FASTTABLE_INIT({
|
1032
1215
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1033
1216
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -1064,22 +1247,28 @@ const upb_MiniTable google__protobuf__EnumOptions_msg_init = {
|
|
1064
1247
|
})
|
1065
1248
|
};
|
1066
1249
|
|
1067
|
-
|
1068
|
-
|
1069
|
-
{.UPB_PRIVATE(submsg) = &
|
1250
|
+
const upb_MiniTable* google__protobuf__EnumOptions_msg_init_ptr = &google__protobuf__EnumOptions_msg_init;
|
1251
|
+
static const upb_MiniTableSubInternal google_protobuf_EnumValueOptions_submsgs[3] = {
|
1252
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init_ptr},
|
1253
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FieldOptions__FeatureSupport_msg_init_ptr},
|
1254
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init_ptr},
|
1070
1255
|
};
|
1071
1256
|
|
1072
|
-
static const upb_MiniTableField google_protobuf_EnumValueOptions__fields[
|
1257
|
+
static const upb_MiniTableField google_protobuf_EnumValueOptions__fields[5] = {
|
1073
1258
|
{1, 9, 64, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)},
|
1074
1259
|
{2, UPB_SIZE(12, 16), 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)},
|
1075
1260
|
{3, UPB_SIZE(16, 10), 66, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)},
|
1076
|
-
{
|
1261
|
+
{4, UPB_SIZE(20, 24), 67, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)},
|
1262
|
+
{999, UPB_SIZE(24, 32), 0, 2, 11, (int)kUpb_FieldMode_Array | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)},
|
1077
1263
|
};
|
1078
1264
|
|
1079
1265
|
const upb_MiniTable google__protobuf__EnumValueOptions_msg_init = {
|
1080
1266
|
&google_protobuf_EnumValueOptions_submsgs[0],
|
1081
1267
|
&google_protobuf_EnumValueOptions__fields[0],
|
1082
|
-
UPB_SIZE(
|
1268
|
+
UPB_SIZE(32, 40), 5, kUpb_ExtMode_Extendable, 4, UPB_FASTTABLE_MASK(248), 0,
|
1269
|
+
#ifdef UPB_TRACING_ENABLED
|
1270
|
+
"google.protobuf.EnumValueOptions",
|
1271
|
+
#endif
|
1083
1272
|
UPB_FASTTABLE_INIT({
|
1084
1273
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1085
1274
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -1104,7 +1293,7 @@ const upb_MiniTable google__protobuf__EnumValueOptions_msg_init = {
|
|
1104
1293
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1105
1294
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1106
1295
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1107
|
-
{
|
1296
|
+
{0x002000003f023eba, &upb_prm_2bt_max128b},
|
1108
1297
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1109
1298
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1110
1299
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -1116,9 +1305,10 @@ const upb_MiniTable google__protobuf__EnumValueOptions_msg_init = {
|
|
1116
1305
|
})
|
1117
1306
|
};
|
1118
1307
|
|
1119
|
-
|
1120
|
-
|
1121
|
-
{.UPB_PRIVATE(submsg) = &
|
1308
|
+
const upb_MiniTable* google__protobuf__EnumValueOptions_msg_init_ptr = &google__protobuf__EnumValueOptions_msg_init;
|
1309
|
+
static const upb_MiniTableSubInternal google_protobuf_ServiceOptions_submsgs[2] = {
|
1310
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init_ptr},
|
1311
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init_ptr},
|
1122
1312
|
};
|
1123
1313
|
|
1124
1314
|
static const upb_MiniTableField google_protobuf_ServiceOptions__fields[3] = {
|
@@ -1131,6 +1321,9 @@ const upb_MiniTable google__protobuf__ServiceOptions_msg_init = {
|
|
1131
1321
|
&google_protobuf_ServiceOptions_submsgs[0],
|
1132
1322
|
&google_protobuf_ServiceOptions__fields[0],
|
1133
1323
|
UPB_SIZE(24, 32), 3, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0,
|
1324
|
+
#ifdef UPB_TRACING_ENABLED
|
1325
|
+
"google.protobuf.ServiceOptions",
|
1326
|
+
#endif
|
1134
1327
|
UPB_FASTTABLE_INIT({
|
1135
1328
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1136
1329
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -1167,9 +1360,10 @@ const upb_MiniTable google__protobuf__ServiceOptions_msg_init = {
|
|
1167
1360
|
})
|
1168
1361
|
};
|
1169
1362
|
|
1170
|
-
|
1171
|
-
|
1172
|
-
{.UPB_PRIVATE(submsg) = &
|
1363
|
+
const upb_MiniTable* google__protobuf__ServiceOptions_msg_init_ptr = &google__protobuf__ServiceOptions_msg_init;
|
1364
|
+
static const upb_MiniTableSubInternal google_protobuf_MethodOptions_submsgs[3] = {
|
1365
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init_ptr},
|
1366
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption_msg_init_ptr},
|
1173
1367
|
{.UPB_PRIVATE(subenum) = &google_protobuf_MethodOptions_IdempotencyLevel_enum_init},
|
1174
1368
|
};
|
1175
1369
|
|
@@ -1184,6 +1378,9 @@ const upb_MiniTable google__protobuf__MethodOptions_msg_init = {
|
|
1184
1378
|
&google_protobuf_MethodOptions_submsgs[0],
|
1185
1379
|
&google_protobuf_MethodOptions__fields[0],
|
1186
1380
|
UPB_SIZE(24, 32), 4, kUpb_ExtMode_Extendable, 0, UPB_FASTTABLE_MASK(248), 0,
|
1381
|
+
#ifdef UPB_TRACING_ENABLED
|
1382
|
+
"google.protobuf.MethodOptions",
|
1383
|
+
#endif
|
1187
1384
|
UPB_FASTTABLE_INIT({
|
1188
1385
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1189
1386
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -1220,8 +1417,9 @@ const upb_MiniTable google__protobuf__MethodOptions_msg_init = {
|
|
1220
1417
|
})
|
1221
1418
|
};
|
1222
1419
|
|
1223
|
-
|
1224
|
-
|
1420
|
+
const upb_MiniTable* google__protobuf__MethodOptions_msg_init_ptr = &google__protobuf__MethodOptions_msg_init;
|
1421
|
+
static const upb_MiniTableSubInternal google_protobuf_UninterpretedOption_submsgs[1] = {
|
1422
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__UninterpretedOption__NamePart_msg_init_ptr},
|
1225
1423
|
};
|
1226
1424
|
|
1227
1425
|
static const upb_MiniTableField google_protobuf_UninterpretedOption__fields[7] = {
|
@@ -1238,6 +1436,9 @@ const upb_MiniTable google__protobuf__UninterpretedOption_msg_init = {
|
|
1238
1436
|
&google_protobuf_UninterpretedOption_submsgs[0],
|
1239
1437
|
&google_protobuf_UninterpretedOption__fields[0],
|
1240
1438
|
UPB_SIZE(64, 96), 7, kUpb_ExtMode_NonExtendable, 0, UPB_FASTTABLE_MASK(24), 0,
|
1439
|
+
#ifdef UPB_TRACING_ENABLED
|
1440
|
+
"google.protobuf.UninterpretedOption",
|
1441
|
+
#endif
|
1241
1442
|
UPB_FASTTABLE_INIT({
|
1242
1443
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1243
1444
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
@@ -1246,6 +1447,7 @@ const upb_MiniTable google__protobuf__UninterpretedOption_msg_init = {
|
|
1246
1447
|
})
|
1247
1448
|
};
|
1248
1449
|
|
1450
|
+
const upb_MiniTable* google__protobuf__UninterpretedOption_msg_init_ptr = &google__protobuf__UninterpretedOption_msg_init;
|
1249
1451
|
static const upb_MiniTableField google_protobuf_UninterpretedOption_NamePart__fields[2] = {
|
1250
1452
|
{1, UPB_SIZE(12, 16), 64, kUpb_NoSub, 12, (int)kUpb_FieldMode_Scalar | (int)kUpb_LabelFlags_IsAlternate | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)},
|
1251
1453
|
{2, 9, 65, kUpb_NoSub, 8, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_1Byte << kUpb_FieldRep_Shift)},
|
@@ -1255,9 +1457,13 @@ const upb_MiniTable google__protobuf__UninterpretedOption__NamePart_msg_init = {
|
|
1255
1457
|
NULL,
|
1256
1458
|
&google_protobuf_UninterpretedOption_NamePart__fields[0],
|
1257
1459
|
UPB_SIZE(24, 32), 2, kUpb_ExtMode_NonExtendable, 2, UPB_FASTTABLE_MASK(255), 2,
|
1460
|
+
#ifdef UPB_TRACING_ENABLED
|
1461
|
+
"google.protobuf.UninterpretedOption.NamePart",
|
1462
|
+
#endif
|
1258
1463
|
};
|
1259
1464
|
|
1260
|
-
|
1465
|
+
const upb_MiniTable* google__protobuf__UninterpretedOption__NamePart_msg_init_ptr = &google__protobuf__UninterpretedOption__NamePart_msg_init;
|
1466
|
+
static const upb_MiniTableSubInternal google_protobuf_FeatureSet_submsgs[6] = {
|
1261
1467
|
{.UPB_PRIVATE(subenum) = &google_protobuf_FeatureSet_FieldPresence_enum_init},
|
1262
1468
|
{.UPB_PRIVATE(subenum) = &google_protobuf_FeatureSet_EnumType_enum_init},
|
1263
1469
|
{.UPB_PRIVATE(subenum) = &google_protobuf_FeatureSet_RepeatedFieldEncoding_enum_init},
|
@@ -1279,10 +1485,14 @@ const upb_MiniTable google__protobuf__FeatureSet_msg_init = {
|
|
1279
1485
|
&google_protobuf_FeatureSet_submsgs[0],
|
1280
1486
|
&google_protobuf_FeatureSet__fields[0],
|
1281
1487
|
40, 6, kUpb_ExtMode_Extendable, 6, UPB_FASTTABLE_MASK(255), 0,
|
1488
|
+
#ifdef UPB_TRACING_ENABLED
|
1489
|
+
"google.protobuf.FeatureSet",
|
1490
|
+
#endif
|
1282
1491
|
};
|
1283
1492
|
|
1284
|
-
|
1285
|
-
|
1493
|
+
const upb_MiniTable* google__protobuf__FeatureSet_msg_init_ptr = &google__protobuf__FeatureSet_msg_init;
|
1494
|
+
static const upb_MiniTableSubInternal google_protobuf_FeatureSetDefaults_submsgs[3] = {
|
1495
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init_ptr},
|
1286
1496
|
{.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init},
|
1287
1497
|
{.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init},
|
1288
1498
|
};
|
@@ -1297,30 +1507,40 @@ const upb_MiniTable google__protobuf__FeatureSetDefaults_msg_init = {
|
|
1297
1507
|
&google_protobuf_FeatureSetDefaults_submsgs[0],
|
1298
1508
|
&google_protobuf_FeatureSetDefaults__fields[0],
|
1299
1509
|
UPB_SIZE(24, 32), 3, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(8), 0,
|
1510
|
+
#ifdef UPB_TRACING_ENABLED
|
1511
|
+
"google.protobuf.FeatureSetDefaults",
|
1512
|
+
#endif
|
1300
1513
|
UPB_FASTTABLE_INIT({
|
1301
1514
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1302
1515
|
{0x001800003f00000a, &upb_prm_1bt_max64b},
|
1303
1516
|
})
|
1304
1517
|
};
|
1305
1518
|
|
1306
|
-
|
1307
|
-
|
1519
|
+
const upb_MiniTable* google__protobuf__FeatureSetDefaults_msg_init_ptr = &google__protobuf__FeatureSetDefaults_msg_init;
|
1520
|
+
static const upb_MiniTableSubInternal google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_submsgs[3] = {
|
1521
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init_ptr},
|
1522
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__FeatureSet_msg_init_ptr},
|
1308
1523
|
{.UPB_PRIVATE(subenum) = &google_protobuf_Edition_enum_init},
|
1309
1524
|
};
|
1310
1525
|
|
1311
|
-
static const upb_MiniTableField google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault__fields[
|
1312
|
-
{
|
1313
|
-
{
|
1526
|
+
static const upb_MiniTableField google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault__fields[3] = {
|
1527
|
+
{3, 12, 64, 2, 14, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)},
|
1528
|
+
{4, 16, 65, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)},
|
1529
|
+
{5, UPB_SIZE(20, 24), 66, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)},
|
1314
1530
|
};
|
1315
1531
|
|
1316
1532
|
const upb_MiniTable google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init = {
|
1317
1533
|
&google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_submsgs[0],
|
1318
1534
|
&google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault__fields[0],
|
1319
|
-
24,
|
1535
|
+
UPB_SIZE(24, 32), 3, kUpb_ExtMode_NonExtendable, 0, UPB_FASTTABLE_MASK(255), 0,
|
1536
|
+
#ifdef UPB_TRACING_ENABLED
|
1537
|
+
"google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault",
|
1538
|
+
#endif
|
1320
1539
|
};
|
1321
1540
|
|
1322
|
-
|
1323
|
-
|
1541
|
+
const upb_MiniTable* google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init_ptr = &google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init;
|
1542
|
+
static const upb_MiniTableSubInternal google_protobuf_SourceCodeInfo_submsgs[1] = {
|
1543
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__SourceCodeInfo__Location_msg_init_ptr},
|
1324
1544
|
};
|
1325
1545
|
|
1326
1546
|
static const upb_MiniTableField google_protobuf_SourceCodeInfo__fields[1] = {
|
@@ -1331,12 +1551,16 @@ const upb_MiniTable google__protobuf__SourceCodeInfo_msg_init = {
|
|
1331
1551
|
&google_protobuf_SourceCodeInfo_submsgs[0],
|
1332
1552
|
&google_protobuf_SourceCodeInfo__fields[0],
|
1333
1553
|
16, 1, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(8), 0,
|
1554
|
+
#ifdef UPB_TRACING_ENABLED
|
1555
|
+
"google.protobuf.SourceCodeInfo",
|
1556
|
+
#endif
|
1334
1557
|
UPB_FASTTABLE_INIT({
|
1335
1558
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1336
1559
|
{0x000800003f00000a, &upb_prm_1bt_max128b},
|
1337
1560
|
})
|
1338
1561
|
};
|
1339
1562
|
|
1563
|
+
const upb_MiniTable* google__protobuf__SourceCodeInfo_msg_init_ptr = &google__protobuf__SourceCodeInfo_msg_init;
|
1340
1564
|
static const upb_MiniTableField google_protobuf_SourceCodeInfo_Location__fields[5] = {
|
1341
1565
|
{1, UPB_SIZE(12, 16), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)},
|
1342
1566
|
{2, UPB_SIZE(16, 24), 0, kUpb_NoSub, 5, (int)kUpb_FieldMode_Array | (int)kUpb_LabelFlags_IsPacked | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)},
|
@@ -1349,6 +1573,9 @@ const upb_MiniTable google__protobuf__SourceCodeInfo__Location_msg_init = {
|
|
1349
1573
|
NULL,
|
1350
1574
|
&google_protobuf_SourceCodeInfo_Location__fields[0],
|
1351
1575
|
UPB_SIZE(40, 72), 5, kUpb_ExtMode_NonExtendable, 4, UPB_FASTTABLE_MASK(56), 0,
|
1576
|
+
#ifdef UPB_TRACING_ENABLED
|
1577
|
+
"google.protobuf.SourceCodeInfo.Location",
|
1578
|
+
#endif
|
1352
1579
|
UPB_FASTTABLE_INIT({
|
1353
1580
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1354
1581
|
{0x001000003f00000a, &upb_ppv4_1bt},
|
@@ -1361,8 +1588,9 @@ const upb_MiniTable google__protobuf__SourceCodeInfo__Location_msg_init = {
|
|
1361
1588
|
})
|
1362
1589
|
};
|
1363
1590
|
|
1364
|
-
|
1365
|
-
|
1591
|
+
const upb_MiniTable* google__protobuf__SourceCodeInfo__Location_msg_init_ptr = &google__protobuf__SourceCodeInfo__Location_msg_init;
|
1592
|
+
static const upb_MiniTableSubInternal google_protobuf_GeneratedCodeInfo_submsgs[1] = {
|
1593
|
+
{.UPB_PRIVATE(submsg) = &google__protobuf__GeneratedCodeInfo__Annotation_msg_init_ptr},
|
1366
1594
|
};
|
1367
1595
|
|
1368
1596
|
static const upb_MiniTableField google_protobuf_GeneratedCodeInfo__fields[1] = {
|
@@ -1373,13 +1601,17 @@ const upb_MiniTable google__protobuf__GeneratedCodeInfo_msg_init = {
|
|
1373
1601
|
&google_protobuf_GeneratedCodeInfo_submsgs[0],
|
1374
1602
|
&google_protobuf_GeneratedCodeInfo__fields[0],
|
1375
1603
|
16, 1, kUpb_ExtMode_NonExtendable, 1, UPB_FASTTABLE_MASK(8), 0,
|
1604
|
+
#ifdef UPB_TRACING_ENABLED
|
1605
|
+
"google.protobuf.GeneratedCodeInfo",
|
1606
|
+
#endif
|
1376
1607
|
UPB_FASTTABLE_INIT({
|
1377
1608
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1378
1609
|
{0x000800003f00000a, &upb_prm_1bt_max64b},
|
1379
1610
|
})
|
1380
1611
|
};
|
1381
1612
|
|
1382
|
-
|
1613
|
+
const upb_MiniTable* google__protobuf__GeneratedCodeInfo_msg_init_ptr = &google__protobuf__GeneratedCodeInfo_msg_init;
|
1614
|
+
static const upb_MiniTableSubInternal google_protobuf_GeneratedCodeInfo_Annotation_submsgs[1] = {
|
1383
1615
|
{.UPB_PRIVATE(subenum) = &google_protobuf_GeneratedCodeInfo_Annotation_Semantic_enum_init},
|
1384
1616
|
};
|
1385
1617
|
|
@@ -1395,53 +1627,23 @@ const upb_MiniTable google__protobuf__GeneratedCodeInfo__Annotation_msg_init = {
|
|
1395
1627
|
&google_protobuf_GeneratedCodeInfo_Annotation_submsgs[0],
|
1396
1628
|
&google_protobuf_GeneratedCodeInfo_Annotation__fields[0],
|
1397
1629
|
UPB_SIZE(40, 48), 5, kUpb_ExtMode_NonExtendable, 5, UPB_FASTTABLE_MASK(8), 0,
|
1630
|
+
#ifdef UPB_TRACING_ENABLED
|
1631
|
+
"google.protobuf.GeneratedCodeInfo.Annotation",
|
1632
|
+
#endif
|
1398
1633
|
UPB_FASTTABLE_INIT({
|
1399
1634
|
{0x0000000000000000, &_upb_FastDecoder_DecodeGeneric},
|
1400
1635
|
{0x001800003f00000a, &upb_ppv4_1bt},
|
1401
1636
|
})
|
1402
1637
|
};
|
1403
1638
|
|
1404
|
-
|
1405
|
-
&google__protobuf__FileDescriptorSet_msg_init,
|
1406
|
-
&google__protobuf__FileDescriptorProto_msg_init,
|
1407
|
-
&google__protobuf__DescriptorProto_msg_init,
|
1408
|
-
&google__protobuf__DescriptorProto__ExtensionRange_msg_init,
|
1409
|
-
&google__protobuf__DescriptorProto__ReservedRange_msg_init,
|
1410
|
-
&google__protobuf__ExtensionRangeOptions_msg_init,
|
1411
|
-
&google__protobuf__ExtensionRangeOptions__Declaration_msg_init,
|
1412
|
-
&google__protobuf__FieldDescriptorProto_msg_init,
|
1413
|
-
&google__protobuf__OneofDescriptorProto_msg_init,
|
1414
|
-
&google__protobuf__EnumDescriptorProto_msg_init,
|
1415
|
-
&google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init,
|
1416
|
-
&google__protobuf__EnumValueDescriptorProto_msg_init,
|
1417
|
-
&google__protobuf__ServiceDescriptorProto_msg_init,
|
1418
|
-
&google__protobuf__MethodDescriptorProto_msg_init,
|
1419
|
-
&google__protobuf__FileOptions_msg_init,
|
1420
|
-
&google__protobuf__MessageOptions_msg_init,
|
1421
|
-
&google__protobuf__FieldOptions_msg_init,
|
1422
|
-
&google__protobuf__FieldOptions__EditionDefault_msg_init,
|
1423
|
-
&google__protobuf__OneofOptions_msg_init,
|
1424
|
-
&google__protobuf__EnumOptions_msg_init,
|
1425
|
-
&google__protobuf__EnumValueOptions_msg_init,
|
1426
|
-
&google__protobuf__ServiceOptions_msg_init,
|
1427
|
-
&google__protobuf__MethodOptions_msg_init,
|
1428
|
-
&google__protobuf__UninterpretedOption_msg_init,
|
1429
|
-
&google__protobuf__UninterpretedOption__NamePart_msg_init,
|
1430
|
-
&google__protobuf__FeatureSet_msg_init,
|
1431
|
-
&google__protobuf__FeatureSetDefaults_msg_init,
|
1432
|
-
&google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init,
|
1433
|
-
&google__protobuf__SourceCodeInfo_msg_init,
|
1434
|
-
&google__protobuf__SourceCodeInfo__Location_msg_init,
|
1435
|
-
&google__protobuf__GeneratedCodeInfo_msg_init,
|
1436
|
-
&google__protobuf__GeneratedCodeInfo__Annotation_msg_init,
|
1437
|
-
};
|
1438
|
-
|
1639
|
+
const upb_MiniTable* google__protobuf__GeneratedCodeInfo__Annotation_msg_init_ptr = &google__protobuf__GeneratedCodeInfo__Annotation_msg_init;
|
1439
1640
|
const upb_MiniTableEnum google_protobuf_Edition_enum_init = {
|
1440
1641
|
64,
|
1441
|
-
|
1642
|
+
9,
|
1442
1643
|
{
|
1443
1644
|
0x7,
|
1444
1645
|
0x0,
|
1646
|
+
0x384,
|
1445
1647
|
0x3e6,
|
1446
1648
|
0x3e7,
|
1447
1649
|
0x3e8,
|
@@ -1597,6 +1799,42 @@ const upb_MiniTableEnum google_protobuf_MethodOptions_IdempotencyLevel_enum_init
|
|
1597
1799
|
},
|
1598
1800
|
};
|
1599
1801
|
|
1802
|
+
static const upb_MiniTable *messages_layout[33] = {
|
1803
|
+
&google__protobuf__FileDescriptorSet_msg_init,
|
1804
|
+
&google__protobuf__FileDescriptorProto_msg_init,
|
1805
|
+
&google__protobuf__DescriptorProto_msg_init,
|
1806
|
+
&google__protobuf__DescriptorProto__ExtensionRange_msg_init,
|
1807
|
+
&google__protobuf__DescriptorProto__ReservedRange_msg_init,
|
1808
|
+
&google__protobuf__ExtensionRangeOptions_msg_init,
|
1809
|
+
&google__protobuf__ExtensionRangeOptions__Declaration_msg_init,
|
1810
|
+
&google__protobuf__FieldDescriptorProto_msg_init,
|
1811
|
+
&google__protobuf__OneofDescriptorProto_msg_init,
|
1812
|
+
&google__protobuf__EnumDescriptorProto_msg_init,
|
1813
|
+
&google__protobuf__EnumDescriptorProto__EnumReservedRange_msg_init,
|
1814
|
+
&google__protobuf__EnumValueDescriptorProto_msg_init,
|
1815
|
+
&google__protobuf__ServiceDescriptorProto_msg_init,
|
1816
|
+
&google__protobuf__MethodDescriptorProto_msg_init,
|
1817
|
+
&google__protobuf__FileOptions_msg_init,
|
1818
|
+
&google__protobuf__MessageOptions_msg_init,
|
1819
|
+
&google__protobuf__FieldOptions_msg_init,
|
1820
|
+
&google__protobuf__FieldOptions__EditionDefault_msg_init,
|
1821
|
+
&google__protobuf__FieldOptions__FeatureSupport_msg_init,
|
1822
|
+
&google__protobuf__OneofOptions_msg_init,
|
1823
|
+
&google__protobuf__EnumOptions_msg_init,
|
1824
|
+
&google__protobuf__EnumValueOptions_msg_init,
|
1825
|
+
&google__protobuf__ServiceOptions_msg_init,
|
1826
|
+
&google__protobuf__MethodOptions_msg_init,
|
1827
|
+
&google__protobuf__UninterpretedOption_msg_init,
|
1828
|
+
&google__protobuf__UninterpretedOption__NamePart_msg_init,
|
1829
|
+
&google__protobuf__FeatureSet_msg_init,
|
1830
|
+
&google__protobuf__FeatureSetDefaults_msg_init,
|
1831
|
+
&google__protobuf__FeatureSetDefaults__FeatureSetEditionDefault_msg_init,
|
1832
|
+
&google__protobuf__SourceCodeInfo_msg_init,
|
1833
|
+
&google__protobuf__SourceCodeInfo__Location_msg_init,
|
1834
|
+
&google__protobuf__GeneratedCodeInfo_msg_init,
|
1835
|
+
&google__protobuf__GeneratedCodeInfo__Annotation_msg_init,
|
1836
|
+
};
|
1837
|
+
|
1600
1838
|
static const upb_MiniTableEnum *enums_layout[17] = {
|
1601
1839
|
&google_protobuf_Edition_enum_init,
|
1602
1840
|
&google_protobuf_ExtensionRangeOptions_VerificationState_enum_init,
|
@@ -1621,7 +1859,7 @@ const upb_MiniTableFile google_protobuf_descriptor_proto_upb_file_layout = {
|
|
1621
1859
|
messages_layout,
|
1622
1860
|
enums_layout,
|
1623
1861
|
NULL,
|
1624
|
-
|
1862
|
+
33,
|
1625
1863
|
17,
|
1626
1864
|
0,
|
1627
1865
|
};
|
@@ -2482,6 +2720,7 @@ static upb_MessageValue jsondec_bool(jsondec* d, const upb_FieldDef* f) {
|
|
2482
2720
|
/* Composite types (array/message/map) ****************************************/
|
2483
2721
|
|
2484
2722
|
static void jsondec_array(jsondec* d, upb_Message* msg, const upb_FieldDef* f) {
|
2723
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2485
2724
|
upb_Array* arr = upb_Message_Mutable(msg, f, d->arena).array;
|
2486
2725
|
|
2487
2726
|
jsondec_arrstart(d);
|
@@ -2495,6 +2734,7 @@ static void jsondec_array(jsondec* d, upb_Message* msg, const upb_FieldDef* f) {
|
|
2495
2734
|
}
|
2496
2735
|
|
2497
2736
|
static void jsondec_map(jsondec* d, upb_Message* msg, const upb_FieldDef* f) {
|
2737
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2498
2738
|
upb_Map* map = upb_Message_Mutable(msg, f, d->arena).map;
|
2499
2739
|
const upb_MessageDef* entry = upb_FieldDef_MessageSubDef(f);
|
2500
2740
|
const upb_FieldDef* key_f = upb_MessageDef_FindFieldByNumber(entry, 1);
|
@@ -2516,6 +2756,7 @@ static void jsondec_map(jsondec* d, upb_Message* msg, const upb_FieldDef* f) {
|
|
2516
2756
|
|
2517
2757
|
static void jsondec_tomsg(jsondec* d, upb_Message* msg,
|
2518
2758
|
const upb_MessageDef* m) {
|
2759
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2519
2760
|
if (upb_MessageDef_WellKnownType(m) == kUpb_WellKnown_Unspecified) {
|
2520
2761
|
jsondec_object(d, msg, m);
|
2521
2762
|
} else {
|
@@ -2536,6 +2777,7 @@ static upb_MessageValue jsondec_msg(jsondec* d, const upb_FieldDef* f) {
|
|
2536
2777
|
|
2537
2778
|
static void jsondec_field(jsondec* d, upb_Message* msg,
|
2538
2779
|
const upb_MessageDef* m) {
|
2780
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2539
2781
|
upb_StringView name;
|
2540
2782
|
const upb_FieldDef* f;
|
2541
2783
|
const upb_FieldDef* preserved;
|
@@ -2574,7 +2816,7 @@ static void jsondec_field(jsondec* d, upb_Message* msg,
|
|
2574
2816
|
}
|
2575
2817
|
|
2576
2818
|
if (upb_FieldDef_RealContainingOneof(f) &&
|
2577
|
-
|
2819
|
+
upb_Message_WhichOneofByDef(msg, upb_FieldDef_ContainingOneof(f))) {
|
2578
2820
|
jsondec_err(d, "More than one field for this oneof.");
|
2579
2821
|
}
|
2580
2822
|
|
@@ -2601,6 +2843,7 @@ static void jsondec_field(jsondec* d, upb_Message* msg,
|
|
2601
2843
|
|
2602
2844
|
static void jsondec_object(jsondec* d, upb_Message* msg,
|
2603
2845
|
const upb_MessageDef* m) {
|
2846
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2604
2847
|
jsondec_objstart(d);
|
2605
2848
|
while (jsondec_objnext(d)) {
|
2606
2849
|
jsondec_field(d, msg, m);
|
@@ -2701,6 +2944,7 @@ static int64_t jsondec_unixtime(int y, int m, int d, int h, int min, int s) {
|
|
2701
2944
|
|
2702
2945
|
static void jsondec_timestamp(jsondec* d, upb_Message* msg,
|
2703
2946
|
const upb_MessageDef* m) {
|
2947
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2704
2948
|
upb_MessageValue seconds;
|
2705
2949
|
upb_MessageValue nanos;
|
2706
2950
|
upb_StringView str = jsondec_string(d);
|
@@ -2766,6 +3010,7 @@ malformed:
|
|
2766
3010
|
|
2767
3011
|
static void jsondec_duration(jsondec* d, upb_Message* msg,
|
2768
3012
|
const upb_MessageDef* m) {
|
3013
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2769
3014
|
upb_MessageValue seconds;
|
2770
3015
|
upb_MessageValue nanos;
|
2771
3016
|
upb_StringView str = jsondec_string(d);
|
@@ -2798,6 +3043,7 @@ static void jsondec_duration(jsondec* d, upb_Message* msg,
|
|
2798
3043
|
|
2799
3044
|
static void jsondec_listvalue(jsondec* d, upb_Message* msg,
|
2800
3045
|
const upb_MessageDef* m) {
|
3046
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2801
3047
|
const upb_FieldDef* values_f = upb_MessageDef_FindFieldByNumber(m, 1);
|
2802
3048
|
const upb_MessageDef* value_m = upb_FieldDef_MessageSubDef(values_f);
|
2803
3049
|
const upb_MiniTable* value_layout = upb_MessageDef_MiniTable(value_m);
|
@@ -2816,6 +3062,7 @@ static void jsondec_listvalue(jsondec* d, upb_Message* msg,
|
|
2816
3062
|
|
2817
3063
|
static void jsondec_struct(jsondec* d, upb_Message* msg,
|
2818
3064
|
const upb_MessageDef* m) {
|
3065
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2819
3066
|
const upb_FieldDef* fields_f = upb_MessageDef_FindFieldByNumber(m, 1);
|
2820
3067
|
const upb_MessageDef* entry_m = upb_FieldDef_MessageSubDef(fields_f);
|
2821
3068
|
const upb_FieldDef* value_f = upb_MessageDef_FindFieldByNumber(entry_m, 2);
|
@@ -2838,6 +3085,7 @@ static void jsondec_struct(jsondec* d, upb_Message* msg,
|
|
2838
3085
|
|
2839
3086
|
static void jsondec_wellknownvalue(jsondec* d, upb_Message* msg,
|
2840
3087
|
const upb_MessageDef* m) {
|
3088
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2841
3089
|
upb_MessageValue val;
|
2842
3090
|
const upb_FieldDef* f;
|
2843
3091
|
upb_Message* submsg;
|
@@ -2926,6 +3174,7 @@ static upb_StringView jsondec_mask(jsondec* d, const char* buf,
|
|
2926
3174
|
|
2927
3175
|
static void jsondec_fieldmask(jsondec* d, upb_Message* msg,
|
2928
3176
|
const upb_MessageDef* m) {
|
3177
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2929
3178
|
/* repeated string paths = 1; */
|
2930
3179
|
const upb_FieldDef* paths_f = upb_MessageDef_FindFieldByNumber(m, 1);
|
2931
3180
|
upb_Array* arr = upb_Message_Mutable(msg, paths_f, d->arena).array;
|
@@ -2949,6 +3198,7 @@ static void jsondec_fieldmask(jsondec* d, upb_Message* msg,
|
|
2949
3198
|
|
2950
3199
|
static void jsondec_anyfield(jsondec* d, upb_Message* msg,
|
2951
3200
|
const upb_MessageDef* m) {
|
3201
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2952
3202
|
if (upb_MessageDef_WellKnownType(m) == kUpb_WellKnown_Unspecified) {
|
2953
3203
|
/* For regular types: {"@type": "[user type]", "f1": <V1>, "f2": <V2>}
|
2954
3204
|
* where f1, f2, etc. are the normal fields of this type. */
|
@@ -2967,6 +3217,7 @@ static void jsondec_anyfield(jsondec* d, upb_Message* msg,
|
|
2967
3217
|
|
2968
3218
|
static const upb_MessageDef* jsondec_typeurl(jsondec* d, upb_Message* msg,
|
2969
3219
|
const upb_MessageDef* m) {
|
3220
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2970
3221
|
const upb_FieldDef* type_url_f = upb_MessageDef_FindFieldByNumber(m, 1);
|
2971
3222
|
const upb_MessageDef* type_m;
|
2972
3223
|
upb_StringView type_url = jsondec_string(d);
|
@@ -2996,6 +3247,7 @@ static const upb_MessageDef* jsondec_typeurl(jsondec* d, upb_Message* msg,
|
|
2996
3247
|
}
|
2997
3248
|
|
2998
3249
|
static void jsondec_any(jsondec* d, upb_Message* msg, const upb_MessageDef* m) {
|
3250
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
2999
3251
|
/* string type_url = 1;
|
3000
3252
|
* bytes value = 2; */
|
3001
3253
|
const upb_FieldDef* value_f = upb_MessageDef_FindFieldByNumber(m, 2);
|
@@ -3064,6 +3316,7 @@ static void jsondec_any(jsondec* d, upb_Message* msg, const upb_MessageDef* m) {
|
|
3064
3316
|
|
3065
3317
|
static void jsondec_wrapper(jsondec* d, upb_Message* msg,
|
3066
3318
|
const upb_MessageDef* m) {
|
3319
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
3067
3320
|
const upb_FieldDef* value_f = upb_MessageDef_FindFieldByNumber(m, 1);
|
3068
3321
|
upb_JsonMessageValue val = jsondec_value(d, value_f);
|
3069
3322
|
UPB_ASSUME(val.ignore == false); // Wrapper cannot be an enum.
|
@@ -3072,6 +3325,7 @@ static void jsondec_wrapper(jsondec* d, upb_Message* msg,
|
|
3072
3325
|
|
3073
3326
|
static void jsondec_wellknown(jsondec* d, upb_Message* msg,
|
3074
3327
|
const upb_MessageDef* m) {
|
3328
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
3075
3329
|
switch (upb_MessageDef_WellKnownType(m)) {
|
3076
3330
|
case kUpb_WellKnown_Any:
|
3077
3331
|
jsondec_any(d, msg, m);
|
@@ -3112,6 +3366,7 @@ static void jsondec_wellknown(jsondec* d, upb_Message* msg,
|
|
3112
3366
|
|
3113
3367
|
static bool upb_JsonDecoder_Decode(jsondec* const d, upb_Message* const msg,
|
3114
3368
|
const upb_MessageDef* const m) {
|
3369
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
3115
3370
|
if (UPB_SETJMP(d->err)) return false;
|
3116
3371
|
|
3117
3372
|
jsondec_tomsg(d, msg, m);
|
@@ -3131,6 +3386,7 @@ static bool upb_JsonDecoder_Decode(jsondec* const d, upb_Message* const msg,
|
|
3131
3386
|
bool upb_JsonDecode(const char* buf, size_t size, upb_Message* msg,
|
3132
3387
|
const upb_MessageDef* m, const upb_DefPool* symtab,
|
3133
3388
|
int options, upb_Arena* arena, upb_Status* status) {
|
3389
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
3134
3390
|
jsondec d;
|
3135
3391
|
|
3136
3392
|
if (size == 0) return true;
|
@@ -3185,7 +3441,7 @@ static void jsonenc_value(jsonenc* e, const upb_Message* msg,
|
|
3185
3441
|
|
3186
3442
|
UPB_NORETURN static void jsonenc_err(jsonenc* e, const char* msg) {
|
3187
3443
|
upb_Status_SetErrorMessage(e->status, msg);
|
3188
|
-
|
3444
|
+
UPB_LONGJMP(e->err, 1);
|
3189
3445
|
}
|
3190
3446
|
|
3191
3447
|
UPB_PRINTF(2, 3)
|
@@ -3194,7 +3450,7 @@ UPB_NORETURN static void jsonenc_errf(jsonenc* e, const char* fmt, ...) {
|
|
3194
3450
|
va_start(argp, fmt);
|
3195
3451
|
upb_Status_VSetErrorFormat(e->status, fmt, argp);
|
3196
3452
|
va_end(argp);
|
3197
|
-
|
3453
|
+
UPB_LONGJMP(e->err, 1);
|
3198
3454
|
}
|
3199
3455
|
|
3200
3456
|
static upb_Arena* jsonenc_arena(jsonenc* e) {
|
@@ -3941,12 +4197,20 @@ static void* upb_global_allocfunc(upb_alloc* alloc, void* ptr, size_t oldsize,
|
|
3941
4197
|
upb_alloc upb_alloc_global = {&upb_global_allocfunc};
|
3942
4198
|
|
3943
4199
|
|
4200
|
+
#ifdef UPB_TRACING_ENABLED
|
4201
|
+
#include <stdatomic.h>
|
4202
|
+
#endif
|
4203
|
+
|
3944
4204
|
#include <stddef.h>
|
3945
4205
|
#include <stdint.h>
|
3946
4206
|
|
3947
4207
|
|
3948
4208
|
// Must be last.
|
3949
4209
|
|
4210
|
+
static UPB_ATOMIC(size_t) max_block_size = 32 << 10;
|
4211
|
+
|
4212
|
+
void upb_Arena_SetMaxBlockSize(size_t max) { max_block_size = max; }
|
4213
|
+
|
3950
4214
|
typedef struct upb_MemBlock {
|
3951
4215
|
// Atomic only for the benefit of SpaceAllocated().
|
3952
4216
|
UPB_ATOMIC(struct upb_MemBlock*) next;
|
@@ -4047,6 +4311,38 @@ static bool _upb_ArenaInternal_HasInitialBlock(upb_ArenaInternal* ai) {
|
|
4047
4311
|
return ai->block_alloc & 0x1;
|
4048
4312
|
}
|
4049
4313
|
|
4314
|
+
#ifdef UPB_TRACING_ENABLED
|
4315
|
+
static void (*_init_arena_trace_handler)(const upb_Arena*, size_t size) = NULL;
|
4316
|
+
static void (*_fuse_arena_trace_handler)(const upb_Arena*,
|
4317
|
+
const upb_Arena*) = NULL;
|
4318
|
+
static void (*_free_arena_trace_handler)(const upb_Arena*) = NULL;
|
4319
|
+
|
4320
|
+
void upb_Arena_SetTraceHandler(
|
4321
|
+
void (*initArenaTraceHandler)(const upb_Arena*, size_t size),
|
4322
|
+
void (*fuseArenaTraceHandler)(const upb_Arena*, const upb_Arena*),
|
4323
|
+
void (*freeArenaTraceHandler)(const upb_Arena*)) {
|
4324
|
+
_init_arena_trace_handler = initArenaTraceHandler;
|
4325
|
+
_fuse_arena_trace_handler = fuseArenaTraceHandler;
|
4326
|
+
_free_arena_trace_handler = freeArenaTraceHandler;
|
4327
|
+
}
|
4328
|
+
|
4329
|
+
void upb_Arena_LogInit(const upb_Arena* arena, size_t size) {
|
4330
|
+
if (_init_arena_trace_handler) {
|
4331
|
+
_init_arena_trace_handler(arena, size);
|
4332
|
+
}
|
4333
|
+
}
|
4334
|
+
void upb_Arena_LogFuse(const upb_Arena* arena1, const upb_Arena* arena2) {
|
4335
|
+
if (_fuse_arena_trace_handler) {
|
4336
|
+
_fuse_arena_trace_handler(arena1, arena2);
|
4337
|
+
}
|
4338
|
+
}
|
4339
|
+
void upb_Arena_LogFree(const upb_Arena* arena) {
|
4340
|
+
if (_free_arena_trace_handler) {
|
4341
|
+
_free_arena_trace_handler(arena);
|
4342
|
+
}
|
4343
|
+
}
|
4344
|
+
#endif // UPB_TRACING_ENABLED
|
4345
|
+
|
4050
4346
|
static upb_ArenaRoot _upb_Arena_FindRoot(upb_Arena* a) {
|
4051
4347
|
upb_ArenaInternal* ai = upb_Arena_Internal(a);
|
4052
4348
|
uintptr_t poc = upb_Atomic_Load(&ai->parent_or_count, memory_order_acquire);
|
@@ -4104,6 +4400,21 @@ size_t upb_Arena_SpaceAllocated(upb_Arena* arena, size_t* fused_count) {
|
|
4104
4400
|
return memsize;
|
4105
4401
|
}
|
4106
4402
|
|
4403
|
+
bool UPB_PRIVATE(_upb_Arena_Contains)(const upb_Arena* a, void* ptr) {
|
4404
|
+
upb_ArenaInternal* ai = upb_Arena_Internal(a);
|
4405
|
+
UPB_ASSERT(ai);
|
4406
|
+
|
4407
|
+
upb_MemBlock* block = upb_Atomic_Load(&ai->blocks, memory_order_relaxed);
|
4408
|
+
while (block) {
|
4409
|
+
uintptr_t beg = (uintptr_t)block;
|
4410
|
+
uintptr_t end = beg + block->size;
|
4411
|
+
if ((uintptr_t)ptr >= beg && (uintptr_t)ptr < end) return true;
|
4412
|
+
block = upb_Atomic_Load(&block->next, memory_order_relaxed);
|
4413
|
+
}
|
4414
|
+
|
4415
|
+
return false;
|
4416
|
+
}
|
4417
|
+
|
4107
4418
|
uint32_t upb_Arena_DebugRefCount(upb_Arena* a) {
|
4108
4419
|
upb_ArenaInternal* ai = upb_Arena_Internal(a);
|
4109
4420
|
// These loads could probably be relaxed, but given that this is debug-only,
|
@@ -4137,7 +4448,14 @@ static bool _upb_Arena_AllocBlock(upb_Arena* a, size_t size) {
|
|
4137
4448
|
if (!ai->block_alloc) return false;
|
4138
4449
|
upb_MemBlock* last_block = upb_Atomic_Load(&ai->blocks, memory_order_acquire);
|
4139
4450
|
size_t last_size = last_block != NULL ? last_block->size : 128;
|
4140
|
-
|
4451
|
+
|
4452
|
+
// Don't naturally grow beyond the max block size.
|
4453
|
+
size_t clamped_size = UPB_MIN(last_size * 2, max_block_size);
|
4454
|
+
|
4455
|
+
// We may need to exceed the max block size if the user requested a large
|
4456
|
+
// allocation.
|
4457
|
+
size_t block_size = UPB_MAX(size, clamped_size) + kUpb_MemblockReserve;
|
4458
|
+
|
4141
4459
|
upb_MemBlock* block =
|
4142
4460
|
upb_malloc(_upb_ArenaInternal_BlockAlloc(ai), block_size);
|
4143
4461
|
|
@@ -4195,7 +4513,13 @@ upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc) {
|
|
4195
4513
|
n = UPB_ALIGN_DOWN(n, UPB_ALIGN_OF(upb_ArenaState));
|
4196
4514
|
|
4197
4515
|
if (UPB_UNLIKELY(n < sizeof(upb_ArenaState))) {
|
4516
|
+
#ifdef UPB_TRACING_ENABLED
|
4517
|
+
upb_Arena* ret = _upb_Arena_InitSlow(alloc);
|
4518
|
+
upb_Arena_LogInit(ret, n);
|
4519
|
+
return ret;
|
4520
|
+
#else
|
4198
4521
|
return _upb_Arena_InitSlow(alloc);
|
4522
|
+
#endif
|
4199
4523
|
}
|
4200
4524
|
|
4201
4525
|
a = UPB_PTR_AT(mem, n - sizeof(upb_ArenaState), upb_ArenaState);
|
@@ -4208,13 +4532,14 @@ upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc) {
|
|
4208
4532
|
a->body.block_alloc = _upb_Arena_MakeBlockAlloc(alloc, 1);
|
4209
4533
|
a->head.UPB_PRIVATE(ptr) = mem;
|
4210
4534
|
a->head.UPB_PRIVATE(end) = UPB_PTR_AT(mem, n - sizeof(upb_ArenaState), char);
|
4211
|
-
|
4535
|
+
#ifdef UPB_TRACING_ENABLED
|
4536
|
+
upb_Arena_LogInit(&a->head, n);
|
4537
|
+
#endif
|
4212
4538
|
return &a->head;
|
4213
4539
|
}
|
4214
4540
|
|
4215
4541
|
static void _upb_Arena_DoFree(upb_ArenaInternal* ai) {
|
4216
4542
|
UPB_ASSERT(_upb_Arena_RefCountFromTagged(ai->parent_or_count) == 1);
|
4217
|
-
|
4218
4543
|
while (ai != NULL) {
|
4219
4544
|
// Load first since arena itself is likely from one of its blocks.
|
4220
4545
|
upb_ArenaInternal* next_arena =
|
@@ -4245,6 +4570,9 @@ retry:
|
|
4245
4570
|
// expensive then direct loads. As an optimization, we only do RMW ops
|
4246
4571
|
// when we need to update things for other threads to see.
|
4247
4572
|
if (poc == _upb_Arena_TaggedFromRefcount(1)) {
|
4573
|
+
#ifdef UPB_TRACING_ENABLED
|
4574
|
+
upb_Arena_LogFree(a);
|
4575
|
+
#endif
|
4248
4576
|
_upb_Arena_DoFree(ai);
|
4249
4577
|
return;
|
4250
4578
|
}
|
@@ -4364,6 +4692,10 @@ static bool _upb_Arena_FixupRefs(upb_ArenaInternal* new_root,
|
|
4364
4692
|
bool upb_Arena_Fuse(upb_Arena* a1, upb_Arena* a2) {
|
4365
4693
|
if (a1 == a2) return true; // trivial fuse
|
4366
4694
|
|
4695
|
+
#ifdef UPB_TRACING_ENABLED
|
4696
|
+
upb_Arena_LogFuse(a1, a2);
|
4697
|
+
#endif
|
4698
|
+
|
4367
4699
|
upb_ArenaInternal* ai1 = upb_Arena_Internal(a1);
|
4368
4700
|
upb_ArenaInternal* ai2 = upb_Arena_Internal(a2);
|
4369
4701
|
|
@@ -4430,18 +4762,17 @@ void UPB_PRIVATE(_upb_Arena_SwapOut)(upb_Arena* des, const upb_Arena* src) {
|
|
4430
4762
|
|
4431
4763
|
// Must be last.
|
4432
4764
|
|
4433
|
-
bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable*
|
4765
|
+
bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* m,
|
4434
4766
|
const upb_MiniTableField* f,
|
4435
4767
|
upb_Message* map_entry_message, upb_Arena* arena) {
|
4436
|
-
|
4437
|
-
const upb_MiniTable* map_entry_mini_table =
|
4438
|
-
|
4768
|
+
UPB_ASSERT(!upb_Message_IsFrozen(map_entry_message));
|
4769
|
+
const upb_MiniTable* map_entry_mini_table =
|
4770
|
+
upb_MiniTable_MapEntrySubMessage(m, f);
|
4439
4771
|
UPB_ASSERT(map_entry_mini_table);
|
4440
|
-
UPB_ASSERT(map_entry_mini_table->UPB_PRIVATE(field_count) == 2);
|
4441
4772
|
const upb_MiniTableField* map_entry_key_field =
|
4442
|
-
|
4773
|
+
upb_MiniTable_MapKey(map_entry_mini_table);
|
4443
4774
|
const upb_MiniTableField* map_entry_value_field =
|
4444
|
-
|
4775
|
+
upb_MiniTable_MapValue(map_entry_mini_table);
|
4445
4776
|
// Map key/value cannot have explicit defaults,
|
4446
4777
|
// hence assuming a zero default is valid.
|
4447
4778
|
upb_MessageValue default_val;
|
@@ -4466,31 +4797,33 @@ upb_Array* upb_Array_New(upb_Arena* a, upb_CType type) {
|
|
4466
4797
|
}
|
4467
4798
|
|
4468
4799
|
upb_MessageValue upb_Array_Get(const upb_Array* arr, size_t i) {
|
4800
|
+
UPB_ASSERT(i < upb_Array_Size(arr));
|
4469
4801
|
upb_MessageValue ret;
|
4470
4802
|
const char* data = upb_Array_DataPtr(arr);
|
4471
4803
|
const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr);
|
4472
|
-
UPB_ASSERT(i < arr->UPB_PRIVATE(size));
|
4473
4804
|
memcpy(&ret, data + (i << lg2), 1 << lg2);
|
4474
4805
|
return ret;
|
4475
4806
|
}
|
4476
4807
|
|
4477
4808
|
upb_MutableMessageValue upb_Array_GetMutable(upb_Array* arr, size_t i) {
|
4809
|
+
UPB_ASSERT(i < upb_Array_Size(arr));
|
4478
4810
|
upb_MutableMessageValue ret;
|
4479
4811
|
char* data = upb_Array_MutableDataPtr(arr);
|
4480
4812
|
const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr);
|
4481
|
-
UPB_ASSERT(i < arr->UPB_PRIVATE(size));
|
4482
4813
|
memcpy(&ret, data + (i << lg2), 1 << lg2);
|
4483
4814
|
return ret;
|
4484
4815
|
}
|
4485
4816
|
|
4486
4817
|
void upb_Array_Set(upb_Array* arr, size_t i, upb_MessageValue val) {
|
4818
|
+
UPB_ASSERT(!upb_Array_IsFrozen(arr));
|
4819
|
+
UPB_ASSERT(i < upb_Array_Size(arr));
|
4487
4820
|
char* data = upb_Array_MutableDataPtr(arr);
|
4488
4821
|
const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr);
|
4489
|
-
UPB_ASSERT(i < arr->UPB_PRIVATE(size));
|
4490
4822
|
memcpy(data + (i << lg2), &val, 1 << lg2);
|
4491
4823
|
}
|
4492
4824
|
|
4493
4825
|
bool upb_Array_Append(upb_Array* arr, upb_MessageValue val, upb_Arena* arena) {
|
4826
|
+
UPB_ASSERT(!upb_Array_IsFrozen(arr));
|
4494
4827
|
UPB_ASSERT(arena);
|
4495
4828
|
if (!UPB_PRIVATE(_upb_Array_ResizeUninitialized)(
|
4496
4829
|
arr, arr->UPB_PRIVATE(size) + 1, arena)) {
|
@@ -4502,6 +4835,7 @@ bool upb_Array_Append(upb_Array* arr, upb_MessageValue val, upb_Arena* arena) {
|
|
4502
4835
|
|
4503
4836
|
void upb_Array_Move(upb_Array* arr, size_t dst_idx, size_t src_idx,
|
4504
4837
|
size_t count) {
|
4838
|
+
UPB_ASSERT(!upb_Array_IsFrozen(arr));
|
4505
4839
|
const int lg2 = UPB_PRIVATE(_upb_Array_ElemSizeLg2)(arr);
|
4506
4840
|
char* data = upb_Array_MutableDataPtr(arr);
|
4507
4841
|
memmove(&data[dst_idx << lg2], &data[src_idx << lg2], count << lg2);
|
@@ -4509,6 +4843,7 @@ void upb_Array_Move(upb_Array* arr, size_t dst_idx, size_t src_idx,
|
|
4509
4843
|
|
4510
4844
|
bool upb_Array_Insert(upb_Array* arr, size_t i, size_t count,
|
4511
4845
|
upb_Arena* arena) {
|
4846
|
+
UPB_ASSERT(!upb_Array_IsFrozen(arr));
|
4512
4847
|
UPB_ASSERT(arena);
|
4513
4848
|
UPB_ASSERT(i <= arr->UPB_PRIVATE(size));
|
4514
4849
|
UPB_ASSERT(count + arr->UPB_PRIVATE(size) >= count);
|
@@ -4526,6 +4861,7 @@ bool upb_Array_Insert(upb_Array* arr, size_t i, size_t count,
|
|
4526
4861
|
* |------------|XXXXXXXX|--------|
|
4527
4862
|
*/
|
4528
4863
|
void upb_Array_Delete(upb_Array* arr, size_t i, size_t count) {
|
4864
|
+
UPB_ASSERT(!upb_Array_IsFrozen(arr));
|
4529
4865
|
const size_t end = i + count;
|
4530
4866
|
UPB_ASSERT(i <= end);
|
4531
4867
|
UPB_ASSERT(end <= arr->UPB_PRIVATE(size));
|
@@ -4534,6 +4870,7 @@ void upb_Array_Delete(upb_Array* arr, size_t i, size_t count) {
|
|
4534
4870
|
}
|
4535
4871
|
|
4536
4872
|
bool upb_Array_Resize(upb_Array* arr, size_t size, upb_Arena* arena) {
|
4873
|
+
UPB_ASSERT(!upb_Array_IsFrozen(arr));
|
4537
4874
|
const size_t oldsize = arr->UPB_PRIVATE(size);
|
4538
4875
|
if (UPB_UNLIKELY(
|
4539
4876
|
!UPB_PRIVATE(_upb_Array_ResizeUninitialized)(arr, size, arena))) {
|
@@ -4567,6 +4904,20 @@ bool UPB_PRIVATE(_upb_Array_Realloc)(upb_Array* array, size_t min_capacity,
|
|
4567
4904
|
return true;
|
4568
4905
|
}
|
4569
4906
|
|
4907
|
+
void upb_Array_Freeze(upb_Array* arr, const upb_MiniTable* m) {
|
4908
|
+
if (upb_Array_IsFrozen(arr)) return;
|
4909
|
+
UPB_PRIVATE(_upb_Array_ShallowFreeze)(arr);
|
4910
|
+
|
4911
|
+
if (m) {
|
4912
|
+
const size_t size = upb_Array_Size(arr);
|
4913
|
+
|
4914
|
+
for (size_t i = 0; i < size; i++) {
|
4915
|
+
upb_MessageValue val = upb_Array_Get(arr, i);
|
4916
|
+
upb_Message_Freeze((upb_Message*)val.msg_val, m);
|
4917
|
+
}
|
4918
|
+
}
|
4919
|
+
}
|
4920
|
+
|
4570
4921
|
|
4571
4922
|
#include <stddef.h>
|
4572
4923
|
#include <stdint.h>
|
@@ -4583,19 +4934,20 @@ const upb_MiniTableExtension* upb_Message_ExtensionByIndex(
|
|
4583
4934
|
return ext[index].ext;
|
4584
4935
|
}
|
4585
4936
|
|
4586
|
-
const
|
4587
|
-
|
4937
|
+
const upb_MiniTableExtension* upb_Message_FindExtensionByNumber(
|
4938
|
+
const upb_Message* msg, uint32_t field_number) {
|
4588
4939
|
size_t count;
|
4589
4940
|
const upb_Extension* ext = UPB_PRIVATE(_upb_Message_Getexts)(msg, &count);
|
4590
4941
|
|
4591
|
-
|
4592
|
-
|
4593
|
-
|
4942
|
+
for (; count--; ext++) {
|
4943
|
+
const upb_MiniTableExtension* e = ext->ext;
|
4944
|
+
if (upb_MiniTableExtension_Number(e) == field_number) return e;
|
4594
4945
|
}
|
4595
4946
|
return NULL;
|
4596
4947
|
}
|
4597
4948
|
|
4598
4949
|
|
4950
|
+
#include <stdint.h>
|
4599
4951
|
#include <string.h>
|
4600
4952
|
|
4601
4953
|
|
@@ -4694,6 +5046,20 @@ upb_MessageValue upb_MapIterator_Value(const upb_Map* map, size_t iter) {
|
|
4694
5046
|
return ret;
|
4695
5047
|
}
|
4696
5048
|
|
5049
|
+
void upb_Map_Freeze(upb_Map* map, const upb_MiniTable* m) {
|
5050
|
+
if (upb_Map_IsFrozen(map)) return;
|
5051
|
+
UPB_PRIVATE(_upb_Map_ShallowFreeze)(map);
|
5052
|
+
|
5053
|
+
if (m) {
|
5054
|
+
size_t iter = kUpb_Map_Begin;
|
5055
|
+
upb_MessageValue key, val;
|
5056
|
+
|
5057
|
+
while (upb_Map_Next(map, &key, &val, &iter)) {
|
5058
|
+
upb_Message_Freeze((upb_Message*)val.msg_val, m);
|
5059
|
+
}
|
5060
|
+
}
|
5061
|
+
}
|
5062
|
+
|
4697
5063
|
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
|
4698
5064
|
|
4699
5065
|
upb_Map* _upb_Map_New(upb_Arena* a, size_t key_size, size_t value_size) {
|
@@ -4703,6 +5069,7 @@ upb_Map* _upb_Map_New(upb_Arena* a, size_t key_size, size_t value_size) {
|
|
4703
5069
|
upb_strtable_init(&map->table, 4, a);
|
4704
5070
|
map->key_size = key_size;
|
4705
5071
|
map->val_size = value_size;
|
5072
|
+
map->UPB_PRIVATE(is_frozen) = false;
|
4706
5073
|
|
4707
5074
|
return map;
|
4708
5075
|
}
|
@@ -4866,22 +5233,24 @@ upb_Message* upb_Message_New(const upb_MiniTable* m, upb_Arena* a) {
|
|
4866
5233
|
|
4867
5234
|
bool UPB_PRIVATE(_upb_Message_AddUnknown)(upb_Message* msg, const char* data,
|
4868
5235
|
size_t len, upb_Arena* arena) {
|
5236
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
4869
5237
|
if (!UPB_PRIVATE(_upb_Message_Realloc)(msg, len, arena)) return false;
|
4870
|
-
upb_Message_Internal* in = msg
|
5238
|
+
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
4871
5239
|
memcpy(UPB_PTR_AT(in, in->unknown_end, char), data, len);
|
4872
5240
|
in->unknown_end += len;
|
4873
5241
|
return true;
|
4874
5242
|
}
|
4875
5243
|
|
4876
5244
|
void _upb_Message_DiscardUnknown_shallow(upb_Message* msg) {
|
4877
|
-
|
5245
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
5246
|
+
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
4878
5247
|
if (in) {
|
4879
5248
|
in->unknown_end = message_overhead;
|
4880
5249
|
}
|
4881
5250
|
}
|
4882
5251
|
|
4883
5252
|
const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len) {
|
4884
|
-
upb_Message_Internal* in = msg
|
5253
|
+
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
4885
5254
|
if (in) {
|
4886
5255
|
*len = in->unknown_end - message_overhead;
|
4887
5256
|
return (char*)(in + 1);
|
@@ -4892,7 +5261,8 @@ const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len) {
|
|
4892
5261
|
}
|
4893
5262
|
|
4894
5263
|
void upb_Message_DeleteUnknown(upb_Message* msg, const char* data, size_t len) {
|
4895
|
-
|
5264
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
5265
|
+
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
4896
5266
|
const char* internal_unknown_end = UPB_PTR_AT(in, in->unknown_end, char);
|
4897
5267
|
|
4898
5268
|
#ifndef NDEBUG
|
@@ -4916,35 +5286,242 @@ size_t upb_Message_ExtensionCount(const upb_Message* msg) {
|
|
4916
5286
|
return count;
|
4917
5287
|
}
|
4918
5288
|
|
5289
|
+
void upb_Message_Freeze(upb_Message* msg, const upb_MiniTable* m) {
|
5290
|
+
if (upb_Message_IsFrozen(msg)) return;
|
5291
|
+
UPB_PRIVATE(_upb_Message_ShallowFreeze)(msg);
|
5292
|
+
|
5293
|
+
// Base Fields.
|
5294
|
+
const size_t field_count = upb_MiniTable_FieldCount(m);
|
5295
|
+
|
5296
|
+
for (size_t i = 0; i < field_count; i++) {
|
5297
|
+
const upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, i);
|
5298
|
+
const upb_MiniTable* m2 = upb_MiniTable_SubMessage(m, f);
|
5299
|
+
|
5300
|
+
switch (UPB_PRIVATE(_upb_MiniTableField_Mode)(f)) {
|
5301
|
+
case kUpb_FieldMode_Array: {
|
5302
|
+
upb_Array* arr = upb_Message_GetMutableArray(msg, f);
|
5303
|
+
if (arr) upb_Array_Freeze(arr, m2);
|
5304
|
+
break;
|
5305
|
+
}
|
5306
|
+
case kUpb_FieldMode_Map: {
|
5307
|
+
upb_Map* map = upb_Message_GetMutableMap(msg, f);
|
5308
|
+
if (map) {
|
5309
|
+
const upb_MiniTableField* f2 = upb_MiniTable_MapValue(m2);
|
5310
|
+
const upb_MiniTable* m3 = upb_MiniTable_SubMessage(m2, f2);
|
5311
|
+
upb_Map_Freeze(map, m3);
|
5312
|
+
}
|
5313
|
+
break;
|
5314
|
+
}
|
5315
|
+
case kUpb_FieldMode_Scalar: {
|
5316
|
+
if (m2) {
|
5317
|
+
upb_Message* msg2 = upb_Message_GetMutableMessage(msg, f);
|
5318
|
+
if (msg2) upb_Message_Freeze(msg2, m2);
|
5319
|
+
}
|
5320
|
+
break;
|
5321
|
+
}
|
5322
|
+
}
|
5323
|
+
}
|
5324
|
+
|
5325
|
+
// Extensions.
|
5326
|
+
size_t ext_count;
|
5327
|
+
const upb_Extension* ext = UPB_PRIVATE(_upb_Message_Getexts)(msg, &ext_count);
|
5328
|
+
|
5329
|
+
for (size_t i = 0; i < ext_count; i++) {
|
5330
|
+
const upb_MiniTableExtension* e = ext[i].ext;
|
5331
|
+
const upb_MiniTableField* f = &e->UPB_PRIVATE(field);
|
5332
|
+
const upb_MiniTable* m2 = upb_MiniTableExtension_GetSubMessage(e);
|
5333
|
+
|
5334
|
+
upb_MessageValue val;
|
5335
|
+
memcpy(&val, &ext[i].data, sizeof(upb_MessageValue));
|
5336
|
+
|
5337
|
+
switch (UPB_PRIVATE(_upb_MiniTableField_Mode)(f)) {
|
5338
|
+
case kUpb_FieldMode_Array: {
|
5339
|
+
upb_Array* arr = (upb_Array*)val.array_val;
|
5340
|
+
if (arr) upb_Array_Freeze(arr, m2);
|
5341
|
+
break;
|
5342
|
+
}
|
5343
|
+
case kUpb_FieldMode_Map:
|
5344
|
+
UPB_UNREACHABLE(); // Maps cannot be extensions.
|
5345
|
+
break;
|
5346
|
+
case kUpb_FieldMode_Scalar:
|
5347
|
+
if (upb_MiniTableField_IsSubMessage(f)) {
|
5348
|
+
upb_Message* msg2 = (upb_Message*)val.msg_val;
|
5349
|
+
if (msg2) upb_Message_Freeze(msg2, m2);
|
5350
|
+
}
|
5351
|
+
break;
|
5352
|
+
}
|
5353
|
+
}
|
5354
|
+
}
|
4919
5355
|
|
4920
|
-
|
5356
|
+
|
5357
|
+
#include <stddef.h>
|
4921
5358
|
|
4922
5359
|
|
4923
5360
|
// Must be last.
|
4924
5361
|
|
4925
|
-
bool upb_Message_IsExactlyEqual(const upb_Message* msg1,
|
4926
|
-
const upb_Message* msg2,
|
4927
|
-
const upb_MiniTable* m) {
|
4928
|
-
if (msg1 == msg2) return true;
|
4929
5362
|
|
4930
|
-
|
4931
|
-
|
5363
|
+
#ifdef __cplusplus
|
5364
|
+
extern "C" {
|
5365
|
+
#endif
|
5366
|
+
|
5367
|
+
bool upb_Message_IsEmpty(const upb_Message* msg, const upb_MiniTable* m) {
|
5368
|
+
if (upb_Message_ExtensionCount(msg)) return false;
|
5369
|
+
|
5370
|
+
const upb_MiniTableField* f;
|
5371
|
+
upb_MessageValue v;
|
5372
|
+
size_t iter = kUpb_BaseField_Begin;
|
5373
|
+
return !UPB_PRIVATE(_upb_Message_NextBaseField)(msg, m, &f, &v, &iter);
|
5374
|
+
}
|
5375
|
+
|
5376
|
+
static bool _upb_Array_IsEqual(const upb_Array* arr1, const upb_Array* arr2,
|
5377
|
+
upb_CType ctype, const upb_MiniTable* m,
|
5378
|
+
int options) {
|
5379
|
+
// Check for trivial equality.
|
5380
|
+
if (arr1 == arr2) return true;
|
4932
5381
|
|
4933
|
-
//
|
4934
|
-
size_t size1
|
4935
|
-
|
4936
|
-
|
4937
|
-
upb_EncodeStatus status2 = upb_Encode(msg2, m, opts, a, &data2, &size2);
|
5382
|
+
// Must have identical element counts.
|
5383
|
+
const size_t size1 = arr1 ? upb_Array_Size(arr1) : 0;
|
5384
|
+
const size_t size2 = arr2 ? upb_Array_Size(arr2) : 0;
|
5385
|
+
if (size1 != size2) return false;
|
4938
5386
|
|
4939
|
-
|
4940
|
-
|
4941
|
-
|
5387
|
+
for (size_t i = 0; i < size1; i++) {
|
5388
|
+
const upb_MessageValue val1 = upb_Array_Get(arr1, i);
|
5389
|
+
const upb_MessageValue val2 = upb_Array_Get(arr2, i);
|
5390
|
+
|
5391
|
+
if (!upb_MessageValue_IsEqual(val1, val2, ctype, m, options)) return false;
|
5392
|
+
}
|
5393
|
+
|
5394
|
+
return true;
|
5395
|
+
}
|
5396
|
+
|
5397
|
+
static bool _upb_Map_IsEqual(const upb_Map* map1, const upb_Map* map2,
|
5398
|
+
const upb_MiniTable* m, int options) {
|
5399
|
+
// Check for trivial equality.
|
5400
|
+
if (map1 == map2) return true;
|
5401
|
+
|
5402
|
+
// Must have identical element counts.
|
5403
|
+
size_t size1 = map1 ? upb_Map_Size(map1) : 0;
|
5404
|
+
size_t size2 = map2 ? upb_Map_Size(map2) : 0;
|
5405
|
+
if (size1 != size2) return false;
|
5406
|
+
|
5407
|
+
const upb_MiniTableField* f = upb_MiniTable_MapValue(m);
|
5408
|
+
const upb_MiniTable* m2_value = upb_MiniTable_SubMessage(m, f);
|
5409
|
+
const upb_CType ctype = upb_MiniTableField_CType(f);
|
5410
|
+
|
5411
|
+
upb_MessageValue key, val1, val2;
|
5412
|
+
size_t iter = kUpb_Map_Begin;
|
5413
|
+
while (upb_Map_Next(map1, &key, &val1, &iter)) {
|
5414
|
+
if (!upb_Map_Get(map2, key, &val2)) return false;
|
5415
|
+
if (!upb_MessageValue_IsEqual(val1, val2, ctype, m2_value, options))
|
5416
|
+
return false;
|
5417
|
+
}
|
5418
|
+
|
5419
|
+
return true;
|
5420
|
+
}
|
5421
|
+
|
5422
|
+
static bool _upb_Message_BaseFieldsAreEqual(const upb_Message* msg1,
|
5423
|
+
const upb_Message* msg2,
|
5424
|
+
const upb_MiniTable* m,
|
5425
|
+
int options) {
|
5426
|
+
// Iterate over all base fields for each message.
|
5427
|
+
// The order will always match if the messages are equal.
|
5428
|
+
size_t iter1 = kUpb_BaseField_Begin;
|
5429
|
+
size_t iter2 = kUpb_BaseField_Begin;
|
5430
|
+
|
5431
|
+
for (;;) {
|
5432
|
+
const upb_MiniTableField *f1, *f2;
|
5433
|
+
upb_MessageValue val1, val2;
|
5434
|
+
|
5435
|
+
const bool got1 =
|
5436
|
+
UPB_PRIVATE(_upb_Message_NextBaseField)(msg1, m, &f1, &val1, &iter1);
|
5437
|
+
const bool got2 =
|
5438
|
+
UPB_PRIVATE(_upb_Message_NextBaseField)(msg2, m, &f2, &val2, &iter2);
|
5439
|
+
|
5440
|
+
if (got1 != got2) return false; // Must have identical field counts.
|
5441
|
+
if (!got1) return true; // Loop termination condition.
|
5442
|
+
if (f1 != f2) return false; // Must have identical fields set.
|
5443
|
+
|
5444
|
+
const upb_MiniTable* subm = upb_MiniTable_SubMessage(m, f1);
|
5445
|
+
const upb_CType ctype = upb_MiniTableField_CType(f1);
|
5446
|
+
|
5447
|
+
bool eq;
|
5448
|
+
switch (UPB_PRIVATE(_upb_MiniTableField_Mode)(f1)) {
|
5449
|
+
case kUpb_FieldMode_Array:
|
5450
|
+
eq = _upb_Array_IsEqual(val1.array_val, val2.array_val, ctype, subm,
|
5451
|
+
options);
|
5452
|
+
break;
|
5453
|
+
case kUpb_FieldMode_Map:
|
5454
|
+
eq = _upb_Map_IsEqual(val1.map_val, val2.map_val, subm, options);
|
5455
|
+
break;
|
5456
|
+
case kUpb_FieldMode_Scalar:
|
5457
|
+
eq = upb_MessageValue_IsEqual(val1, val2, ctype, subm, options);
|
5458
|
+
break;
|
5459
|
+
}
|
5460
|
+
if (!eq) return false;
|
5461
|
+
}
|
5462
|
+
}
|
5463
|
+
|
5464
|
+
static bool _upb_Message_ExtensionsAreEqual(const upb_Message* msg1,
|
5465
|
+
const upb_Message* msg2,
|
5466
|
+
const upb_MiniTable* m,
|
5467
|
+
int options) {
|
5468
|
+
// Must have identical extension counts.
|
5469
|
+
if (upb_Message_ExtensionCount(msg1) != upb_Message_ExtensionCount(msg2)) {
|
4942
5470
|
return false;
|
4943
5471
|
}
|
4944
5472
|
|
4945
|
-
const
|
4946
|
-
|
4947
|
-
|
5473
|
+
const upb_MiniTableExtension* e;
|
5474
|
+
upb_MessageValue val1;
|
5475
|
+
|
5476
|
+
// Iterate over all extensions for msg1, and search msg2 for each extension.
|
5477
|
+
size_t iter1 = kUpb_Extension_Begin;
|
5478
|
+
while (UPB_PRIVATE(_upb_Message_NextExtension)(msg1, m, &e, &val1, &iter1)) {
|
5479
|
+
const upb_Extension* ext2 = UPB_PRIVATE(_upb_Message_Getext)(msg2, e);
|
5480
|
+
if (!ext2) return false;
|
5481
|
+
|
5482
|
+
const upb_MessageValue val2 = ext2->data;
|
5483
|
+
const upb_MiniTableField* f = &e->UPB_PRIVATE(field);
|
5484
|
+
const upb_MiniTable* subm = upb_MiniTableField_IsSubMessage(f)
|
5485
|
+
? upb_MiniTableExtension_GetSubMessage(e)
|
5486
|
+
: NULL;
|
5487
|
+
const upb_CType ctype = upb_MiniTableField_CType(f);
|
5488
|
+
|
5489
|
+
bool eq;
|
5490
|
+
switch (UPB_PRIVATE(_upb_MiniTableField_Mode)(f)) {
|
5491
|
+
case kUpb_FieldMode_Array:
|
5492
|
+
eq = _upb_Array_IsEqual(val1.array_val, val2.array_val, ctype, subm,
|
5493
|
+
options);
|
5494
|
+
break;
|
5495
|
+
case kUpb_FieldMode_Map:
|
5496
|
+
UPB_UNREACHABLE(); // Maps cannot be extensions.
|
5497
|
+
break;
|
5498
|
+
case kUpb_FieldMode_Scalar: {
|
5499
|
+
eq = upb_MessageValue_IsEqual(val1, val2, ctype, subm, options);
|
5500
|
+
break;
|
5501
|
+
}
|
5502
|
+
}
|
5503
|
+
if (!eq) return false;
|
5504
|
+
}
|
5505
|
+
return true;
|
5506
|
+
}
|
5507
|
+
|
5508
|
+
bool upb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2,
|
5509
|
+
const upb_MiniTable* m, int options) {
|
5510
|
+
if (UPB_UNLIKELY(msg1 == msg2)) return true;
|
5511
|
+
|
5512
|
+
if (!_upb_Message_BaseFieldsAreEqual(msg1, msg2, m, options)) return false;
|
5513
|
+
if (!_upb_Message_ExtensionsAreEqual(msg1, msg2, m, options)) return false;
|
5514
|
+
|
5515
|
+
if (!(options & kUpb_CompareOption_IncludeUnknownFields)) return true;
|
5516
|
+
|
5517
|
+
// Check the unknown fields.
|
5518
|
+
size_t usize1, usize2;
|
5519
|
+
const char* uf1 = upb_Message_GetUnknown(msg1, &usize1);
|
5520
|
+
const char* uf2 = upb_Message_GetUnknown(msg2, &usize2);
|
5521
|
+
|
5522
|
+
// The wire encoder enforces a maximum depth of 100 so we match that here.
|
5523
|
+
return UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)(
|
5524
|
+
uf1, usize1, uf2, usize2, 100) == kUpb_UnknownCompareResult_Equal;
|
4948
5525
|
}
|
4949
5526
|
|
4950
5527
|
|
@@ -5018,7 +5595,7 @@ upb_Map* upb_Map_DeepClone(const upb_Map* map, upb_CType key_type,
|
|
5018
5595
|
size_t iter = kUpb_Map_Begin;
|
5019
5596
|
while (upb_Map_Next(map, &key, &val, &iter)) {
|
5020
5597
|
const upb_MiniTableField* value_field =
|
5021
|
-
|
5598
|
+
upb_MiniTable_MapValue(map_entry_table);
|
5022
5599
|
const upb_MiniTable* value_sub =
|
5023
5600
|
upb_MiniTableField_CType(value_field) == kUpb_CType_Message
|
5024
5601
|
? upb_MiniTable_GetSubMessageTable(map_entry_table, value_field)
|
@@ -5039,15 +5616,14 @@ static upb_Map* upb_Message_Map_DeepClone(const upb_Map* map,
|
|
5039
5616
|
const upb_MiniTableField* f,
|
5040
5617
|
upb_Message* clone,
|
5041
5618
|
upb_Arena* arena) {
|
5042
|
-
|
5043
|
-
const upb_MiniTable* map_entry_table =
|
5044
|
-
mini_table
|
5619
|
+
UPB_ASSERT(!upb_Message_IsFrozen(clone));
|
5620
|
+
const upb_MiniTable* map_entry_table =
|
5621
|
+
upb_MiniTable_MapEntrySubMessage(mini_table, f);
|
5045
5622
|
UPB_ASSERT(map_entry_table);
|
5046
5623
|
|
5047
|
-
const upb_MiniTableField* key_field =
|
5048
|
-
&map_entry_table->UPB_PRIVATE(fields)[0];
|
5624
|
+
const upb_MiniTableField* key_field = upb_MiniTable_MapKey(map_entry_table);
|
5049
5625
|
const upb_MiniTableField* value_field =
|
5050
|
-
|
5626
|
+
upb_MiniTable_MapValue(map_entry_table);
|
5051
5627
|
|
5052
5628
|
upb_Map* cloned_map = upb_Map_DeepClone(
|
5053
5629
|
map, upb_MiniTableField_CType(key_field),
|
@@ -5055,13 +5631,13 @@ static upb_Map* upb_Message_Map_DeepClone(const upb_Map* map,
|
|
5055
5631
|
if (!cloned_map) {
|
5056
5632
|
return NULL;
|
5057
5633
|
}
|
5058
|
-
|
5634
|
+
upb_Message_SetBaseField(clone, f, &cloned_map);
|
5059
5635
|
return cloned_map;
|
5060
5636
|
}
|
5061
5637
|
|
5062
5638
|
upb_Array* upb_Array_DeepClone(const upb_Array* array, upb_CType value_type,
|
5063
5639
|
const upb_MiniTable* sub, upb_Arena* arena) {
|
5064
|
-
const size_t size = array
|
5640
|
+
const size_t size = upb_Array_Size(array);
|
5065
5641
|
const int lg2 = UPB_PRIVATE(_upb_CType_SizeLg2)(value_type);
|
5066
5642
|
upb_Array* cloned_array = UPB_PRIVATE(_upb_Array_New)(arena, size, lg2);
|
5067
5643
|
if (!cloned_array) {
|
@@ -5084,6 +5660,7 @@ static bool upb_Message_Array_DeepClone(const upb_Array* array,
|
|
5084
5660
|
const upb_MiniTable* mini_table,
|
5085
5661
|
const upb_MiniTableField* field,
|
5086
5662
|
upb_Message* clone, upb_Arena* arena) {
|
5663
|
+
UPB_ASSERT(!upb_Message_IsFrozen(clone));
|
5087
5664
|
UPB_PRIVATE(_upb_MiniTableField_CheckIsArray)(field);
|
5088
5665
|
upb_Array* cloned_array = upb_Array_DeepClone(
|
5089
5666
|
array, upb_MiniTableField_CType(field),
|
@@ -5093,7 +5670,7 @@ static bool upb_Message_Array_DeepClone(const upb_Array* array,
|
|
5093
5670
|
arena);
|
5094
5671
|
|
5095
5672
|
// Clear out upb_Array* due to parent memcpy.
|
5096
|
-
|
5673
|
+
upb_Message_SetBaseField(clone, field, &cloned_array);
|
5097
5674
|
return true;
|
5098
5675
|
}
|
5099
5676
|
|
@@ -5102,19 +5679,20 @@ static bool upb_Clone_ExtensionValue(
|
|
5102
5679
|
upb_Extension* dest, upb_Arena* arena) {
|
5103
5680
|
dest->data = source->data;
|
5104
5681
|
return upb_Clone_MessageValue(
|
5105
|
-
&dest->data,
|
5106
|
-
upb_MiniTableField_CType(&mini_table_ext->UPB_PRIVATE(field)),
|
5682
|
+
&dest->data, upb_MiniTableExtension_CType(mini_table_ext),
|
5107
5683
|
upb_MiniTableExtension_GetSubMessage(mini_table_ext), arena);
|
5108
5684
|
}
|
5109
5685
|
|
5110
5686
|
upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
|
5111
5687
|
const upb_MiniTable* mini_table,
|
5112
5688
|
upb_Arena* arena) {
|
5689
|
+
UPB_ASSERT(!upb_Message_IsFrozen(dst));
|
5113
5690
|
upb_StringView empty_string = upb_StringView_FromDataAndSize(NULL, 0);
|
5114
5691
|
// Only copy message area skipping upb_Message_Internal.
|
5115
5692
|
memcpy(dst + 1, src + 1, mini_table->UPB_PRIVATE(size) - sizeof(upb_Message));
|
5116
|
-
for (
|
5117
|
-
const upb_MiniTableField* field =
|
5693
|
+
for (int i = 0; i < upb_MiniTable_FieldCount(mini_table); ++i) {
|
5694
|
+
const upb_MiniTableField* field =
|
5695
|
+
upb_MiniTable_GetFieldByIndex(mini_table, i);
|
5118
5696
|
if (upb_MiniTableField_IsScalar(field)) {
|
5119
5697
|
switch (upb_MiniTableField_CType(field)) {
|
5120
5698
|
case kUpb_CType_Message: {
|
@@ -5135,10 +5713,10 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
|
|
5135
5713
|
if (dst_sub_message == NULL) {
|
5136
5714
|
return NULL;
|
5137
5715
|
}
|
5138
|
-
_upb_Message_SetTaggedMessagePtr
|
5139
|
-
|
5140
|
-
|
5141
|
-
|
5716
|
+
UPB_PRIVATE(_upb_Message_SetTaggedMessagePtr)
|
5717
|
+
(dst, field,
|
5718
|
+
UPB_PRIVATE(_upb_TaggedMessagePtr_Pack)(dst_sub_message,
|
5719
|
+
is_empty));
|
5142
5720
|
}
|
5143
5721
|
} break;
|
5144
5722
|
case kUpb_CType_String:
|
@@ -5188,7 +5766,7 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
|
|
5188
5766
|
return NULL;
|
5189
5767
|
}
|
5190
5768
|
} else {
|
5191
|
-
upb_Array* msg_array = (upb_Array*)msg_ext->data.
|
5769
|
+
upb_Array* msg_array = (upb_Array*)msg_ext->data.array_val;
|
5192
5770
|
UPB_ASSERT(msg_array);
|
5193
5771
|
upb_Array* cloned_array = upb_Array_DeepClone(
|
5194
5772
|
msg_array, upb_MiniTableField_CType(field),
|
@@ -5196,7 +5774,7 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
|
|
5196
5774
|
if (!cloned_array) {
|
5197
5775
|
return NULL;
|
5198
5776
|
}
|
5199
|
-
dst_ext->data.
|
5777
|
+
dst_ext->data.array_val = cloned_array;
|
5200
5778
|
}
|
5201
5779
|
}
|
5202
5780
|
|
@@ -5215,6 +5793,7 @@ upb_Message* _upb_Message_Copy(upb_Message* dst, const upb_Message* src,
|
|
5215
5793
|
|
5216
5794
|
bool upb_Message_DeepCopy(upb_Message* dst, const upb_Message* src,
|
5217
5795
|
const upb_MiniTable* mini_table, upb_Arena* arena) {
|
5796
|
+
UPB_ASSERT(!upb_Message_IsFrozen(dst));
|
5218
5797
|
upb_Message_Clear(dst, mini_table);
|
5219
5798
|
return _upb_Message_Copy(dst, src, mini_table, arena) != NULL;
|
5220
5799
|
}
|
@@ -5231,6 +5810,7 @@ upb_Message* upb_Message_DeepClone(const upb_Message* msg,
|
|
5231
5810
|
// Performs a shallow copy. TODO: Extend to handle unknown fields.
|
5232
5811
|
void upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src,
|
5233
5812
|
const upb_MiniTable* m) {
|
5813
|
+
UPB_ASSERT(!upb_Message_IsFrozen(dst));
|
5234
5814
|
memcpy(dst, src, m->UPB_PRIVATE(size));
|
5235
5815
|
}
|
5236
5816
|
|
@@ -5243,6 +5823,36 @@ upb_Message* upb_Message_ShallowClone(const upb_Message* msg,
|
|
5243
5823
|
return clone;
|
5244
5824
|
}
|
5245
5825
|
|
5826
|
+
#include "stddef.h"
|
5827
|
+
|
5828
|
+
// Must be last.
|
5829
|
+
|
5830
|
+
bool upb_Message_MergeFrom(upb_Message* dst, const upb_Message* src,
|
5831
|
+
const upb_MiniTable* mt,
|
5832
|
+
const upb_ExtensionRegistry* extreg,
|
5833
|
+
upb_Arena* arena) {
|
5834
|
+
char* buf = NULL;
|
5835
|
+
size_t size = 0;
|
5836
|
+
// This tmp arena is used to hold the bytes for `src` serialized. This bends
|
5837
|
+
// the typical "no hidden allocations" design of upb, but under a properly
|
5838
|
+
// optimized implementation this extra allocation would not be necessary and
|
5839
|
+
// so we don't want to unnecessarily have the bad API or bloat the passed-in
|
5840
|
+
// arena with this very-short-term allocation.
|
5841
|
+
upb_Arena* encode_arena = upb_Arena_New();
|
5842
|
+
upb_EncodeStatus e_status = upb_Encode(src, mt, 0, encode_arena, &buf, &size);
|
5843
|
+
if (e_status != kUpb_EncodeStatus_Ok) {
|
5844
|
+
upb_Arena_Free(encode_arena);
|
5845
|
+
return false;
|
5846
|
+
}
|
5847
|
+
upb_DecodeStatus d_status = upb_Decode(buf, size, dst, mt, extreg, 0, arena);
|
5848
|
+
if (d_status != kUpb_DecodeStatus_Ok) {
|
5849
|
+
upb_Arena_Free(encode_arena);
|
5850
|
+
return false;
|
5851
|
+
}
|
5852
|
+
upb_Arena_Free(encode_arena);
|
5853
|
+
return true;
|
5854
|
+
}
|
5855
|
+
|
5246
5856
|
|
5247
5857
|
#include <stddef.h>
|
5248
5858
|
#include <stdint.h>
|
@@ -5348,9 +5958,9 @@ static upb_MiniTableEnum* upb_MtDecoder_BuildMiniTableEnum(
|
|
5348
5958
|
return upb_MtDecoder_DoBuildMiniTableEnum(decoder, data, len);
|
5349
5959
|
}
|
5350
5960
|
|
5351
|
-
upb_MiniTableEnum*
|
5352
|
-
|
5353
|
-
|
5961
|
+
upb_MiniTableEnum* upb_MiniTableEnum_Build(const char* data, size_t len,
|
5962
|
+
upb_Arena* arena,
|
5963
|
+
upb_Status* status) {
|
5354
5964
|
upb_MdEnumDecoder decoder = {
|
5355
5965
|
.base =
|
5356
5966
|
{
|
@@ -5391,7 +6001,7 @@ typedef enum {
|
|
5391
6001
|
kUpb_LayoutItemType_Max = kUpb_LayoutItemType_Field,
|
5392
6002
|
} upb_LayoutItemType;
|
5393
6003
|
|
5394
|
-
#define kUpb_LayoutItem_IndexSentinel ((uint16_t)-1)
|
6004
|
+
#define kUpb_LayoutItem_IndexSentinel ((uint16_t) - 1)
|
5395
6005
|
|
5396
6006
|
typedef struct {
|
5397
6007
|
// Index of the corresponding field. When this is a oneof field, the field's
|
@@ -5588,6 +6198,12 @@ static void upb_MtDecoder_ModifyField(upb_MtDecoder* d,
|
|
5588
6198
|
upb_MiniTableField_Number(field));
|
5589
6199
|
}
|
5590
6200
|
|
6201
|
+
if (singular && upb_MiniTableField_IsSubMessage(field)) {
|
6202
|
+
upb_MdDecoder_ErrorJmp(&d->base,
|
6203
|
+
"Field %" PRIu32 " cannot be a singular submessage",
|
6204
|
+
upb_MiniTableField_Number(field));
|
6205
|
+
}
|
6206
|
+
|
5591
6207
|
if (singular) field->UPB_PRIVATE(offset) = kNoPresence;
|
5592
6208
|
if (required) {
|
5593
6209
|
field->UPB_PRIVATE(offset) = kRequiredPresence;
|
@@ -5744,11 +6360,15 @@ static void upb_MtDecoder_AllocateSubs(upb_MtDecoder* d,
|
|
5744
6360
|
upb_SubCounts sub_counts) {
|
5745
6361
|
uint32_t total_count = sub_counts.submsg_count + sub_counts.subenum_count;
|
5746
6362
|
size_t subs_bytes = sizeof(*d->table->UPB_PRIVATE(subs)) * total_count;
|
5747
|
-
|
6363
|
+
size_t ptrs_bytes = sizeof(upb_MiniTable*) * sub_counts.submsg_count;
|
6364
|
+
upb_MiniTableSubInternal* subs = upb_Arena_Malloc(d->arena, subs_bytes);
|
6365
|
+
const upb_MiniTable** subs_ptrs = upb_Arena_Malloc(d->arena, ptrs_bytes);
|
5748
6366
|
upb_MdDecoder_CheckOutOfMemory(&d->base, subs);
|
6367
|
+
upb_MdDecoder_CheckOutOfMemory(&d->base, subs_ptrs);
|
5749
6368
|
uint32_t i = 0;
|
5750
6369
|
for (; i < sub_counts.submsg_count; i++) {
|
5751
|
-
|
6370
|
+
subs_ptrs[i] = UPB_PRIVATE(_upb_MiniTable_Empty)();
|
6371
|
+
subs[i].UPB_PRIVATE(submsg) = &subs_ptrs[i];
|
5752
6372
|
}
|
5753
6373
|
if (sub_counts.subenum_count) {
|
5754
6374
|
upb_MiniTableField* f = d->fields;
|
@@ -6074,6 +6694,11 @@ static upb_MiniTable* upb_MtDecoder_DoBuildMiniTableWithBuf(
|
|
6074
6694
|
decoder->table->UPB_PRIVATE(dense_below) = 0;
|
6075
6695
|
decoder->table->UPB_PRIVATE(table_mask) = -1;
|
6076
6696
|
decoder->table->UPB_PRIVATE(required_count) = 0;
|
6697
|
+
#if UPB_TRACING_ENABLED
|
6698
|
+
// MiniTables built from MiniDescriptors will not be able to vend the message
|
6699
|
+
// name unless it is explicitly set with upb_MiniTable_SetFullName().
|
6700
|
+
decoder->table->UPB_PRIVATE(full_name) = 0;
|
6701
|
+
#endif
|
6077
6702
|
|
6078
6703
|
// Strip off and verify the version tag.
|
6079
6704
|
if (!len--) goto done;
|
@@ -6235,6 +6860,7 @@ upb_MiniTable* _upb_MiniTable_Build(const char* data, size_t len,
|
|
6235
6860
|
|
6236
6861
|
#include <stddef.h>
|
6237
6862
|
#include <stdint.h>
|
6863
|
+
#include <string.h>
|
6238
6864
|
|
6239
6865
|
|
6240
6866
|
// Must be last.
|
@@ -6270,12 +6896,12 @@ bool upb_MiniTable_SetSubMessage(upb_MiniTable* table,
|
|
6270
6896
|
return false;
|
6271
6897
|
}
|
6272
6898
|
|
6273
|
-
|
6274
|
-
|
6899
|
+
int idx = field->UPB_PRIVATE(submsg_index);
|
6900
|
+
upb_MiniTableSubInternal* table_subs = (void*)table->UPB_PRIVATE(subs);
|
6275
6901
|
// TODO: Add this assert back once YouTube is updated to not call
|
6276
6902
|
// this function repeatedly.
|
6277
6903
|
// UPB_ASSERT(UPB_PRIVATE(_upb_MiniTable_IsEmpty)(table_sub->submsg));
|
6278
|
-
*
|
6904
|
+
memcpy((void*)table_subs[idx].UPB_PRIVATE(submsg), &sub, sizeof(void*));
|
6279
6905
|
return true;
|
6280
6906
|
}
|
6281
6907
|
|
@@ -6292,13 +6918,13 @@ bool upb_MiniTable_SetSubEnum(upb_MiniTable* table, upb_MiniTableField* field,
|
|
6292
6918
|
return true;
|
6293
6919
|
}
|
6294
6920
|
|
6295
|
-
uint32_t upb_MiniTable_GetSubList(const upb_MiniTable*
|
6921
|
+
uint32_t upb_MiniTable_GetSubList(const upb_MiniTable* m,
|
6296
6922
|
const upb_MiniTableField** subs) {
|
6297
6923
|
uint32_t msg_count = 0;
|
6298
6924
|
uint32_t enum_count = 0;
|
6299
6925
|
|
6300
|
-
for (int i = 0; i <
|
6301
|
-
const upb_MiniTableField* f =
|
6926
|
+
for (int i = 0; i < upb_MiniTable_FieldCount(m); i++) {
|
6927
|
+
const upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, i);
|
6302
6928
|
if (upb_MiniTableField_CType(f) == kUpb_CType_Message) {
|
6303
6929
|
*subs = f;
|
6304
6930
|
++subs;
|
@@ -6306,9 +6932,9 @@ uint32_t upb_MiniTable_GetSubList(const upb_MiniTable* mt,
|
|
6306
6932
|
}
|
6307
6933
|
}
|
6308
6934
|
|
6309
|
-
for (int i = 0; i <
|
6310
|
-
const upb_MiniTableField* f =
|
6311
|
-
if (
|
6935
|
+
for (int i = 0; i < upb_MiniTable_FieldCount(m); i++) {
|
6936
|
+
const upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, i);
|
6937
|
+
if (upb_MiniTableField_IsClosedEnum(f)) {
|
6312
6938
|
*subs = f;
|
6313
6939
|
++subs;
|
6314
6940
|
enum_count++;
|
@@ -6321,36 +6947,34 @@ uint32_t upb_MiniTable_GetSubList(const upb_MiniTable* mt,
|
|
6321
6947
|
// The list of sub_tables and sub_enums must exactly match the number and order
|
6322
6948
|
// of sub-message fields and sub-enum fields given by upb_MiniTable_GetSubList()
|
6323
6949
|
// above.
|
6324
|
-
bool upb_MiniTable_Link(upb_MiniTable*
|
6950
|
+
bool upb_MiniTable_Link(upb_MiniTable* m, const upb_MiniTable** sub_tables,
|
6325
6951
|
size_t sub_table_count,
|
6326
6952
|
const upb_MiniTableEnum** sub_enums,
|
6327
6953
|
size_t sub_enum_count) {
|
6328
6954
|
uint32_t msg_count = 0;
|
6329
6955
|
uint32_t enum_count = 0;
|
6330
6956
|
|
6331
|
-
for (int i = 0; i <
|
6332
|
-
upb_MiniTableField* f =
|
6957
|
+
for (int i = 0; i < upb_MiniTable_FieldCount(m); i++) {
|
6958
|
+
upb_MiniTableField* f =
|
6959
|
+
(upb_MiniTableField*)upb_MiniTable_GetFieldByIndex(m, i);
|
6333
6960
|
if (upb_MiniTableField_CType(f) == kUpb_CType_Message) {
|
6334
6961
|
const upb_MiniTable* sub = sub_tables[msg_count++];
|
6335
6962
|
if (msg_count > sub_table_count) return false;
|
6336
|
-
if (sub
|
6337
|
-
if (!upb_MiniTable_SetSubMessage(mt, f, sub)) return false;
|
6338
|
-
}
|
6963
|
+
if (sub && !upb_MiniTable_SetSubMessage(m, f, sub)) return false;
|
6339
6964
|
}
|
6340
6965
|
}
|
6341
6966
|
|
6342
|
-
for (int i = 0; i <
|
6343
|
-
upb_MiniTableField* f =
|
6967
|
+
for (int i = 0; i < upb_MiniTable_FieldCount(m); i++) {
|
6968
|
+
upb_MiniTableField* f =
|
6969
|
+
(upb_MiniTableField*)upb_MiniTable_GetFieldByIndex(m, i);
|
6344
6970
|
if (upb_MiniTableField_IsClosedEnum(f)) {
|
6345
6971
|
const upb_MiniTableEnum* sub = sub_enums[enum_count++];
|
6346
6972
|
if (enum_count > sub_enum_count) return false;
|
6347
|
-
if (sub
|
6348
|
-
if (!upb_MiniTable_SetSubEnum(mt, f, sub)) return false;
|
6349
|
-
}
|
6973
|
+
if (sub && !upb_MiniTable_SetSubEnum(m, f, sub)) return false;
|
6350
6974
|
}
|
6351
6975
|
}
|
6352
6976
|
|
6353
|
-
return
|
6977
|
+
return (msg_count == sub_table_count) && (enum_count == sub_enum_count);
|
6354
6978
|
}
|
6355
6979
|
|
6356
6980
|
|
@@ -6412,6 +7036,24 @@ failure:
|
|
6412
7036
|
return false;
|
6413
7037
|
}
|
6414
7038
|
|
7039
|
+
#ifdef UPB_LINKARR_DECLARE
|
7040
|
+
|
7041
|
+
UPB_LINKARR_DECLARE(upb_AllExts, upb_MiniTableExtension);
|
7042
|
+
|
7043
|
+
bool upb_ExtensionRegistry_AddAllLinkedExtensions(upb_ExtensionRegistry* r) {
|
7044
|
+
const upb_MiniTableExtension* start = UPB_LINKARR_START(upb_AllExts);
|
7045
|
+
const upb_MiniTableExtension* stop = UPB_LINKARR_STOP(upb_AllExts);
|
7046
|
+
for (const upb_MiniTableExtension* p = start; p < stop; p++) {
|
7047
|
+
// Windows can introduce zero padding, so we have to skip zeroes.
|
7048
|
+
if (upb_MiniTableExtension_Number(p) != 0) {
|
7049
|
+
if (!upb_ExtensionRegistry_Add(r, p)) return false;
|
7050
|
+
}
|
7051
|
+
}
|
7052
|
+
return true;
|
7053
|
+
}
|
7054
|
+
|
7055
|
+
#endif // UPB_LINKARR_DECLARE
|
7056
|
+
|
6415
7057
|
const upb_MiniTableExtension* upb_ExtensionRegistry_Lookup(
|
6416
7058
|
const upb_ExtensionRegistry* r, const upb_MiniTable* t, uint32_t num) {
|
6417
7059
|
char buf[EXTREG_KEY_SIZE];
|
@@ -6650,15 +7292,15 @@ typedef union {
|
|
6650
7292
|
// Returns the MiniTable corresponding to a given MiniTableField
|
6651
7293
|
// from an array of MiniTableSubs.
|
6652
7294
|
static const upb_MiniTable* _upb_MiniTableSubs_MessageByField(
|
6653
|
-
const
|
6654
|
-
return
|
7295
|
+
const upb_MiniTableSubInternal* subs, const upb_MiniTableField* field) {
|
7296
|
+
return *subs[field->UPB_PRIVATE(submsg_index)].UPB_PRIVATE(submsg);
|
6655
7297
|
}
|
6656
7298
|
|
6657
7299
|
// Returns the MiniTableEnum corresponding to a given MiniTableField
|
6658
7300
|
// from an array of MiniTableSub.
|
6659
7301
|
static const upb_MiniTableEnum* _upb_MiniTableSubs_EnumByField(
|
6660
|
-
const
|
6661
|
-
return
|
7302
|
+
const upb_MiniTableSubInternal* subs, const upb_MiniTableField* field) {
|
7303
|
+
return subs[field->UPB_PRIVATE(submsg_index)].UPB_PRIVATE(subenum);
|
6662
7304
|
}
|
6663
7305
|
|
6664
7306
|
static const char* _upb_Decoder_DecodeMessage(upb_Decoder* d, const char* ptr,
|
@@ -6705,8 +7347,7 @@ static _upb_DecodeLongVarintReturn _upb_Decoder_DecodeLongVarint(
|
|
6705
7347
|
const char* ptr, uint64_t val) {
|
6706
7348
|
_upb_DecodeLongVarintReturn ret = {NULL, 0};
|
6707
7349
|
uint64_t byte;
|
6708
|
-
int i;
|
6709
|
-
for (i = 1; i < 10; i++) {
|
7350
|
+
for (int i = 1; i < 10; i++) {
|
6710
7351
|
byte = (uint8_t)ptr[i];
|
6711
7352
|
val += (byte - 1) << (i * 7);
|
6712
7353
|
if (!(byte & 0x80)) {
|
@@ -6719,8 +7360,8 @@ static _upb_DecodeLongVarintReturn _upb_Decoder_DecodeLongVarint(
|
|
6719
7360
|
}
|
6720
7361
|
|
6721
7362
|
UPB_FORCEINLINE
|
6722
|
-
|
6723
|
-
|
7363
|
+
const char* _upb_Decoder_DecodeVarint(upb_Decoder* d, const char* ptr,
|
7364
|
+
uint64_t* val) {
|
6724
7365
|
uint64_t byte = (uint8_t)*ptr;
|
6725
7366
|
if (UPB_LIKELY((byte & 0x80) == 0)) {
|
6726
7367
|
*val = byte;
|
@@ -6734,8 +7375,8 @@ static const char* _upb_Decoder_DecodeVarint(upb_Decoder* d, const char* ptr,
|
|
6734
7375
|
}
|
6735
7376
|
|
6736
7377
|
UPB_FORCEINLINE
|
6737
|
-
|
6738
|
-
|
7378
|
+
const char* _upb_Decoder_DecodeTag(upb_Decoder* d, const char* ptr,
|
7379
|
+
uint32_t* val) {
|
6739
7380
|
uint64_t byte = (uint8_t)*ptr;
|
6740
7381
|
if (UPB_LIKELY((byte & 0x80) == 0)) {
|
6741
7382
|
*val = byte;
|
@@ -6752,8 +7393,8 @@ static const char* _upb_Decoder_DecodeTag(upb_Decoder* d, const char* ptr,
|
|
6752
7393
|
}
|
6753
7394
|
|
6754
7395
|
UPB_FORCEINLINE
|
6755
|
-
|
6756
|
-
|
7396
|
+
const char* upb_Decoder_DecodeSize(upb_Decoder* d, const char* ptr,
|
7397
|
+
uint32_t* size) {
|
6757
7398
|
uint64_t size64;
|
6758
7399
|
ptr = _upb_Decoder_DecodeVarint(d, ptr, &size64);
|
6759
7400
|
if (size64 >= INT32_MAX ||
|
@@ -6794,11 +7435,10 @@ static void _upb_Decoder_Munge(int type, wireval* val) {
|
|
6794
7435
|
}
|
6795
7436
|
}
|
6796
7437
|
|
6797
|
-
static upb_Message*
|
6798
|
-
|
6799
|
-
|
6800
|
-
|
6801
|
-
const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field);
|
7438
|
+
static upb_Message* _upb_Decoder_NewSubMessage2(upb_Decoder* d,
|
7439
|
+
const upb_MiniTable* subl,
|
7440
|
+
const upb_MiniTableField* field,
|
7441
|
+
upb_TaggedMessagePtr* target) {
|
6802
7442
|
UPB_ASSERT(subl);
|
6803
7443
|
upb_Message* msg = _upb_Message_New(subl, &d->arena);
|
6804
7444
|
if (!msg) _upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
|
@@ -6819,8 +7459,15 @@ static upb_Message* _upb_Decoder_NewSubMessage(upb_Decoder* d,
|
|
6819
7459
|
return msg;
|
6820
7460
|
}
|
6821
7461
|
|
7462
|
+
static upb_Message* _upb_Decoder_NewSubMessage(
|
7463
|
+
upb_Decoder* d, const upb_MiniTableSubInternal* subs,
|
7464
|
+
const upb_MiniTableField* field, upb_TaggedMessagePtr* target) {
|
7465
|
+
const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field);
|
7466
|
+
return _upb_Decoder_NewSubMessage2(d, subl, field, target);
|
7467
|
+
}
|
7468
|
+
|
6822
7469
|
static upb_Message* _upb_Decoder_ReuseSubMessage(
|
6823
|
-
upb_Decoder* d, const
|
7470
|
+
upb_Decoder* d, const upb_MiniTableSubInternal* subs,
|
6824
7471
|
const upb_MiniTableField* field, upb_TaggedMessagePtr* target) {
|
6825
7472
|
upb_TaggedMessagePtr tagged = *target;
|
6826
7473
|
const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field);
|
@@ -6855,11 +7502,10 @@ static const char* _upb_Decoder_ReadString(upb_Decoder* d, const char* ptr,
|
|
6855
7502
|
}
|
6856
7503
|
|
6857
7504
|
UPB_FORCEINLINE
|
6858
|
-
|
6859
|
-
|
6860
|
-
|
6861
|
-
|
6862
|
-
uint32_t expected_end_group) {
|
7505
|
+
const char* _upb_Decoder_RecurseSubMessage(upb_Decoder* d, const char* ptr,
|
7506
|
+
upb_Message* submsg,
|
7507
|
+
const upb_MiniTable* subl,
|
7508
|
+
uint32_t expected_end_group) {
|
6863
7509
|
if (--d->depth < 0) {
|
6864
7510
|
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_MaxDepthExceeded);
|
6865
7511
|
}
|
@@ -6872,9 +7518,11 @@ static const char* _upb_Decoder_RecurseSubMessage(upb_Decoder* d,
|
|
6872
7518
|
}
|
6873
7519
|
|
6874
7520
|
UPB_FORCEINLINE
|
6875
|
-
|
6876
|
-
|
6877
|
-
|
7521
|
+
const char* _upb_Decoder_DecodeSubMessage(upb_Decoder* d, const char* ptr,
|
7522
|
+
upb_Message* submsg,
|
7523
|
+
const upb_MiniTableSubInternal* subs,
|
7524
|
+
const upb_MiniTableField* field,
|
7525
|
+
int size) {
|
6878
7526
|
int saved_delta = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, size);
|
6879
7527
|
const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field);
|
6880
7528
|
UPB_ASSERT(subl);
|
@@ -6884,10 +7532,10 @@ static const char* _upb_Decoder_DecodeSubMessage(
|
|
6884
7532
|
}
|
6885
7533
|
|
6886
7534
|
UPB_FORCEINLINE
|
6887
|
-
|
6888
|
-
|
6889
|
-
|
6890
|
-
|
7535
|
+
const char* _upb_Decoder_DecodeGroup(upb_Decoder* d, const char* ptr,
|
7536
|
+
upb_Message* submsg,
|
7537
|
+
const upb_MiniTable* subl,
|
7538
|
+
uint32_t number) {
|
6891
7539
|
if (_upb_Decoder_IsDone(d, &ptr)) {
|
6892
7540
|
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed);
|
6893
7541
|
}
|
@@ -6897,16 +7545,16 @@ static const char* _upb_Decoder_DecodeGroup(upb_Decoder* d, const char* ptr,
|
|
6897
7545
|
}
|
6898
7546
|
|
6899
7547
|
UPB_FORCEINLINE
|
6900
|
-
|
6901
|
-
|
6902
|
-
uint32_t number) {
|
7548
|
+
const char* _upb_Decoder_DecodeUnknownGroup(upb_Decoder* d, const char* ptr,
|
7549
|
+
uint32_t number) {
|
6903
7550
|
return _upb_Decoder_DecodeGroup(d, ptr, NULL, NULL, number);
|
6904
7551
|
}
|
6905
7552
|
|
6906
7553
|
UPB_FORCEINLINE
|
6907
|
-
|
6908
|
-
|
6909
|
-
|
7554
|
+
const char* _upb_Decoder_DecodeKnownGroup(upb_Decoder* d, const char* ptr,
|
7555
|
+
upb_Message* submsg,
|
7556
|
+
const upb_MiniTableSubInternal* subs,
|
7557
|
+
const upb_MiniTableField* field) {
|
6910
7558
|
const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field);
|
6911
7559
|
UPB_ASSERT(subl);
|
6912
7560
|
return _upb_Decoder_DecodeGroup(d, ptr, submsg, subl,
|
@@ -6936,10 +7584,9 @@ static void _upb_Decoder_AddUnknownVarints(upb_Decoder* d, upb_Message* msg,
|
|
6936
7584
|
}
|
6937
7585
|
|
6938
7586
|
UPB_FORCEINLINE
|
6939
|
-
|
6940
|
-
|
6941
|
-
|
6942
|
-
wireval* val) {
|
7587
|
+
bool _upb_Decoder_CheckEnum(upb_Decoder* d, const char* ptr, upb_Message* msg,
|
7588
|
+
const upb_MiniTableEnum* e,
|
7589
|
+
const upb_MiniTableField* field, wireval* val) {
|
6943
7590
|
const uint32_t v = val->uint32_val;
|
6944
7591
|
|
6945
7592
|
if (UPB_LIKELY(upb_MiniTableEnum_CheckValue(e, v))) return true;
|
@@ -6957,12 +7604,10 @@ static bool _upb_Decoder_CheckEnum(upb_Decoder* d, const char* ptr,
|
|
6957
7604
|
}
|
6958
7605
|
|
6959
7606
|
UPB_NOINLINE
|
6960
|
-
static const char* _upb_Decoder_DecodeEnumArray(
|
6961
|
-
|
6962
|
-
|
6963
|
-
|
6964
|
-
const upb_MiniTableField* field,
|
6965
|
-
wireval* val) {
|
7607
|
+
static const char* _upb_Decoder_DecodeEnumArray(
|
7608
|
+
upb_Decoder* d, const char* ptr, upb_Message* msg, upb_Array* arr,
|
7609
|
+
const upb_MiniTableSubInternal* subs, const upb_MiniTableField* field,
|
7610
|
+
wireval* val) {
|
6966
7611
|
const upb_MiniTableEnum* e = _upb_MiniTableSubs_EnumByField(subs, field);
|
6967
7612
|
if (!_upb_Decoder_CheckEnum(d, ptr, msg, e, field, val)) return ptr;
|
6968
7613
|
void* mem = UPB_PTR_AT(upb_Array_MutableDataPtr(arr),
|
@@ -6973,9 +7618,10 @@ static const char* _upb_Decoder_DecodeEnumArray(upb_Decoder* d, const char* ptr,
|
|
6973
7618
|
}
|
6974
7619
|
|
6975
7620
|
UPB_FORCEINLINE
|
6976
|
-
|
6977
|
-
|
6978
|
-
|
7621
|
+
const char* _upb_Decoder_DecodeFixedPacked(upb_Decoder* d, const char* ptr,
|
7622
|
+
upb_Array* arr, wireval* val,
|
7623
|
+
const upb_MiniTableField* field,
|
7624
|
+
int lg2) {
|
6979
7625
|
int mask = (1 << lg2) - 1;
|
6980
7626
|
size_t count = val->size >> lg2;
|
6981
7627
|
if ((val->size & mask) != 0) {
|
@@ -7010,9 +7656,10 @@ static const char* _upb_Decoder_DecodeFixedPacked(
|
|
7010
7656
|
}
|
7011
7657
|
|
7012
7658
|
UPB_FORCEINLINE
|
7013
|
-
|
7014
|
-
|
7015
|
-
|
7659
|
+
const char* _upb_Decoder_DecodeVarintPacked(upb_Decoder* d, const char* ptr,
|
7660
|
+
upb_Array* arr, wireval* val,
|
7661
|
+
const upb_MiniTableField* field,
|
7662
|
+
int lg2) {
|
7016
7663
|
int scale = 1 << lg2;
|
7017
7664
|
int saved_limit = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, val->size);
|
7018
7665
|
char* out = UPB_PTR_AT(upb_Array_MutableDataPtr(arr),
|
@@ -7036,7 +7683,7 @@ static const char* _upb_Decoder_DecodeVarintPacked(
|
|
7036
7683
|
UPB_NOINLINE
|
7037
7684
|
static const char* _upb_Decoder_DecodeEnumPacked(
|
7038
7685
|
upb_Decoder* d, const char* ptr, upb_Message* msg, upb_Array* arr,
|
7039
|
-
const
|
7686
|
+
const upb_MiniTableSubInternal* subs, const upb_MiniTableField* field,
|
7040
7687
|
wireval* val) {
|
7041
7688
|
const upb_MiniTableEnum* e = _upb_MiniTableSubs_EnumByField(subs, field);
|
7042
7689
|
int saved_limit = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, val->size);
|
@@ -7070,11 +7717,10 @@ static upb_Array* _upb_Decoder_CreateArray(upb_Decoder* d,
|
|
7070
7717
|
return ret;
|
7071
7718
|
}
|
7072
7719
|
|
7073
|
-
static const char* _upb_Decoder_DecodeToArray(
|
7074
|
-
|
7075
|
-
|
7076
|
-
|
7077
|
-
wireval* val, int op) {
|
7720
|
+
static const char* _upb_Decoder_DecodeToArray(
|
7721
|
+
upb_Decoder* d, const char* ptr, upb_Message* msg,
|
7722
|
+
const upb_MiniTableSubInternal* subs, const upb_MiniTableField* field,
|
7723
|
+
wireval* val, int op) {
|
7078
7724
|
upb_Array** arrp = UPB_PTR_AT(msg, field->UPB_PRIVATE(offset), void);
|
7079
7725
|
upb_Array* arr = *arrp;
|
7080
7726
|
void* mem;
|
@@ -7175,11 +7821,10 @@ static upb_Map* _upb_Decoder_CreateMap(upb_Decoder* d,
|
|
7175
7821
|
return ret;
|
7176
7822
|
}
|
7177
7823
|
|
7178
|
-
static const char* _upb_Decoder_DecodeToMap(
|
7179
|
-
|
7180
|
-
|
7181
|
-
|
7182
|
-
wireval* val) {
|
7824
|
+
static const char* _upb_Decoder_DecodeToMap(
|
7825
|
+
upb_Decoder* d, const char* ptr, upb_Message* msg,
|
7826
|
+
const upb_MiniTableSubInternal* subs, const upb_MiniTableField* field,
|
7827
|
+
wireval* val) {
|
7183
7828
|
upb_Map** map_p = UPB_PTR_AT(msg, field->UPB_PRIVATE(offset), upb_Map*);
|
7184
7829
|
upb_Map* map = *map_p;
|
7185
7830
|
upb_MapEntry ent;
|
@@ -7240,8 +7885,8 @@ static const char* _upb_Decoder_DecodeToMap(upb_Decoder* d, const char* ptr,
|
|
7240
7885
|
|
7241
7886
|
static const char* _upb_Decoder_DecodeToSubMessage(
|
7242
7887
|
upb_Decoder* d, const char* ptr, upb_Message* msg,
|
7243
|
-
const
|
7244
|
-
int op) {
|
7888
|
+
const upb_MiniTableSubInternal* subs, const upb_MiniTableField* field,
|
7889
|
+
wireval* val, int op) {
|
7245
7890
|
void* mem = UPB_PTR_AT(msg, field->UPB_PRIVATE(offset), void);
|
7246
7891
|
int type = field->UPB_PRIVATE(descriptortype);
|
7247
7892
|
|
@@ -7255,7 +7900,7 @@ static const char* _upb_Decoder_DecodeToSubMessage(
|
|
7255
7900
|
// Set presence if necessary.
|
7256
7901
|
if (UPB_PRIVATE(_upb_MiniTableField_HasHasbit)(field)) {
|
7257
7902
|
UPB_PRIVATE(_upb_Message_SetHasbit)(msg, field);
|
7258
|
-
} else if (
|
7903
|
+
} else if (upb_MiniTableField_IsInOneof(field)) {
|
7259
7904
|
// Oneof case
|
7260
7905
|
uint32_t* oneof_case = UPB_PRIVATE(_upb_Message_OneofCasePtr)(msg, field);
|
7261
7906
|
if (op == kUpb_DecodeOp_SubMessage &&
|
@@ -7318,9 +7963,8 @@ const char* _upb_Decoder_CheckRequired(upb_Decoder* d, const char* ptr,
|
|
7318
7963
|
}
|
7319
7964
|
|
7320
7965
|
UPB_FORCEINLINE
|
7321
|
-
|
7322
|
-
|
7323
|
-
const upb_MiniTable* m) {
|
7966
|
+
bool _upb_Decoder_TryFastDispatch(upb_Decoder* d, const char** ptr,
|
7967
|
+
upb_Message* msg, const upb_MiniTable* m) {
|
7324
7968
|
#if UPB_FASTTABLE
|
7325
7969
|
if (m && m->UPB_PRIVATE(table_mask) != (unsigned char)-1) {
|
7326
7970
|
uint16_t tag = _upb_FastDecoder_LoadTag(*ptr);
|
@@ -7372,9 +8016,9 @@ static void upb_Decoder_AddKnownMessageSetItem(
|
|
7372
8016
|
if (UPB_UNLIKELY(!ext)) {
|
7373
8017
|
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
|
7374
8018
|
}
|
7375
|
-
upb_Message* submsg =
|
7376
|
-
d,
|
7377
|
-
(upb_TaggedMessagePtr*)&ext->data);
|
8019
|
+
upb_Message* submsg = _upb_Decoder_NewSubMessage2(
|
8020
|
+
d, ext->ext->UPB_PRIVATE(sub).UPB_PRIVATE(submsg),
|
8021
|
+
&ext->ext->UPB_PRIVATE(field), (upb_TaggedMessagePtr*)&ext->data);
|
7378
8022
|
upb_DecodeStatus status = upb_Decode(
|
7379
8023
|
data, size, submsg, upb_MiniTableExtension_GetSubMessage(item_mt),
|
7380
8024
|
d->extreg, d->options, &d->arena);
|
@@ -7558,9 +8202,8 @@ static int _upb_Decoder_GetVarintOp(const upb_MiniTableField* field) {
|
|
7558
8202
|
}
|
7559
8203
|
|
7560
8204
|
UPB_FORCEINLINE
|
7561
|
-
|
7562
|
-
|
7563
|
-
int* op) {
|
8205
|
+
void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt,
|
8206
|
+
const upb_MiniTableField* field, int* op) {
|
7564
8207
|
// If sub-message is not linked, treat as unknown.
|
7565
8208
|
if (field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsExtension) return;
|
7566
8209
|
const upb_MiniTable* mt_sub =
|
@@ -7576,8 +8219,9 @@ static void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt,
|
|
7576
8219
|
// unlinked.
|
7577
8220
|
do {
|
7578
8221
|
UPB_ASSERT(upb_MiniTableField_CType(oneof) == kUpb_CType_Message);
|
7579
|
-
const
|
7580
|
-
|
8222
|
+
const upb_MiniTable* oneof_sub =
|
8223
|
+
*mt->UPB_PRIVATE(subs)[oneof->UPB_PRIVATE(submsg_index)].UPB_PRIVATE(
|
8224
|
+
submsg);
|
7581
8225
|
UPB_ASSERT(!oneof_sub);
|
7582
8226
|
} while (upb_MiniTable_NextOneofField(mt, &oneof));
|
7583
8227
|
}
|
@@ -7586,9 +8230,8 @@ static void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt,
|
|
7586
8230
|
}
|
7587
8231
|
|
7588
8232
|
UPB_FORCEINLINE
|
7589
|
-
|
7590
|
-
|
7591
|
-
int* op) {
|
8233
|
+
void _upb_Decoder_MaybeVerifyUtf8(upb_Decoder* d,
|
8234
|
+
const upb_MiniTableField* field, int* op) {
|
7592
8235
|
if ((field->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsAlternate) &&
|
7593
8236
|
UPB_UNLIKELY(d->options & kUpb_DecodeOption_AlwaysValidateUtf8))
|
7594
8237
|
*op = kUpb_DecodeOp_String;
|
@@ -7658,11 +8301,10 @@ static int _upb_Decoder_GetDelimitedOp(upb_Decoder* d, const upb_MiniTable* mt,
|
|
7658
8301
|
}
|
7659
8302
|
|
7660
8303
|
UPB_FORCEINLINE
|
7661
|
-
|
7662
|
-
|
7663
|
-
|
7664
|
-
|
7665
|
-
int* op) {
|
8304
|
+
const char* _upb_Decoder_DecodeWireValue(upb_Decoder* d, const char* ptr,
|
8305
|
+
const upb_MiniTable* mt,
|
8306
|
+
const upb_MiniTableField* field,
|
8307
|
+
int wire_type, wireval* val, int* op) {
|
7666
8308
|
static const unsigned kFixed32OkMask = (1 << kUpb_FieldType_Float) |
|
7667
8309
|
(1 << kUpb_FieldType_Fixed32) |
|
7668
8310
|
(1 << kUpb_FieldType_SFixed32);
|
@@ -7712,12 +8354,14 @@ static const char* _upb_Decoder_DecodeWireValue(upb_Decoder* d, const char* ptr,
|
|
7712
8354
|
}
|
7713
8355
|
|
7714
8356
|
UPB_FORCEINLINE
|
7715
|
-
|
7716
|
-
|
7717
|
-
|
7718
|
-
|
7719
|
-
|
8357
|
+
const char* _upb_Decoder_DecodeKnownField(upb_Decoder* d, const char* ptr,
|
8358
|
+
upb_Message* msg,
|
8359
|
+
const upb_MiniTable* layout,
|
8360
|
+
const upb_MiniTableField* field,
|
8361
|
+
int op, wireval* val) {
|
8362
|
+
const upb_MiniTableSubInternal* subs = layout->UPB_PRIVATE(subs);
|
7720
8363
|
uint8_t mode = field->UPB_PRIVATE(mode);
|
8364
|
+
upb_MiniTableSubInternal ext_sub;
|
7721
8365
|
|
7722
8366
|
if (UPB_UNLIKELY(mode & kUpb_LabelFlags_IsExtension)) {
|
7723
8367
|
const upb_MiniTableExtension* ext_layout =
|
@@ -7729,7 +8373,14 @@ static const char* _upb_Decoder_DecodeKnownField(
|
|
7729
8373
|
}
|
7730
8374
|
d->unknown_msg = msg;
|
7731
8375
|
msg = (upb_Message*)&ext->data;
|
7732
|
-
|
8376
|
+
if (upb_MiniTableField_IsSubMessage(&ext->ext->UPB_PRIVATE(field))) {
|
8377
|
+
ext_sub.UPB_PRIVATE(submsg) =
|
8378
|
+
&ext->ext->UPB_PRIVATE(sub).UPB_PRIVATE(submsg);
|
8379
|
+
} else {
|
8380
|
+
ext_sub.UPB_PRIVATE(subenum) =
|
8381
|
+
ext->ext->UPB_PRIVATE(sub).UPB_PRIVATE(subenum);
|
8382
|
+
}
|
8383
|
+
subs = &ext_sub;
|
7733
8384
|
}
|
7734
8385
|
|
7735
8386
|
switch (mode & kUpb_FieldMode_Mask) {
|
@@ -7921,9 +8572,10 @@ static upb_DecodeStatus upb_Decoder_Decode(upb_Decoder* const decoder,
|
|
7921
8572
|
}
|
7922
8573
|
|
7923
8574
|
upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg,
|
7924
|
-
const upb_MiniTable*
|
8575
|
+
const upb_MiniTable* mt,
|
7925
8576
|
const upb_ExtensionRegistry* extreg, int options,
|
7926
8577
|
upb_Arena* arena) {
|
8578
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
7927
8579
|
upb_Decoder decoder;
|
7928
8580
|
unsigned depth = (unsigned)options >> 16;
|
7929
8581
|
|
@@ -7945,7 +8597,63 @@ upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg,
|
|
7945
8597
|
// (particularly parent_or_count).
|
7946
8598
|
UPB_PRIVATE(_upb_Arena_SwapIn)(&decoder.arena, arena);
|
7947
8599
|
|
7948
|
-
return upb_Decoder_Decode(&decoder, buf, msg,
|
8600
|
+
return upb_Decoder_Decode(&decoder, buf, msg, mt, arena);
|
8601
|
+
}
|
8602
|
+
|
8603
|
+
upb_DecodeStatus upb_DecodeLengthPrefixed(const char* buf, size_t size,
|
8604
|
+
upb_Message* msg,
|
8605
|
+
size_t* num_bytes_read,
|
8606
|
+
const upb_MiniTable* mt,
|
8607
|
+
const upb_ExtensionRegistry* extreg,
|
8608
|
+
int options, upb_Arena* arena) {
|
8609
|
+
// To avoid needing to make a Decoder just to decode the initial length,
|
8610
|
+
// hand-decode the leading varint for the message length here.
|
8611
|
+
uint64_t msg_len = 0;
|
8612
|
+
for (size_t i = 0;; ++i) {
|
8613
|
+
if (i >= size || i > 9) {
|
8614
|
+
return kUpb_DecodeStatus_Malformed;
|
8615
|
+
}
|
8616
|
+
uint64_t b = *buf;
|
8617
|
+
buf++;
|
8618
|
+
msg_len += (b & 0x7f) << (i * 7);
|
8619
|
+
if ((b & 0x80) == 0) {
|
8620
|
+
*num_bytes_read = i + 1 + msg_len;
|
8621
|
+
break;
|
8622
|
+
}
|
8623
|
+
}
|
8624
|
+
|
8625
|
+
// If the total number of bytes we would read (= the bytes from the varint
|
8626
|
+
// plus however many bytes that varint says we should read) is larger then the
|
8627
|
+
// input buffer then error as malformed.
|
8628
|
+
if (*num_bytes_read > size) {
|
8629
|
+
return kUpb_DecodeStatus_Malformed;
|
8630
|
+
}
|
8631
|
+
if (msg_len > INT32_MAX) {
|
8632
|
+
return kUpb_DecodeStatus_Malformed;
|
8633
|
+
}
|
8634
|
+
|
8635
|
+
return upb_Decode(buf, msg_len, msg, mt, extreg, options, arena);
|
8636
|
+
}
|
8637
|
+
|
8638
|
+
const char* upb_DecodeStatus_String(upb_DecodeStatus status) {
|
8639
|
+
switch (status) {
|
8640
|
+
case kUpb_DecodeStatus_Ok:
|
8641
|
+
return "Ok";
|
8642
|
+
case kUpb_DecodeStatus_Malformed:
|
8643
|
+
return "Wire format was corrupt";
|
8644
|
+
case kUpb_DecodeStatus_OutOfMemory:
|
8645
|
+
return "Arena alloc failed";
|
8646
|
+
case kUpb_DecodeStatus_BadUtf8:
|
8647
|
+
return "String field had bad UTF-8";
|
8648
|
+
case kUpb_DecodeStatus_MaxDepthExceeded:
|
8649
|
+
return "Exceeded upb_DecodeOptions_MaxDepth";
|
8650
|
+
case kUpb_DecodeStatus_MissingRequired:
|
8651
|
+
return "Missing required field";
|
8652
|
+
case kUpb_DecodeStatus_UnlinkedSubMessage:
|
8653
|
+
return "Unlinked sub-message field was present";
|
8654
|
+
default:
|
8655
|
+
return "Unknown decode status";
|
8656
|
+
}
|
7949
8657
|
}
|
7950
8658
|
|
7951
8659
|
#undef OP_FIXPCK_LG2
|
@@ -7962,6 +8670,13 @@ upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg,
|
|
7962
8670
|
|
7963
8671
|
// Must be last.
|
7964
8672
|
|
8673
|
+
// Returns the MiniTable corresponding to a given MiniTableField
|
8674
|
+
// from an array of MiniTableSubs.
|
8675
|
+
static const upb_MiniTable* _upb_Encoder_GetSubMiniTable(
|
8676
|
+
const upb_MiniTableSubInternal* subs, const upb_MiniTableField* field) {
|
8677
|
+
return *subs[field->UPB_PRIVATE(submsg_index)].UPB_PRIVATE(submsg);
|
8678
|
+
}
|
8679
|
+
|
7965
8680
|
#define UPB_PB_VARINT_MAX_LEN 10
|
7966
8681
|
|
7967
8682
|
UPB_NOINLINE
|
@@ -8032,7 +8747,7 @@ static void encode_growbuffer(upb_encstate* e, size_t bytes) {
|
|
8032
8747
|
/* Call to ensure that at least "bytes" bytes are available for writing at
|
8033
8748
|
* e->ptr. Returns false if the bytes could not be allocated. */
|
8034
8749
|
UPB_FORCEINLINE
|
8035
|
-
|
8750
|
+
void encode_reserve(upb_encstate* e, size_t bytes) {
|
8036
8751
|
if ((size_t)(e->ptr - e->buf) < bytes) {
|
8037
8752
|
encode_growbuffer(e, bytes);
|
8038
8753
|
return;
|
@@ -8071,7 +8786,7 @@ static void encode_longvarint(upb_encstate* e, uint64_t val) {
|
|
8071
8786
|
}
|
8072
8787
|
|
8073
8788
|
UPB_FORCEINLINE
|
8074
|
-
|
8789
|
+
void encode_varint(upb_encstate* e, uint64_t val) {
|
8075
8790
|
if (val < 128 && e->ptr != e->buf) {
|
8076
8791
|
--e->ptr;
|
8077
8792
|
*e->ptr = val;
|
@@ -8101,7 +8816,7 @@ static void encode_tag(upb_encstate* e, uint32_t field_number,
|
|
8101
8816
|
|
8102
8817
|
static void encode_fixedarray(upb_encstate* e, const upb_Array* arr,
|
8103
8818
|
size_t elem_size, uint32_t tag) {
|
8104
|
-
size_t bytes = arr
|
8819
|
+
size_t bytes = upb_Array_Size(arr) * elem_size;
|
8105
8820
|
const char* data = upb_Array_DataPtr(arr);
|
8106
8821
|
const char* ptr = data + bytes - elem_size;
|
8107
8822
|
|
@@ -8143,7 +8858,7 @@ static void encode_TaggedMessagePtr(upb_encstate* e,
|
|
8143
8858
|
}
|
8144
8859
|
|
8145
8860
|
static void encode_scalar(upb_encstate* e, const void* _field_mem,
|
8146
|
-
const
|
8861
|
+
const upb_MiniTableSubInternal* subs,
|
8147
8862
|
const upb_MiniTableField* f) {
|
8148
8863
|
const char* field_mem = _field_mem;
|
8149
8864
|
int wire_type;
|
@@ -8192,13 +8907,12 @@ static void encode_scalar(upb_encstate* e, const void* _field_mem,
|
|
8192
8907
|
case kUpb_FieldType_Group: {
|
8193
8908
|
size_t size;
|
8194
8909
|
upb_TaggedMessagePtr submsg = *(upb_TaggedMessagePtr*)field_mem;
|
8195
|
-
const upb_MiniTable* subm =
|
8196
|
-
upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]);
|
8910
|
+
const upb_MiniTable* subm = _upb_Encoder_GetSubMiniTable(subs, f);
|
8197
8911
|
if (submsg == 0) {
|
8198
8912
|
return;
|
8199
8913
|
}
|
8200
8914
|
if (--e->depth == 0) encode_err(e, kUpb_EncodeStatus_MaxDepthExceeded);
|
8201
|
-
encode_tag(e, f
|
8915
|
+
encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_EndGroup);
|
8202
8916
|
encode_TaggedMessagePtr(e, submsg, subm, &size);
|
8203
8917
|
wire_type = kUpb_WireType_StartGroup;
|
8204
8918
|
e->depth++;
|
@@ -8207,8 +8921,7 @@ static void encode_scalar(upb_encstate* e, const void* _field_mem,
|
|
8207
8921
|
case kUpb_FieldType_Message: {
|
8208
8922
|
size_t size;
|
8209
8923
|
upb_TaggedMessagePtr submsg = *(upb_TaggedMessagePtr*)field_mem;
|
8210
|
-
const upb_MiniTable* subm =
|
8211
|
-
upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]);
|
8924
|
+
const upb_MiniTable* subm = _upb_Encoder_GetSubMiniTable(subs, f);
|
8212
8925
|
if (submsg == 0) {
|
8213
8926
|
return;
|
8214
8927
|
}
|
@@ -8224,24 +8937,24 @@ static void encode_scalar(upb_encstate* e, const void* _field_mem,
|
|
8224
8937
|
}
|
8225
8938
|
#undef CASE
|
8226
8939
|
|
8227
|
-
encode_tag(e, f
|
8940
|
+
encode_tag(e, upb_MiniTableField_Number(f), wire_type);
|
8228
8941
|
}
|
8229
8942
|
|
8230
8943
|
static void encode_array(upb_encstate* e, const upb_Message* msg,
|
8231
|
-
const
|
8944
|
+
const upb_MiniTableSubInternal* subs,
|
8232
8945
|
const upb_MiniTableField* f) {
|
8233
8946
|
const upb_Array* arr = *UPB_PTR_AT(msg, f->UPB_PRIVATE(offset), upb_Array*);
|
8234
8947
|
bool packed = upb_MiniTableField_IsPacked(f);
|
8235
8948
|
size_t pre_len = e->limit - e->ptr;
|
8236
8949
|
|
8237
|
-
if (arr == NULL || arr
|
8950
|
+
if (arr == NULL || upb_Array_Size(arr) == 0) {
|
8238
8951
|
return;
|
8239
8952
|
}
|
8240
8953
|
|
8241
8954
|
#define VARINT_CASE(ctype, encode) \
|
8242
8955
|
{ \
|
8243
8956
|
const ctype* start = upb_Array_DataPtr(arr); \
|
8244
|
-
const ctype* ptr = start + arr
|
8957
|
+
const ctype* ptr = start + upb_Array_Size(arr); \
|
8245
8958
|
uint32_t tag = \
|
8246
8959
|
packed ? 0 : (f->UPB_PRIVATE(number) << 3) | kUpb_WireType_Varint; \
|
8247
8960
|
do { \
|
@@ -8286,43 +8999,41 @@ static void encode_array(upb_encstate* e, const upb_Message* msg,
|
|
8286
8999
|
case kUpb_FieldType_String:
|
8287
9000
|
case kUpb_FieldType_Bytes: {
|
8288
9001
|
const upb_StringView* start = upb_Array_DataPtr(arr);
|
8289
|
-
const upb_StringView* ptr = start + arr
|
9002
|
+
const upb_StringView* ptr = start + upb_Array_Size(arr);
|
8290
9003
|
do {
|
8291
9004
|
ptr--;
|
8292
9005
|
encode_bytes(e, ptr->data, ptr->size);
|
8293
9006
|
encode_varint(e, ptr->size);
|
8294
|
-
encode_tag(e, f
|
9007
|
+
encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_Delimited);
|
8295
9008
|
} while (ptr != start);
|
8296
9009
|
return;
|
8297
9010
|
}
|
8298
9011
|
case kUpb_FieldType_Group: {
|
8299
9012
|
const upb_TaggedMessagePtr* start = upb_Array_DataPtr(arr);
|
8300
|
-
const upb_TaggedMessagePtr* ptr = start + arr
|
8301
|
-
const upb_MiniTable* subm =
|
8302
|
-
upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]);
|
9013
|
+
const upb_TaggedMessagePtr* ptr = start + upb_Array_Size(arr);
|
9014
|
+
const upb_MiniTable* subm = _upb_Encoder_GetSubMiniTable(subs, f);
|
8303
9015
|
if (--e->depth == 0) encode_err(e, kUpb_EncodeStatus_MaxDepthExceeded);
|
8304
9016
|
do {
|
8305
9017
|
size_t size;
|
8306
9018
|
ptr--;
|
8307
|
-
encode_tag(e, f
|
9019
|
+
encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_EndGroup);
|
8308
9020
|
encode_TaggedMessagePtr(e, *ptr, subm, &size);
|
8309
|
-
encode_tag(e, f
|
9021
|
+
encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_StartGroup);
|
8310
9022
|
} while (ptr != start);
|
8311
9023
|
e->depth++;
|
8312
9024
|
return;
|
8313
9025
|
}
|
8314
9026
|
case kUpb_FieldType_Message: {
|
8315
9027
|
const upb_TaggedMessagePtr* start = upb_Array_DataPtr(arr);
|
8316
|
-
const upb_TaggedMessagePtr* ptr = start + arr
|
8317
|
-
const upb_MiniTable* subm =
|
8318
|
-
upb_MiniTableSub_Message(subs[f->UPB_PRIVATE(submsg_index)]);
|
9028
|
+
const upb_TaggedMessagePtr* ptr = start + upb_Array_Size(arr);
|
9029
|
+
const upb_MiniTable* subm = _upb_Encoder_GetSubMiniTable(subs, f);
|
8319
9030
|
if (--e->depth == 0) encode_err(e, kUpb_EncodeStatus_MaxDepthExceeded);
|
8320
9031
|
do {
|
8321
9032
|
size_t size;
|
8322
9033
|
ptr--;
|
8323
9034
|
encode_TaggedMessagePtr(e, *ptr, subm, &size);
|
8324
9035
|
encode_varint(e, size);
|
8325
|
-
encode_tag(e, f
|
9036
|
+
encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_Delimited);
|
8326
9037
|
} while (ptr != start);
|
8327
9038
|
e->depth++;
|
8328
9039
|
return;
|
@@ -8332,15 +9043,15 @@ static void encode_array(upb_encstate* e, const upb_Message* msg,
|
|
8332
9043
|
|
8333
9044
|
if (packed) {
|
8334
9045
|
encode_varint(e, e->limit - e->ptr - pre_len);
|
8335
|
-
encode_tag(e, f
|
9046
|
+
encode_tag(e, upb_MiniTableField_Number(f), kUpb_WireType_Delimited);
|
8336
9047
|
}
|
8337
9048
|
}
|
8338
9049
|
|
8339
9050
|
static void encode_mapentry(upb_encstate* e, uint32_t number,
|
8340
9051
|
const upb_MiniTable* layout,
|
8341
9052
|
const upb_MapEntry* ent) {
|
8342
|
-
const upb_MiniTableField* key_field =
|
8343
|
-
const upb_MiniTableField* val_field =
|
9053
|
+
const upb_MiniTableField* key_field = upb_MiniTable_MapKey(layout);
|
9054
|
+
const upb_MiniTableField* val_field = upb_MiniTable_MapValue(layout);
|
8344
9055
|
size_t pre_len = e->limit - e->ptr;
|
8345
9056
|
size_t size;
|
8346
9057
|
encode_scalar(e, &ent->v, layout->UPB_PRIVATE(subs), val_field);
|
@@ -8351,12 +9062,11 @@ static void encode_mapentry(upb_encstate* e, uint32_t number,
|
|
8351
9062
|
}
|
8352
9063
|
|
8353
9064
|
static void encode_map(upb_encstate* e, const upb_Message* msg,
|
8354
|
-
const
|
9065
|
+
const upb_MiniTableSubInternal* subs,
|
8355
9066
|
const upb_MiniTableField* f) {
|
8356
9067
|
const upb_Map* map = *UPB_PTR_AT(msg, f->UPB_PRIVATE(offset), const upb_Map*);
|
8357
|
-
const upb_MiniTable* layout =
|
8358
|
-
|
8359
|
-
UPB_ASSERT(layout->UPB_PRIVATE(field_count) == 2);
|
9068
|
+
const upb_MiniTable* layout = _upb_Encoder_GetSubMiniTable(subs, f);
|
9069
|
+
UPB_ASSERT(upb_MiniTable_FieldCount(layout) == 2);
|
8360
9070
|
|
8361
9071
|
if (!map || !upb_Map_Size(map)) return;
|
8362
9072
|
|
@@ -8367,7 +9077,7 @@ static void encode_map(upb_encstate* e, const upb_Message* msg,
|
|
8367
9077
|
map, &sorted);
|
8368
9078
|
upb_MapEntry ent;
|
8369
9079
|
while (_upb_sortedmap_next(&e->sorter, map, &sorted, &ent)) {
|
8370
|
-
encode_mapentry(e, f
|
9080
|
+
encode_mapentry(e, upb_MiniTableField_Number(f), layout, &ent);
|
8371
9081
|
}
|
8372
9082
|
_upb_mapsorter_popmap(&e->sorter, &sorted);
|
8373
9083
|
} else {
|
@@ -8378,13 +9088,12 @@ static void encode_map(upb_encstate* e, const upb_Message* msg,
|
|
8378
9088
|
upb_MapEntry ent;
|
8379
9089
|
_upb_map_fromkey(key, &ent.k, map->key_size);
|
8380
9090
|
_upb_map_fromvalue(val, &ent.v, map->val_size);
|
8381
|
-
encode_mapentry(e, f
|
9091
|
+
encode_mapentry(e, upb_MiniTableField_Number(f), layout, &ent);
|
8382
9092
|
}
|
8383
9093
|
}
|
8384
9094
|
}
|
8385
9095
|
|
8386
9096
|
static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg,
|
8387
|
-
const upb_MiniTableSub* subs,
|
8388
9097
|
const upb_MiniTableField* f) {
|
8389
9098
|
if (f->presence == 0) {
|
8390
9099
|
// Proto3 presence or map/array.
|
@@ -8418,12 +9127,12 @@ static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg,
|
|
8418
9127
|
} else {
|
8419
9128
|
// Field is in a oneof.
|
8420
9129
|
return UPB_PRIVATE(_upb_Message_GetOneofCase)(msg, f) ==
|
8421
|
-
f
|
9130
|
+
upb_MiniTableField_Number(f);
|
8422
9131
|
}
|
8423
9132
|
}
|
8424
9133
|
|
8425
9134
|
static void encode_field(upb_encstate* e, const upb_Message* msg,
|
8426
|
-
const
|
9135
|
+
const upb_MiniTableSubInternal* subs,
|
8427
9136
|
const upb_MiniTableField* field) {
|
8428
9137
|
switch (UPB_PRIVATE(_upb_MiniTableField_Mode)(field)) {
|
8429
9138
|
case kUpb_FieldMode_Array:
|
@@ -8444,7 +9153,7 @@ static void encode_field(upb_encstate* e, const upb_Message* msg,
|
|
8444
9153
|
static void encode_msgset_item(upb_encstate* e, const upb_Extension* ext) {
|
8445
9154
|
size_t size;
|
8446
9155
|
encode_tag(e, kUpb_MsgSet_Item, kUpb_WireType_EndGroup);
|
8447
|
-
encode_message(e, ext->data.
|
9156
|
+
encode_message(e, ext->data.msg_val,
|
8448
9157
|
upb_MiniTableExtension_GetSubMessage(ext->ext), &size);
|
8449
9158
|
encode_varint(e, size);
|
8450
9159
|
encode_tag(e, kUpb_MsgSet_Message, kUpb_WireType_Delimited);
|
@@ -8458,7 +9167,14 @@ static void encode_ext(upb_encstate* e, const upb_Extension* ext,
|
|
8458
9167
|
if (UPB_UNLIKELY(is_message_set)) {
|
8459
9168
|
encode_msgset_item(e, ext);
|
8460
9169
|
} else {
|
8461
|
-
|
9170
|
+
upb_MiniTableSubInternal sub;
|
9171
|
+
if (upb_MiniTableField_IsSubMessage(&ext->ext->UPB_PRIVATE(field))) {
|
9172
|
+
sub.UPB_PRIVATE(submsg) = &ext->ext->UPB_PRIVATE(sub).UPB_PRIVATE(submsg);
|
9173
|
+
} else {
|
9174
|
+
sub.UPB_PRIVATE(subenum) =
|
9175
|
+
ext->ext->UPB_PRIVATE(sub).UPB_PRIVATE(subenum);
|
9176
|
+
}
|
9177
|
+
encode_field(e, (upb_Message*)&ext->data, &sub,
|
8462
9178
|
&ext->ext->UPB_PRIVATE(field));
|
8463
9179
|
}
|
8464
9180
|
}
|
@@ -8508,13 +9224,13 @@ static void encode_message(upb_encstate* e, const upb_Message* msg,
|
|
8508
9224
|
}
|
8509
9225
|
}
|
8510
9226
|
|
8511
|
-
if (m
|
9227
|
+
if (upb_MiniTable_FieldCount(m)) {
|
8512
9228
|
const upb_MiniTableField* f =
|
8513
9229
|
&m->UPB_PRIVATE(fields)[m->UPB_PRIVATE(field_count)];
|
8514
9230
|
const upb_MiniTableField* first = &m->UPB_PRIVATE(fields)[0];
|
8515
9231
|
while (f != first) {
|
8516
9232
|
f--;
|
8517
|
-
if (encode_shouldencode(e, msg,
|
9233
|
+
if (encode_shouldencode(e, msg, f)) {
|
8518
9234
|
encode_field(e, msg, m->UPB_PRIVATE(subs), f);
|
8519
9235
|
}
|
8520
9236
|
}
|
@@ -8526,14 +9242,18 @@ static void encode_message(upb_encstate* e, const upb_Message* msg,
|
|
8526
9242
|
static upb_EncodeStatus upb_Encoder_Encode(upb_encstate* const encoder,
|
8527
9243
|
const upb_Message* const msg,
|
8528
9244
|
const upb_MiniTable* const l,
|
8529
|
-
char** const buf,
|
8530
|
-
|
9245
|
+
char** const buf, size_t* const size,
|
9246
|
+
bool prepend_len) {
|
8531
9247
|
// Unfortunately we must continue to perform hackery here because there are
|
8532
9248
|
// code paths which blindly copy the returned pointer without bothering to
|
8533
9249
|
// check for errors until much later (b/235839510). So we still set *buf to
|
8534
9250
|
// NULL on error and we still set it to non-NULL on a successful empty result.
|
8535
9251
|
if (UPB_SETJMP(encoder->err) == 0) {
|
8536
|
-
|
9252
|
+
size_t encoded_msg_size;
|
9253
|
+
encode_message(encoder, msg, l, &encoded_msg_size);
|
9254
|
+
if (prepend_len) {
|
9255
|
+
encode_varint(encoder, encoded_msg_size);
|
9256
|
+
}
|
8537
9257
|
*size = encoder->limit - encoder->ptr;
|
8538
9258
|
if (*size == 0) {
|
8539
9259
|
static char ch;
|
@@ -8552,9 +9272,10 @@ static upb_EncodeStatus upb_Encoder_Encode(upb_encstate* const encoder,
|
|
8552
9272
|
return encoder->status;
|
8553
9273
|
}
|
8554
9274
|
|
8555
|
-
upb_EncodeStatus
|
8556
|
-
|
8557
|
-
|
9275
|
+
static upb_EncodeStatus _upb_Encode(const upb_Message* msg,
|
9276
|
+
const upb_MiniTable* l, int options,
|
9277
|
+
upb_Arena* arena, char** buf, size_t* size,
|
9278
|
+
bool prepend_len) {
|
8558
9279
|
upb_encstate e;
|
8559
9280
|
unsigned depth = (unsigned)options >> 16;
|
8560
9281
|
|
@@ -8567,7 +9288,35 @@ upb_EncodeStatus upb_Encode(const upb_Message* msg, const upb_MiniTable* l,
|
|
8567
9288
|
e.options = options;
|
8568
9289
|
_upb_mapsorter_init(&e.sorter);
|
8569
9290
|
|
8570
|
-
return upb_Encoder_Encode(&e, msg, l, buf, size);
|
9291
|
+
return upb_Encoder_Encode(&e, msg, l, buf, size, prepend_len);
|
9292
|
+
}
|
9293
|
+
|
9294
|
+
upb_EncodeStatus upb_Encode(const upb_Message* msg, const upb_MiniTable* l,
|
9295
|
+
int options, upb_Arena* arena, char** buf,
|
9296
|
+
size_t* size) {
|
9297
|
+
return _upb_Encode(msg, l, options, arena, buf, size, false);
|
9298
|
+
}
|
9299
|
+
|
9300
|
+
upb_EncodeStatus upb_EncodeLengthPrefixed(const upb_Message* msg,
|
9301
|
+
const upb_MiniTable* l, int options,
|
9302
|
+
upb_Arena* arena, char** buf,
|
9303
|
+
size_t* size) {
|
9304
|
+
return _upb_Encode(msg, l, options, arena, buf, size, true);
|
9305
|
+
}
|
9306
|
+
|
9307
|
+
const char* upb_EncodeStatus_String(upb_EncodeStatus status) {
|
9308
|
+
switch (status) {
|
9309
|
+
case kUpb_EncodeStatus_Ok:
|
9310
|
+
return "Ok";
|
9311
|
+
case kUpb_EncodeStatus_MissingRequired:
|
9312
|
+
return "Missing required field";
|
9313
|
+
case kUpb_EncodeStatus_MaxDepthExceeded:
|
9314
|
+
return "Max depth exceeded";
|
9315
|
+
case kUpb_EncodeStatus_OutOfMemory:
|
9316
|
+
return "Arena alloc failed";
|
9317
|
+
default:
|
9318
|
+
return "Unknown encode status";
|
9319
|
+
}
|
8571
9320
|
}
|
8572
9321
|
|
8573
9322
|
// Fast decoder: ~3x the speed of decode.c, but requires x86-64/ARM64.
|
@@ -8617,7 +9366,7 @@ static const char* fastdecode_isdonefallback(UPB_PARSE_PARAMS) {
|
|
8617
9366
|
}
|
8618
9367
|
|
8619
9368
|
UPB_FORCEINLINE
|
8620
|
-
|
9369
|
+
const char* fastdecode_dispatch(UPB_PARSE_PARAMS) {
|
8621
9370
|
int overrun;
|
8622
9371
|
switch (upb_EpsCopyInputStream_IsDoneStatus(&d->input, ptr, &overrun)) {
|
8623
9372
|
case kUpb_IsDoneStatus_Done:
|
@@ -8639,7 +9388,7 @@ static const char* fastdecode_dispatch(UPB_PARSE_PARAMS) {
|
|
8639
9388
|
}
|
8640
9389
|
|
8641
9390
|
UPB_FORCEINLINE
|
8642
|
-
|
9391
|
+
bool fastdecode_checktag(uint16_t data, int tagbytes) {
|
8643
9392
|
if (tagbytes == 1) {
|
8644
9393
|
return (data & 0xff) == 0;
|
8645
9394
|
} else {
|
@@ -8648,7 +9397,7 @@ static bool fastdecode_checktag(uint16_t data, int tagbytes) {
|
|
8648
9397
|
}
|
8649
9398
|
|
8650
9399
|
UPB_FORCEINLINE
|
8651
|
-
|
9400
|
+
const char* fastdecode_longsize(const char* ptr, int* size) {
|
8652
9401
|
int i;
|
8653
9402
|
UPB_ASSERT(*size & 0x80);
|
8654
9403
|
*size &= 0xff;
|
@@ -8668,7 +9417,7 @@ static const char* fastdecode_longsize(const char* ptr, int* size) {
|
|
8668
9417
|
}
|
8669
9418
|
|
8670
9419
|
UPB_FORCEINLINE
|
8671
|
-
|
9420
|
+
const char* fastdecode_delimited(
|
8672
9421
|
upb_Decoder* d, const char* ptr,
|
8673
9422
|
upb_EpsCopyInputStream_ParseDelimitedFunc* func, void* ctx) {
|
8674
9423
|
ptr++;
|
@@ -8721,8 +9470,8 @@ typedef struct {
|
|
8721
9470
|
} fastdecode_nextret;
|
8722
9471
|
|
8723
9472
|
UPB_FORCEINLINE
|
8724
|
-
|
8725
|
-
|
9473
|
+
void* fastdecode_resizearr(upb_Decoder* d, void* dst, fastdecode_arr* farr,
|
9474
|
+
int valbytes) {
|
8726
9475
|
if (UPB_UNLIKELY(dst == farr->end)) {
|
8727
9476
|
size_t old_capacity = farr->arr->UPB_PRIVATE(capacity);
|
8728
9477
|
size_t old_bytes = old_capacity * valbytes;
|
@@ -8740,7 +9489,7 @@ static void* fastdecode_resizearr(upb_Decoder* d, void* dst,
|
|
8740
9489
|
}
|
8741
9490
|
|
8742
9491
|
UPB_FORCEINLINE
|
8743
|
-
|
9492
|
+
bool fastdecode_tagmatch(uint32_t tag, uint64_t data, int tagbytes) {
|
8744
9493
|
if (tagbytes == 1) {
|
8745
9494
|
return (uint8_t)tag == (uint8_t)data;
|
8746
9495
|
} else {
|
@@ -8749,19 +9498,17 @@ static bool fastdecode_tagmatch(uint32_t tag, uint64_t data, int tagbytes) {
|
|
8749
9498
|
}
|
8750
9499
|
|
8751
9500
|
UPB_FORCEINLINE
|
8752
|
-
|
8753
|
-
int valbytes) {
|
9501
|
+
void fastdecode_commitarr(void* dst, fastdecode_arr* farr, int valbytes) {
|
8754
9502
|
farr->arr->UPB_PRIVATE(size) =
|
8755
9503
|
(size_t)((char*)dst - (char*)upb_Array_MutableDataPtr(farr->arr)) /
|
8756
9504
|
valbytes;
|
8757
9505
|
}
|
8758
9506
|
|
8759
9507
|
UPB_FORCEINLINE
|
8760
|
-
|
8761
|
-
|
8762
|
-
|
8763
|
-
|
8764
|
-
int valbytes) {
|
9508
|
+
fastdecode_nextret fastdecode_nextrepeated(upb_Decoder* d, void* dst,
|
9509
|
+
const char** ptr,
|
9510
|
+
fastdecode_arr* farr, uint64_t data,
|
9511
|
+
int tagbytes, int valbytes) {
|
8765
9512
|
fastdecode_nextret ret;
|
8766
9513
|
dst = (char*)dst + valbytes;
|
8767
9514
|
|
@@ -8783,16 +9530,16 @@ static fastdecode_nextret fastdecode_nextrepeated(upb_Decoder* d, void* dst,
|
|
8783
9530
|
}
|
8784
9531
|
|
8785
9532
|
UPB_FORCEINLINE
|
8786
|
-
|
9533
|
+
void* fastdecode_fieldmem(upb_Message* msg, uint64_t data) {
|
8787
9534
|
size_t ofs = data >> 48;
|
8788
9535
|
return (char*)msg + ofs;
|
8789
9536
|
}
|
8790
9537
|
|
8791
9538
|
UPB_FORCEINLINE
|
8792
|
-
|
8793
|
-
|
8794
|
-
|
8795
|
-
|
9539
|
+
void* fastdecode_getfield(upb_Decoder* d, const char* ptr, upb_Message* msg,
|
9540
|
+
uint64_t* data, uint64_t* hasbits,
|
9541
|
+
fastdecode_arr* farr, int valbytes, upb_card card) {
|
9542
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
8796
9543
|
switch (card) {
|
8797
9544
|
case CARD_s: {
|
8798
9545
|
uint8_t hasbit_index = *data >> 24;
|
@@ -8831,7 +9578,7 @@ static void* fastdecode_getfield(upb_Decoder* d, const char* ptr,
|
|
8831
9578
|
}
|
8832
9579
|
|
8833
9580
|
UPB_FORCEINLINE
|
8834
|
-
|
9581
|
+
bool fastdecode_flippacked(uint64_t* data, int tagbytes) {
|
8835
9582
|
*data ^= (0x2 ^ 0x0); // Patch data to match packed wiretype.
|
8836
9583
|
return fastdecode_checktag(*data, tagbytes);
|
8837
9584
|
}
|
@@ -8847,7 +9594,7 @@ static bool fastdecode_flippacked(uint64_t* data, int tagbytes) {
|
|
8847
9594
|
/* varint fields **************************************************************/
|
8848
9595
|
|
8849
9596
|
UPB_FORCEINLINE
|
8850
|
-
|
9597
|
+
uint64_t fastdecode_munge(uint64_t val, int valbytes, bool zigzag) {
|
8851
9598
|
if (valbytes == 1) {
|
8852
9599
|
return val != 0;
|
8853
9600
|
} else if (zigzag) {
|
@@ -8863,7 +9610,7 @@ static uint64_t fastdecode_munge(uint64_t val, int valbytes, bool zigzag) {
|
|
8863
9610
|
}
|
8864
9611
|
|
8865
9612
|
UPB_FORCEINLINE
|
8866
|
-
|
9613
|
+
const char* fastdecode_varint64(const char* ptr, uint64_t* val) {
|
8867
9614
|
ptr++;
|
8868
9615
|
*val = (uint8_t)ptr[-1];
|
8869
9616
|
if (UPB_UNLIKELY(*val & 0x80)) {
|
@@ -8938,8 +9685,8 @@ typedef struct {
|
|
8938
9685
|
} fastdecode_varintdata;
|
8939
9686
|
|
8940
9687
|
UPB_FORCEINLINE
|
8941
|
-
|
8942
|
-
|
9688
|
+
const char* fastdecode_topackedvarint(upb_EpsCopyInputStream* e,
|
9689
|
+
const char* ptr, void* ctx) {
|
8943
9690
|
upb_Decoder* d = (upb_Decoder*)e;
|
8944
9691
|
fastdecode_varintdata* data = ctx;
|
8945
9692
|
void* dst = data->dst;
|
@@ -9168,6 +9915,7 @@ UPB_NOINLINE
|
|
9168
9915
|
static const char* fastdecode_verifyutf8(upb_Decoder* d, const char* ptr,
|
9169
9916
|
upb_Message* msg, intptr_t table,
|
9170
9917
|
uint64_t hasbits, uint64_t data) {
|
9918
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
9171
9919
|
upb_StringView* dst = (upb_StringView*)data;
|
9172
9920
|
if (!_upb_Decoder_VerifyUtf8Inline(dst->data, dst->size)) {
|
9173
9921
|
_upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_BadUtf8);
|
@@ -9213,14 +9961,14 @@ UPB_NOINLINE
|
|
9213
9961
|
static const char* fastdecode_longstring_noutf8(
|
9214
9962
|
struct upb_Decoder* d, const char* ptr, upb_Message* msg, intptr_t table,
|
9215
9963
|
uint64_t hasbits, uint64_t data) {
|
9964
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
9216
9965
|
upb_StringView* dst = (upb_StringView*)data;
|
9217
9966
|
FASTDECODE_LONGSTRING(d, ptr, msg, table, hasbits, dst, false);
|
9218
9967
|
}
|
9219
9968
|
|
9220
9969
|
UPB_FORCEINLINE
|
9221
|
-
|
9222
|
-
|
9223
|
-
upb_StringView* dst) {
|
9970
|
+
void fastdecode_docopy(upb_Decoder* d, const char* ptr, uint32_t size, int copy,
|
9971
|
+
char* data, size_t data_offset, upb_StringView* dst) {
|
9224
9972
|
d->arena.UPB_PRIVATE(ptr) += copy;
|
9225
9973
|
dst->data = data + data_offset;
|
9226
9974
|
UPB_UNPOISON_MEMORY_REGION(data, copy);
|
@@ -9451,8 +10199,8 @@ typedef struct {
|
|
9451
10199
|
} fastdecode_submsgdata;
|
9452
10200
|
|
9453
10201
|
UPB_FORCEINLINE
|
9454
|
-
|
9455
|
-
|
10202
|
+
const char* fastdecode_tosubmsg(upb_EpsCopyInputStream* e, const char* ptr,
|
10203
|
+
void* ctx) {
|
9456
10204
|
upb_Decoder* d = (upb_Decoder*)e;
|
9457
10205
|
fastdecode_submsgdata* submsg = ctx;
|
9458
10206
|
ptr = fastdecode_dispatch(d, ptr, submsg->msg, submsg->table, 0, 0);
|
@@ -9570,8 +10318,7 @@ UPB_NOINLINE UPB_PRIVATE(_upb_WireReader_LongVarint)
|
|
9570
10318
|
UPB_PRIVATE(_upb_WireReader_ReadLongVarint)(const char* ptr, uint64_t val) {
|
9571
10319
|
UPB_PRIVATE(_upb_WireReader_LongVarint) ret = {NULL, 0};
|
9572
10320
|
uint64_t byte;
|
9573
|
-
int i;
|
9574
|
-
for (i = 1; i < 10; i++) {
|
10321
|
+
for (int i = 1; i < 10; i++) {
|
9575
10322
|
byte = (uint8_t)ptr[i];
|
9576
10323
|
val += (byte - 1) << (i * 7);
|
9577
10324
|
if (!(byte & 0x80)) {
|
@@ -10467,6 +11214,8 @@ const char* upb_BufToInt64(const char* ptr, const char* end, int64_t* val,
|
|
10467
11214
|
|
10468
11215
|
|
10469
11216
|
#include <float.h>
|
11217
|
+
#include <math.h>
|
11218
|
+
#include <stdio.h>
|
10470
11219
|
#include <stdlib.h>
|
10471
11220
|
|
10472
11221
|
// Must be last.
|
@@ -10486,6 +11235,10 @@ static void upb_FixLocale(char* p) {
|
|
10486
11235
|
|
10487
11236
|
void _upb_EncodeRoundTripDouble(double val, char* buf, size_t size) {
|
10488
11237
|
assert(size >= kUpb_RoundTripBufferSize);
|
11238
|
+
if (isnan(val)) {
|
11239
|
+
snprintf(buf, size, "%s", "nan");
|
11240
|
+
return;
|
11241
|
+
}
|
10489
11242
|
snprintf(buf, size, "%.*g", DBL_DIG, val);
|
10490
11243
|
if (strtod(buf, NULL) != val) {
|
10491
11244
|
snprintf(buf, size, "%.*g", DBL_DIG + 2, val);
|
@@ -10496,6 +11249,10 @@ void _upb_EncodeRoundTripDouble(double val, char* buf, size_t size) {
|
|
10496
11249
|
|
10497
11250
|
void _upb_EncodeRoundTripFloat(float val, char* buf, size_t size) {
|
10498
11251
|
assert(size >= kUpb_RoundTripBufferSize);
|
11252
|
+
if (isnan(val)) {
|
11253
|
+
snprintf(buf, size, "%s", "nan");
|
11254
|
+
return;
|
11255
|
+
}
|
10499
11256
|
snprintf(buf, size, "%.*g", FLT_DIG, val);
|
10500
11257
|
if (strtof(buf, NULL) != val) {
|
10501
11258
|
snprintf(buf, size, "%.*g", FLT_DIG + 3, val);
|
@@ -10603,15 +11360,291 @@ int upb_Unicode_ToUTF8(uint32_t cp, char* out) {
|
|
10603
11360
|
}
|
10604
11361
|
|
10605
11362
|
|
11363
|
+
#include <stdlib.h>
|
11364
|
+
|
11365
|
+
|
11366
|
+
// Must be last.
|
11367
|
+
|
11368
|
+
typedef struct upb_UnknownFields upb_UnknownFields;
|
11369
|
+
|
11370
|
+
typedef struct {
|
11371
|
+
uint32_t tag;
|
11372
|
+
union {
|
11373
|
+
uint64_t varint;
|
11374
|
+
uint64_t uint64;
|
11375
|
+
uint32_t uint32;
|
11376
|
+
upb_StringView delimited;
|
11377
|
+
upb_UnknownFields* group;
|
11378
|
+
} data;
|
11379
|
+
} upb_UnknownField;
|
11380
|
+
|
11381
|
+
struct upb_UnknownFields {
|
11382
|
+
size_t size;
|
11383
|
+
size_t capacity;
|
11384
|
+
upb_UnknownField* fields;
|
11385
|
+
};
|
11386
|
+
|
11387
|
+
typedef struct {
|
11388
|
+
upb_EpsCopyInputStream stream;
|
11389
|
+
upb_Arena* arena;
|
11390
|
+
upb_UnknownField* tmp;
|
11391
|
+
size_t tmp_size;
|
11392
|
+
int depth;
|
11393
|
+
upb_UnknownCompareResult status;
|
11394
|
+
jmp_buf err;
|
11395
|
+
} upb_UnknownField_Context;
|
11396
|
+
|
11397
|
+
UPB_NORETURN static void upb_UnknownFields_OutOfMemory(
|
11398
|
+
upb_UnknownField_Context* ctx) {
|
11399
|
+
ctx->status = kUpb_UnknownCompareResult_OutOfMemory;
|
11400
|
+
UPB_LONGJMP(ctx->err, 1);
|
11401
|
+
}
|
11402
|
+
|
11403
|
+
static void upb_UnknownFields_Grow(upb_UnknownField_Context* ctx,
|
11404
|
+
upb_UnknownField** base,
|
11405
|
+
upb_UnknownField** ptr,
|
11406
|
+
upb_UnknownField** end) {
|
11407
|
+
size_t old = (*ptr - *base);
|
11408
|
+
size_t new = UPB_MAX(4, old * 2);
|
11409
|
+
|
11410
|
+
*base = upb_Arena_Realloc(ctx->arena, *base, old * sizeof(**base),
|
11411
|
+
new * sizeof(**base));
|
11412
|
+
if (!*base) upb_UnknownFields_OutOfMemory(ctx);
|
11413
|
+
|
11414
|
+
*ptr = *base + old;
|
11415
|
+
*end = *base + new;
|
11416
|
+
}
|
11417
|
+
|
11418
|
+
// We have to implement our own sort here, since qsort() is not an in-order
|
11419
|
+
// sort. Here we use merge sort, the simplest in-order sort.
|
11420
|
+
static void upb_UnknownFields_Merge(upb_UnknownField* arr, size_t start,
|
11421
|
+
size_t mid, size_t end,
|
11422
|
+
upb_UnknownField* tmp) {
|
11423
|
+
memcpy(tmp, &arr[start], (end - start) * sizeof(*tmp));
|
11424
|
+
|
11425
|
+
upb_UnknownField* ptr1 = tmp;
|
11426
|
+
upb_UnknownField* end1 = &tmp[mid - start];
|
11427
|
+
upb_UnknownField* ptr2 = &tmp[mid - start];
|
11428
|
+
upb_UnknownField* end2 = &tmp[end - start];
|
11429
|
+
upb_UnknownField* out = &arr[start];
|
11430
|
+
|
11431
|
+
while (ptr1 < end1 && ptr2 < end2) {
|
11432
|
+
if (ptr1->tag <= ptr2->tag) {
|
11433
|
+
*out++ = *ptr1++;
|
11434
|
+
} else {
|
11435
|
+
*out++ = *ptr2++;
|
11436
|
+
}
|
11437
|
+
}
|
11438
|
+
|
11439
|
+
if (ptr1 < end1) {
|
11440
|
+
memcpy(out, ptr1, (end1 - ptr1) * sizeof(*out));
|
11441
|
+
} else if (ptr2 < end2) {
|
11442
|
+
memcpy(out, ptr1, (end2 - ptr2) * sizeof(*out));
|
11443
|
+
}
|
11444
|
+
}
|
11445
|
+
|
11446
|
+
static void upb_UnknownFields_SortRecursive(upb_UnknownField* arr, size_t start,
|
11447
|
+
size_t end, upb_UnknownField* tmp) {
|
11448
|
+
if (end - start > 1) {
|
11449
|
+
size_t mid = start + ((end - start) / 2);
|
11450
|
+
upb_UnknownFields_SortRecursive(arr, start, mid, tmp);
|
11451
|
+
upb_UnknownFields_SortRecursive(arr, mid, end, tmp);
|
11452
|
+
upb_UnknownFields_Merge(arr, start, mid, end, tmp);
|
11453
|
+
}
|
11454
|
+
}
|
11455
|
+
|
11456
|
+
static void upb_UnknownFields_Sort(upb_UnknownField_Context* ctx,
|
11457
|
+
upb_UnknownFields* fields) {
|
11458
|
+
if (ctx->tmp_size < fields->size) {
|
11459
|
+
const int oldsize = ctx->tmp_size * sizeof(*ctx->tmp);
|
11460
|
+
ctx->tmp_size = UPB_MAX(8, ctx->tmp_size);
|
11461
|
+
while (ctx->tmp_size < fields->size) ctx->tmp_size *= 2;
|
11462
|
+
const int newsize = ctx->tmp_size * sizeof(*ctx->tmp);
|
11463
|
+
ctx->tmp = upb_grealloc(ctx->tmp, oldsize, newsize);
|
11464
|
+
}
|
11465
|
+
upb_UnknownFields_SortRecursive(fields->fields, 0, fields->size, ctx->tmp);
|
11466
|
+
}
|
11467
|
+
|
11468
|
+
static upb_UnknownFields* upb_UnknownFields_DoBuild(
|
11469
|
+
upb_UnknownField_Context* ctx, const char** buf) {
|
11470
|
+
upb_UnknownField* arr_base = NULL;
|
11471
|
+
upb_UnknownField* arr_ptr = NULL;
|
11472
|
+
upb_UnknownField* arr_end = NULL;
|
11473
|
+
const char* ptr = *buf;
|
11474
|
+
uint32_t last_tag = 0;
|
11475
|
+
bool sorted = true;
|
11476
|
+
while (!upb_EpsCopyInputStream_IsDone(&ctx->stream, &ptr)) {
|
11477
|
+
uint32_t tag;
|
11478
|
+
ptr = upb_WireReader_ReadTag(ptr, &tag);
|
11479
|
+
UPB_ASSERT(tag <= UINT32_MAX);
|
11480
|
+
int wire_type = upb_WireReader_GetWireType(tag);
|
11481
|
+
if (wire_type == kUpb_WireType_EndGroup) break;
|
11482
|
+
if (tag < last_tag) sorted = false;
|
11483
|
+
last_tag = tag;
|
11484
|
+
|
11485
|
+
if (arr_ptr == arr_end) {
|
11486
|
+
upb_UnknownFields_Grow(ctx, &arr_base, &arr_ptr, &arr_end);
|
11487
|
+
}
|
11488
|
+
upb_UnknownField* field = arr_ptr;
|
11489
|
+
field->tag = tag;
|
11490
|
+
arr_ptr++;
|
11491
|
+
|
11492
|
+
switch (wire_type) {
|
11493
|
+
case kUpb_WireType_Varint:
|
11494
|
+
ptr = upb_WireReader_ReadVarint(ptr, &field->data.varint);
|
11495
|
+
break;
|
11496
|
+
case kUpb_WireType_64Bit:
|
11497
|
+
ptr = upb_WireReader_ReadFixed64(ptr, &field->data.uint64);
|
11498
|
+
break;
|
11499
|
+
case kUpb_WireType_32Bit:
|
11500
|
+
ptr = upb_WireReader_ReadFixed32(ptr, &field->data.uint32);
|
11501
|
+
break;
|
11502
|
+
case kUpb_WireType_Delimited: {
|
11503
|
+
int size;
|
11504
|
+
ptr = upb_WireReader_ReadSize(ptr, &size);
|
11505
|
+
const char* s_ptr = ptr;
|
11506
|
+
ptr = upb_EpsCopyInputStream_ReadStringAliased(&ctx->stream, &s_ptr,
|
11507
|
+
size);
|
11508
|
+
field->data.delimited.data = s_ptr;
|
11509
|
+
field->data.delimited.size = size;
|
11510
|
+
break;
|
11511
|
+
}
|
11512
|
+
case kUpb_WireType_StartGroup:
|
11513
|
+
if (--ctx->depth == 0) {
|
11514
|
+
ctx->status = kUpb_UnknownCompareResult_MaxDepthExceeded;
|
11515
|
+
UPB_LONGJMP(ctx->err, 1);
|
11516
|
+
}
|
11517
|
+
field->data.group = upb_UnknownFields_DoBuild(ctx, &ptr);
|
11518
|
+
ctx->depth++;
|
11519
|
+
break;
|
11520
|
+
default:
|
11521
|
+
UPB_UNREACHABLE();
|
11522
|
+
}
|
11523
|
+
}
|
11524
|
+
|
11525
|
+
*buf = ptr;
|
11526
|
+
upb_UnknownFields* ret = upb_Arena_Malloc(ctx->arena, sizeof(*ret));
|
11527
|
+
if (!ret) upb_UnknownFields_OutOfMemory(ctx);
|
11528
|
+
ret->fields = arr_base;
|
11529
|
+
ret->size = arr_ptr - arr_base;
|
11530
|
+
ret->capacity = arr_end - arr_base;
|
11531
|
+
if (!sorted) {
|
11532
|
+
upb_UnknownFields_Sort(ctx, ret);
|
11533
|
+
}
|
11534
|
+
return ret;
|
11535
|
+
}
|
11536
|
+
|
11537
|
+
// Builds a upb_UnknownFields data structure from the binary data in buf.
|
11538
|
+
static upb_UnknownFields* upb_UnknownFields_Build(upb_UnknownField_Context* ctx,
|
11539
|
+
const char* ptr,
|
11540
|
+
size_t size) {
|
11541
|
+
upb_EpsCopyInputStream_Init(&ctx->stream, &ptr, size, true);
|
11542
|
+
upb_UnknownFields* fields = upb_UnknownFields_DoBuild(ctx, &ptr);
|
11543
|
+
UPB_ASSERT(upb_EpsCopyInputStream_IsDone(&ctx->stream, &ptr) &&
|
11544
|
+
!upb_EpsCopyInputStream_IsError(&ctx->stream));
|
11545
|
+
return fields;
|
11546
|
+
}
|
11547
|
+
|
11548
|
+
// Compares two sorted upb_UnknownFields structures for equality.
|
11549
|
+
static bool upb_UnknownFields_IsEqual(const upb_UnknownFields* uf1,
|
11550
|
+
const upb_UnknownFields* uf2) {
|
11551
|
+
if (uf1->size != uf2->size) return false;
|
11552
|
+
for (size_t i = 0, n = uf1->size; i < n; i++) {
|
11553
|
+
upb_UnknownField* f1 = &uf1->fields[i];
|
11554
|
+
upb_UnknownField* f2 = &uf2->fields[i];
|
11555
|
+
if (f1->tag != f2->tag) return false;
|
11556
|
+
int wire_type = f1->tag & 7;
|
11557
|
+
switch (wire_type) {
|
11558
|
+
case kUpb_WireType_Varint:
|
11559
|
+
if (f1->data.varint != f2->data.varint) return false;
|
11560
|
+
break;
|
11561
|
+
case kUpb_WireType_64Bit:
|
11562
|
+
if (f1->data.uint64 != f2->data.uint64) return false;
|
11563
|
+
break;
|
11564
|
+
case kUpb_WireType_32Bit:
|
11565
|
+
if (f1->data.uint32 != f2->data.uint32) return false;
|
11566
|
+
break;
|
11567
|
+
case kUpb_WireType_Delimited:
|
11568
|
+
if (!upb_StringView_IsEqual(f1->data.delimited, f2->data.delimited)) {
|
11569
|
+
return false;
|
11570
|
+
}
|
11571
|
+
break;
|
11572
|
+
case kUpb_WireType_StartGroup:
|
11573
|
+
if (!upb_UnknownFields_IsEqual(f1->data.group, f2->data.group)) {
|
11574
|
+
return false;
|
11575
|
+
}
|
11576
|
+
break;
|
11577
|
+
default:
|
11578
|
+
UPB_UNREACHABLE();
|
11579
|
+
}
|
11580
|
+
}
|
11581
|
+
return true;
|
11582
|
+
}
|
11583
|
+
|
11584
|
+
static upb_UnknownCompareResult upb_UnknownField_DoCompare(
|
11585
|
+
upb_UnknownField_Context* ctx, const char* buf1, size_t size1,
|
11586
|
+
const char* buf2, size_t size2) {
|
11587
|
+
upb_UnknownCompareResult ret;
|
11588
|
+
// First build both unknown fields into a sorted data structure (similar
|
11589
|
+
// to the UnknownFieldSet in C++).
|
11590
|
+
upb_UnknownFields* uf1 = upb_UnknownFields_Build(ctx, buf1, size1);
|
11591
|
+
upb_UnknownFields* uf2 = upb_UnknownFields_Build(ctx, buf2, size2);
|
11592
|
+
|
11593
|
+
// Now perform the equality check on the sorted structures.
|
11594
|
+
if (upb_UnknownFields_IsEqual(uf1, uf2)) {
|
11595
|
+
ret = kUpb_UnknownCompareResult_Equal;
|
11596
|
+
} else {
|
11597
|
+
ret = kUpb_UnknownCompareResult_NotEqual;
|
11598
|
+
}
|
11599
|
+
return ret;
|
11600
|
+
}
|
11601
|
+
|
11602
|
+
static upb_UnknownCompareResult upb_UnknownField_Compare(
|
11603
|
+
upb_UnknownField_Context* const ctx, const char* const buf1,
|
11604
|
+
const size_t size1, const char* const buf2, const size_t size2) {
|
11605
|
+
upb_UnknownCompareResult ret;
|
11606
|
+
if (UPB_SETJMP(ctx->err) == 0) {
|
11607
|
+
ret = upb_UnknownField_DoCompare(ctx, buf1, size1, buf2, size2);
|
11608
|
+
} else {
|
11609
|
+
ret = ctx->status;
|
11610
|
+
UPB_ASSERT(ret != kUpb_UnknownCompareResult_Equal);
|
11611
|
+
}
|
11612
|
+
|
11613
|
+
upb_Arena_Free(ctx->arena);
|
11614
|
+
upb_gfree(ctx->tmp);
|
11615
|
+
return ret;
|
11616
|
+
}
|
11617
|
+
|
11618
|
+
upb_UnknownCompareResult UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)(
|
11619
|
+
const char* buf1, size_t size1, const char* buf2, size_t size2,
|
11620
|
+
int max_depth) {
|
11621
|
+
if (size1 == 0 && size2 == 0) return kUpb_UnknownCompareResult_Equal;
|
11622
|
+
if (size1 == 0 || size2 == 0) return kUpb_UnknownCompareResult_NotEqual;
|
11623
|
+
if (memcmp(buf1, buf2, size1) == 0) return kUpb_UnknownCompareResult_Equal;
|
11624
|
+
|
11625
|
+
upb_UnknownField_Context ctx = {
|
11626
|
+
.arena = upb_Arena_New(),
|
11627
|
+
.depth = max_depth,
|
11628
|
+
.tmp = NULL,
|
11629
|
+
.tmp_size = 0,
|
11630
|
+
.status = kUpb_UnknownCompareResult_Equal,
|
11631
|
+
};
|
11632
|
+
|
11633
|
+
if (!ctx.arena) return kUpb_UnknownCompareResult_OutOfMemory;
|
11634
|
+
|
11635
|
+
return upb_UnknownField_Compare(&ctx, buf1, size1, buf2, size2);
|
11636
|
+
}
|
11637
|
+
|
11638
|
+
|
10606
11639
|
#include <string.h>
|
10607
11640
|
|
10608
11641
|
|
10609
11642
|
// Must be last.
|
10610
11643
|
|
10611
|
-
const
|
11644
|
+
const upb_Extension* UPB_PRIVATE(_upb_Message_Getext)(
|
10612
11645
|
const struct upb_Message* msg, const upb_MiniTableExtension* e) {
|
10613
11646
|
size_t n;
|
10614
|
-
const
|
11647
|
+
const upb_Extension* ext = UPB_PRIVATE(_upb_Message_Getexts)(msg, &n);
|
10615
11648
|
|
10616
11649
|
// For now we use linear search exclusively to find extensions.
|
10617
11650
|
// If this becomes an issue due to messages with lots of extensions,
|
@@ -10625,11 +11658,11 @@ const struct upb_Extension* UPB_PRIVATE(_upb_Message_Getext)(
|
|
10625
11658
|
return NULL;
|
10626
11659
|
}
|
10627
11660
|
|
10628
|
-
const
|
11661
|
+
const upb_Extension* UPB_PRIVATE(_upb_Message_Getexts)(
|
10629
11662
|
const struct upb_Message* msg, size_t* count) {
|
10630
|
-
upb_Message_Internal* in = msg
|
11663
|
+
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
10631
11664
|
if (in) {
|
10632
|
-
*count = (in->size - in->ext_begin) / sizeof(
|
11665
|
+
*count = (in->size - in->ext_begin) / sizeof(upb_Extension);
|
10633
11666
|
return UPB_PTR_AT(in, in->ext_begin, void);
|
10634
11667
|
} else {
|
10635
11668
|
*count = 0;
|
@@ -10637,17 +11670,17 @@ const struct upb_Extension* UPB_PRIVATE(_upb_Message_Getexts)(
|
|
10637
11670
|
}
|
10638
11671
|
}
|
10639
11672
|
|
10640
|
-
|
11673
|
+
upb_Extension* UPB_PRIVATE(_upb_Message_GetOrCreateExtension)(
|
10641
11674
|
struct upb_Message* msg, const upb_MiniTableExtension* e, upb_Arena* a) {
|
10642
|
-
|
10643
|
-
|
11675
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
11676
|
+
upb_Extension* ext = (upb_Extension*)UPB_PRIVATE(_upb_Message_Getext)(msg, e);
|
10644
11677
|
if (ext) return ext;
|
10645
|
-
if (!UPB_PRIVATE(_upb_Message_Realloc)(msg, sizeof(
|
11678
|
+
if (!UPB_PRIVATE(_upb_Message_Realloc)(msg, sizeof(upb_Extension), a))
|
10646
11679
|
return NULL;
|
10647
|
-
upb_Message_Internal* in = msg
|
10648
|
-
in->ext_begin -= sizeof(
|
11680
|
+
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
11681
|
+
in->ext_begin -= sizeof(upb_Extension);
|
10649
11682
|
ext = UPB_PTR_AT(in, in->ext_begin, void);
|
10650
|
-
memset(ext, 0, sizeof(
|
11683
|
+
memset(ext, 0, sizeof(upb_Extension));
|
10651
11684
|
ext->ext = e;
|
10652
11685
|
return ext;
|
10653
11686
|
}
|
@@ -10665,9 +11698,10 @@ const double kUpb_NaN = NAN;
|
|
10665
11698
|
|
10666
11699
|
bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need,
|
10667
11700
|
upb_Arena* a) {
|
11701
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
10668
11702
|
const size_t overhead = sizeof(upb_Message_Internal);
|
10669
11703
|
|
10670
|
-
upb_Message_Internal* in = msg
|
11704
|
+
upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg);
|
10671
11705
|
if (!in) {
|
10672
11706
|
// No internal data, allocate from scratch.
|
10673
11707
|
size_t size = UPB_MAX(128, upb_Log2CeilingSize(need + overhead));
|
@@ -10677,7 +11711,7 @@ bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need,
|
|
10677
11711
|
in->size = size;
|
10678
11712
|
in->unknown_end = overhead;
|
10679
11713
|
in->ext_begin = size;
|
10680
|
-
msg
|
11714
|
+
UPB_PRIVATE(_upb_Message_SetInternal)(msg, in);
|
10681
11715
|
} else if (in->ext_begin - in->unknown_end < need) {
|
10682
11716
|
// Internal data is too small, reallocate.
|
10683
11717
|
size_t new_size = upb_Log2CeilingSize(in->size + need);
|
@@ -10693,13 +11727,88 @@ bool UPB_PRIVATE(_upb_Message_Realloc)(struct upb_Message* msg, size_t need,
|
|
10693
11727
|
}
|
10694
11728
|
in->ext_begin = new_ext_begin;
|
10695
11729
|
in->size = new_size;
|
10696
|
-
msg
|
11730
|
+
UPB_PRIVATE(_upb_Message_SetInternal)(msg, in);
|
10697
11731
|
}
|
10698
11732
|
|
10699
11733
|
UPB_ASSERT(in->ext_begin - in->unknown_end >= need);
|
10700
11734
|
return true;
|
10701
11735
|
}
|
10702
11736
|
|
11737
|
+
#if UPB_TRACING_ENABLED
|
11738
|
+
static void (*_message_trace_handler)(const upb_MiniTable*, const upb_Arena*);
|
11739
|
+
|
11740
|
+
void upb_Message_LogNewMessage(const upb_MiniTable* m, const upb_Arena* arena) {
|
11741
|
+
if (_message_trace_handler) {
|
11742
|
+
_message_trace_handler(m, arena);
|
11743
|
+
}
|
11744
|
+
}
|
11745
|
+
|
11746
|
+
void upb_Message_SetNewMessageTraceHandler(void (*handler)(const upb_MiniTable*,
|
11747
|
+
const upb_Arena*)) {
|
11748
|
+
_message_trace_handler = handler;
|
11749
|
+
}
|
11750
|
+
#endif // UPB_TRACING_ENABLED
|
11751
|
+
|
11752
|
+
|
11753
|
+
#include <stddef.h>
|
11754
|
+
|
11755
|
+
|
11756
|
+
// Must be last.
|
11757
|
+
|
11758
|
+
bool UPB_PRIVATE(_upb_Message_NextBaseField)(const upb_Message* msg,
|
11759
|
+
const upb_MiniTable* m,
|
11760
|
+
const upb_MiniTableField** out_f,
|
11761
|
+
upb_MessageValue* out_v,
|
11762
|
+
size_t* iter) {
|
11763
|
+
const size_t count = upb_MiniTable_FieldCount(m);
|
11764
|
+
size_t i = *iter;
|
11765
|
+
|
11766
|
+
while (++i < count) {
|
11767
|
+
const upb_MiniTableField* f = upb_MiniTable_GetFieldByIndex(m, i);
|
11768
|
+
const void* src = UPB_PRIVATE(_upb_Message_DataPtr)(msg, f);
|
11769
|
+
|
11770
|
+
upb_MessageValue val;
|
11771
|
+
UPB_PRIVATE(_upb_MiniTableField_DataCopy)(f, &val, src);
|
11772
|
+
|
11773
|
+
// Skip field if unset or empty.
|
11774
|
+
if (upb_MiniTableField_HasPresence(f)) {
|
11775
|
+
if (!upb_Message_HasBaseField(msg, f)) continue;
|
11776
|
+
} else {
|
11777
|
+
if (UPB_PRIVATE(_upb_MiniTableField_DataIsZero)(f, src)) continue;
|
11778
|
+
|
11779
|
+
if (upb_MiniTableField_IsArray(f)) {
|
11780
|
+
if (upb_Array_Size(val.array_val) == 0) continue;
|
11781
|
+
} else if (upb_MiniTableField_IsMap(f)) {
|
11782
|
+
if (upb_Map_Size(val.map_val) == 0) continue;
|
11783
|
+
}
|
11784
|
+
}
|
11785
|
+
|
11786
|
+
*out_f = f;
|
11787
|
+
*out_v = val;
|
11788
|
+
*iter = i;
|
11789
|
+
return true;
|
11790
|
+
}
|
11791
|
+
|
11792
|
+
return false;
|
11793
|
+
}
|
11794
|
+
|
11795
|
+
bool UPB_PRIVATE(_upb_Message_NextExtension)(
|
11796
|
+
const upb_Message* msg, const upb_MiniTable* m,
|
11797
|
+
const upb_MiniTableExtension** out_e, upb_MessageValue* out_v,
|
11798
|
+
size_t* iter) {
|
11799
|
+
size_t count;
|
11800
|
+
const upb_Extension* exts = UPB_PRIVATE(_upb_Message_Getexts)(msg, &count);
|
11801
|
+
size_t i = *iter;
|
11802
|
+
|
11803
|
+
if (++i < count) {
|
11804
|
+
*out_e = exts[i].ext;
|
11805
|
+
*out_v = exts[i].data;
|
11806
|
+
*iter = i;
|
11807
|
+
return true;
|
11808
|
+
}
|
11809
|
+
|
11810
|
+
return false;
|
11811
|
+
}
|
10703
11812
|
|
10704
11813
|
const char _kUpb_ToBase92[] = {
|
10705
11814
|
' ', '!', '#', '$', '%', '&', '(', ')', '*', '+', ',', '-', '.', '/',
|
@@ -11036,7 +12145,12 @@ char* upb_MtDataEncoder_EndEnum(upb_MtDataEncoder* e, char* ptr) {
|
|
11036
12145
|
|
11037
12146
|
// Must be last.
|
11038
12147
|
|
11039
|
-
// A MiniTable for an empty message, used for unlinked sub-messages
|
12148
|
+
// A MiniTable for an empty message, used for unlinked sub-messages that are
|
12149
|
+
// built via MiniDescriptors. Messages that use this MiniTable may possibly
|
12150
|
+
// be linked later, in which case this MiniTable will be replaced with a real
|
12151
|
+
// one. This pattern is known as "dynamic tree shaking", and it introduces
|
12152
|
+
// complication because sub-messages may either be the "empty" type or the
|
12153
|
+
// "real" type. A tagged bit indicates the difference.
|
11040
12154
|
const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_Empty) = {
|
11041
12155
|
.UPB_PRIVATE(subs) = NULL,
|
11042
12156
|
.UPB_PRIVATE(fields) = NULL,
|
@@ -11048,6 +12162,21 @@ const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_Empty) = {
|
|
11048
12162
|
.UPB_PRIVATE(required_count) = 0,
|
11049
12163
|
};
|
11050
12164
|
|
12165
|
+
// A MiniTable for a statically tree shaken message. Messages that use this
|
12166
|
+
// MiniTable are guaranteed to remain unlinked; unlike the empty message, this
|
12167
|
+
// MiniTable is never replaced, which greatly simplifies everything, because the
|
12168
|
+
// type of a sub-message is always known, without consulting a tagged bit.
|
12169
|
+
const struct upb_MiniTable UPB_PRIVATE(_kUpb_MiniTable_StaticallyTreeShaken) = {
|
12170
|
+
.UPB_PRIVATE(subs) = NULL,
|
12171
|
+
.UPB_PRIVATE(fields) = NULL,
|
12172
|
+
.UPB_PRIVATE(size) = sizeof(struct upb_Message),
|
12173
|
+
.UPB_PRIVATE(field_count) = 0,
|
12174
|
+
.UPB_PRIVATE(ext) = kUpb_ExtMode_NonExtendable,
|
12175
|
+
.UPB_PRIVATE(dense_below) = 0,
|
12176
|
+
.UPB_PRIVATE(table_mask) = -1,
|
12177
|
+
.UPB_PRIVATE(required_count) = 0,
|
12178
|
+
};
|
12179
|
+
|
11051
12180
|
|
11052
12181
|
|
11053
12182
|
// Must be last.
|
@@ -11729,7 +12858,11 @@ const upb_EnumValueDef* upb_EnumDef_Value(const upb_EnumDef* e, int i) {
|
|
11729
12858
|
}
|
11730
12859
|
|
11731
12860
|
bool upb_EnumDef_IsClosed(const upb_EnumDef* e) {
|
11732
|
-
if (
|
12861
|
+
if (UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN) return false;
|
12862
|
+
return upb_EnumDef_IsSpecifiedAsClosed(e);
|
12863
|
+
}
|
12864
|
+
|
12865
|
+
bool upb_EnumDef_IsSpecifiedAsClosed(const upb_EnumDef* e) {
|
11733
12866
|
return UPB_DESC(FeatureSet_enum_type)(e->resolved_features) ==
|
11734
12867
|
UPB_DESC(FeatureSet_CLOSED);
|
11735
12868
|
}
|
@@ -12035,15 +13168,10 @@ static void create_enumvaldef(upb_DefBuilder* ctx, const char* prefix,
|
|
12035
13168
|
static void _upb_EnumValueDef_CheckZeroValue(upb_DefBuilder* ctx,
|
12036
13169
|
const upb_EnumDef* e,
|
12037
13170
|
const upb_EnumValueDef* v, int n) {
|
12038
|
-
|
12039
|
-
|
12040
|
-
// When the special UPB_TREAT_PROTO2_ENUMS_LIKE_PROTO3 is enabled, we have to
|
12041
|
-
// exempt proto2 enums from this check, even when we are treating them as
|
13171
|
+
// When the special UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN is enabled, we have to
|
13172
|
+
// exempt closed enums from this check, even when we are treating them as
|
12042
13173
|
// open.
|
12043
|
-
if (
|
12044
|
-
upb_FileDef_Syntax(upb_EnumDef_File(e)) == kUpb_Syntax_Proto2) {
|
12045
|
-
return;
|
12046
|
-
}
|
13174
|
+
if (upb_EnumDef_IsSpecifiedAsClosed(e) || n == 0 || v[0].number == 0) return;
|
12047
13175
|
|
12048
13176
|
_upb_DefBuilder_Errf(ctx, "for open enums, the first value must be zero (%s)",
|
12049
13177
|
upb_EnumDef_FullName(e));
|
@@ -12225,27 +13353,16 @@ upb_CType upb_FieldDef_CType(const upb_FieldDef* f) {
|
|
12225
13353
|
return upb_FieldType_CType(f->type_);
|
12226
13354
|
}
|
12227
13355
|
|
12228
|
-
upb_FieldType upb_FieldDef_Type(const upb_FieldDef* f) {
|
12229
|
-
// TODO: remove once we can deprecate kUpb_FieldType_Group.
|
12230
|
-
if (f->type_ == kUpb_FieldType_Message &&
|
12231
|
-
UPB_DESC(FeatureSet_message_encoding)(f->resolved_features) ==
|
12232
|
-
UPB_DESC(FeatureSet_DELIMITED)) {
|
12233
|
-
return kUpb_FieldType_Group;
|
12234
|
-
}
|
12235
|
-
return f->type_;
|
12236
|
-
}
|
13356
|
+
upb_FieldType upb_FieldDef_Type(const upb_FieldDef* f) { return f->type_; }
|
12237
13357
|
|
12238
13358
|
uint32_t upb_FieldDef_Index(const upb_FieldDef* f) { return f->index_; }
|
12239
13359
|
|
12240
|
-
|
12241
|
-
|
12242
|
-
if (UPB_DESC(FeatureSet_field_presence)(f->resolved_features) ==
|
12243
|
-
UPB_DESC(FeatureSet_LEGACY_REQUIRED)) {
|
12244
|
-
return kUpb_Label_Required;
|
12245
|
-
}
|
12246
|
-
return f->label_;
|
13360
|
+
uint32_t upb_FieldDef_LayoutIndex(const upb_FieldDef* f) {
|
13361
|
+
return f->layout_index;
|
12247
13362
|
}
|
12248
13363
|
|
13364
|
+
upb_Label upb_FieldDef_Label(const upb_FieldDef* f) { return f->label_; }
|
13365
|
+
|
12249
13366
|
uint32_t upb_FieldDef_Number(const upb_FieldDef* f) { return f->number_; }
|
12250
13367
|
|
12251
13368
|
bool upb_FieldDef_IsExtension(const upb_FieldDef* f) { return f->is_extension; }
|
@@ -12334,11 +13451,11 @@ upb_MessageValue upb_FieldDef_Default(const upb_FieldDef* f) {
|
|
12334
13451
|
}
|
12335
13452
|
|
12336
13453
|
const upb_MessageDef* upb_FieldDef_MessageSubDef(const upb_FieldDef* f) {
|
12337
|
-
return
|
13454
|
+
return upb_FieldDef_IsSubMessage(f) ? f->sub.msgdef : NULL;
|
12338
13455
|
}
|
12339
13456
|
|
12340
13457
|
const upb_EnumDef* upb_FieldDef_EnumSubDef(const upb_FieldDef* f) {
|
12341
|
-
return
|
13458
|
+
return upb_FieldDef_IsEnum(f) ? f->sub.enumdef : NULL;
|
12342
13459
|
}
|
12343
13460
|
|
12344
13461
|
const upb_MiniTableField* upb_FieldDef_MiniTable(const upb_FieldDef* f) {
|
@@ -12376,6 +13493,39 @@ bool _upb_FieldDef_ValidateUtf8(const upb_FieldDef* f) {
|
|
12376
13493
|
UPB_DESC(FeatureSet_VERIFY);
|
12377
13494
|
}
|
12378
13495
|
|
13496
|
+
bool _upb_FieldDef_IsGroupLike(const upb_FieldDef* f) {
|
13497
|
+
// Groups are always tag-delimited.
|
13498
|
+
if (f->type_ != kUpb_FieldType_Group) {
|
13499
|
+
return false;
|
13500
|
+
}
|
13501
|
+
|
13502
|
+
const upb_MessageDef* msg = upb_FieldDef_MessageSubDef(f);
|
13503
|
+
|
13504
|
+
// Group fields always are always the lowercase type name.
|
13505
|
+
const char* mname = upb_MessageDef_Name(msg);
|
13506
|
+
const char* fname = upb_FieldDef_Name(f);
|
13507
|
+
size_t name_size = strlen(fname);
|
13508
|
+
if (name_size != strlen(mname)) return false;
|
13509
|
+
for (size_t i = 0; i < name_size; ++i) {
|
13510
|
+
if ((mname[i] | 0x20) != fname[i]) {
|
13511
|
+
// Case-insensitive ascii comparison.
|
13512
|
+
return false;
|
13513
|
+
}
|
13514
|
+
}
|
13515
|
+
|
13516
|
+
if (upb_MessageDef_File(msg) != upb_FieldDef_File(f)) {
|
13517
|
+
return false;
|
13518
|
+
}
|
13519
|
+
|
13520
|
+
// Group messages are always defined in the same scope as the field. File
|
13521
|
+
// level extensions will compare NULL == NULL here, which is why the file
|
13522
|
+
// comparison above is necessary to ensure both come from the same file.
|
13523
|
+
return upb_FieldDef_IsExtension(f) ? upb_FieldDef_ExtensionScope(f) ==
|
13524
|
+
upb_MessageDef_ContainingType(msg)
|
13525
|
+
: upb_FieldDef_ContainingType(f) ==
|
13526
|
+
upb_MessageDef_ContainingType(msg);
|
13527
|
+
}
|
13528
|
+
|
12379
13529
|
uint64_t _upb_FieldDef_Modifiers(const upb_FieldDef* f) {
|
12380
13530
|
uint64_t out = upb_FieldDef_IsPacked(f) ? kUpb_FieldModifier_IsPacked : 0;
|
12381
13531
|
|
@@ -12402,8 +13552,11 @@ bool upb_FieldDef_HasDefault(const upb_FieldDef* f) { return f->has_default; }
|
|
12402
13552
|
bool upb_FieldDef_HasPresence(const upb_FieldDef* f) { return f->has_presence; }
|
12403
13553
|
|
12404
13554
|
bool upb_FieldDef_HasSubDef(const upb_FieldDef* f) {
|
12405
|
-
return upb_FieldDef_IsSubMessage(f) ||
|
12406
|
-
|
13555
|
+
return upb_FieldDef_IsSubMessage(f) || upb_FieldDef_IsEnum(f);
|
13556
|
+
}
|
13557
|
+
|
13558
|
+
bool upb_FieldDef_IsEnum(const upb_FieldDef* f) {
|
13559
|
+
return upb_FieldDef_CType(f) == kUpb_CType_Enum;
|
12407
13560
|
}
|
12408
13561
|
|
12409
13562
|
bool upb_FieldDef_IsMap(const upb_FieldDef* f) {
|
@@ -12707,7 +13860,6 @@ static void _upb_FieldDef_Create(upb_DefBuilder* ctx, const char* prefix,
|
|
12707
13860
|
|
12708
13861
|
const upb_StringView name = UPB_DESC(FieldDescriptorProto_name)(field_proto);
|
12709
13862
|
f->full_name = _upb_DefBuilder_MakeFullName(ctx, prefix, name);
|
12710
|
-
f->label_ = (int)UPB_DESC(FieldDescriptorProto_label)(field_proto);
|
12711
13863
|
f->number_ = UPB_DESC(FieldDescriptorProto_number)(field_proto);
|
12712
13864
|
f->is_proto3_optional =
|
12713
13865
|
UPB_DESC(FieldDescriptorProto_proto3_optional)(field_proto);
|
@@ -12739,7 +13891,7 @@ static void _upb_FieldDef_Create(upb_DefBuilder* ctx, const char* prefix,
|
|
12739
13891
|
f->full_name);
|
12740
13892
|
}
|
12741
13893
|
|
12742
|
-
if (oneof_index >= upb_MessageDef_OneofCount(m)) {
|
13894
|
+
if (oneof_index < 0 || oneof_index >= upb_MessageDef_OneofCount(m)) {
|
12743
13895
|
_upb_DefBuilder_Errf(ctx, "oneof_index out of range (%s)", f->full_name);
|
12744
13896
|
}
|
12745
13897
|
|
@@ -12753,6 +13905,14 @@ static void _upb_FieldDef_Create(upb_DefBuilder* ctx, const char* prefix,
|
|
12753
13905
|
f->resolved_features = _upb_DefBuilder_DoResolveFeatures(
|
12754
13906
|
ctx, parent_features, unresolved_features, implicit);
|
12755
13907
|
|
13908
|
+
f->label_ = (int)UPB_DESC(FieldDescriptorProto_label)(field_proto);
|
13909
|
+
if (f->label_ == kUpb_Label_Optional &&
|
13910
|
+
// TODO: remove once we can deprecate kUpb_Label_Required.
|
13911
|
+
UPB_DESC(FeatureSet_field_presence)(f->resolved_features) ==
|
13912
|
+
UPB_DESC(FeatureSet_LEGACY_REQUIRED)) {
|
13913
|
+
f->label_ = kUpb_Label_Required;
|
13914
|
+
}
|
13915
|
+
|
12756
13916
|
if (!UPB_DESC(FieldDescriptorProto_has_name)(field_proto)) {
|
12757
13917
|
_upb_DefBuilder_Errf(ctx, "field has no name");
|
12758
13918
|
}
|
@@ -12792,7 +13952,7 @@ static void _upb_FieldDef_Create(upb_DefBuilder* ctx, const char* prefix,
|
|
12792
13952
|
}
|
12793
13953
|
}
|
12794
13954
|
|
12795
|
-
if (!has_type && has_type_name) {
|
13955
|
+
if ((!has_type && has_type_name) || f->type_ == kUpb_FieldType_Message) {
|
12796
13956
|
f->type_ =
|
12797
13957
|
UPB_FIELD_TYPE_UNSPECIFIED; // We'll assign this in resolve_subdef()
|
12798
13958
|
} else {
|
@@ -12821,10 +13981,11 @@ static void _upb_FieldDef_Create(upb_DefBuilder* ctx, const char* prefix,
|
|
12821
13981
|
|
12822
13982
|
f->has_presence =
|
12823
13983
|
(!upb_FieldDef_IsRepeated(f)) &&
|
12824
|
-
(f->
|
12825
|
-
|
12826
|
-
|
12827
|
-
|
13984
|
+
(f->is_extension ||
|
13985
|
+
(f->type_ == kUpb_FieldType_Message ||
|
13986
|
+
f->type_ == kUpb_FieldType_Group || upb_FieldDef_ContainingOneof(f) ||
|
13987
|
+
UPB_DESC(FeatureSet_field_presence)(f->resolved_features) !=
|
13988
|
+
UPB_DESC(FeatureSet_IMPLICIT)));
|
12828
13989
|
}
|
12829
13990
|
|
12830
13991
|
static void _upb_FieldDef_CreateExt(upb_DefBuilder* ctx, const char* prefix,
|
@@ -12941,8 +14102,15 @@ static void resolve_subdef(upb_DefBuilder* ctx, const char* prefix,
|
|
12941
14102
|
break;
|
12942
14103
|
case UPB_DEFTYPE_MSG:
|
12943
14104
|
f->sub.msgdef = def;
|
12944
|
-
f->type_ = kUpb_FieldType_Message;
|
12945
|
-
|
14105
|
+
f->type_ = kUpb_FieldType_Message;
|
14106
|
+
// TODO: remove once we can deprecate
|
14107
|
+
// kUpb_FieldType_Group.
|
14108
|
+
if (UPB_DESC(FeatureSet_message_encoding)(f->resolved_features) ==
|
14109
|
+
UPB_DESC(FeatureSet_DELIMITED) &&
|
14110
|
+
!upb_MessageDef_IsMapEntry(def) &&
|
14111
|
+
!(f->msgdef && upb_MessageDef_IsMapEntry(f->msgdef))) {
|
14112
|
+
f->type_ = kUpb_FieldType_Group;
|
14113
|
+
}
|
12946
14114
|
f->has_presence = !upb_FieldDef_IsRepeated(f);
|
12947
14115
|
break;
|
12948
14116
|
default:
|
@@ -13260,6 +14428,17 @@ const upb_MiniTableExtension* _upb_FileDef_ExtensionMiniTable(
|
|
13260
14428
|
return f->ext_layouts[i];
|
13261
14429
|
}
|
13262
14430
|
|
14431
|
+
// Note: Import cycles are not allowed so this will terminate.
|
14432
|
+
bool upb_FileDef_Resolves(const upb_FileDef* f, const char* path) {
|
14433
|
+
if (!strcmp(f->name, path)) return true;
|
14434
|
+
|
14435
|
+
for (int i = 0; i < upb_FileDef_PublicDependencyCount(f); i++) {
|
14436
|
+
const upb_FileDef* dep = upb_FileDef_PublicDependency(f, i);
|
14437
|
+
if (upb_FileDef_Resolves(dep, path)) return true;
|
14438
|
+
}
|
14439
|
+
return false;
|
14440
|
+
}
|
14441
|
+
|
13263
14442
|
static char* strviewdup(upb_DefBuilder* ctx, upb_StringView view) {
|
13264
14443
|
char* ret = upb_strdup2(view.data, view.size, _upb_DefBuilder_Arena(ctx));
|
13265
14444
|
if (!ret) _upb_DefBuilder_OomErr(ctx);
|
@@ -13311,20 +14490,35 @@ const UPB_DESC(FeatureSet*)
|
|
13311
14490
|
size_t n;
|
13312
14491
|
const UPB_DESC(FeatureSetDefaults_FeatureSetEditionDefault)* const* d =
|
13313
14492
|
UPB_DESC(FeatureSetDefaults_defaults)(defaults, &n);
|
13314
|
-
const UPB_DESC(
|
14493
|
+
const UPB_DESC(FeatureSetDefaults_FeatureSetEditionDefault)* result = NULL;
|
13315
14494
|
for (size_t i = 0; i < n; i++) {
|
13316
14495
|
if (UPB_DESC(FeatureSetDefaults_FeatureSetEditionDefault_edition)(d[i]) >
|
13317
14496
|
edition) {
|
13318
14497
|
break;
|
13319
14498
|
}
|
13320
|
-
|
14499
|
+
result = d[i];
|
13321
14500
|
}
|
13322
|
-
if (
|
14501
|
+
if (result == NULL) {
|
13323
14502
|
_upb_DefBuilder_Errf(ctx, "No valid default found for edition %s",
|
13324
14503
|
upb_FileDef_EditionName(edition));
|
13325
14504
|
return NULL;
|
13326
14505
|
}
|
13327
|
-
|
14506
|
+
|
14507
|
+
// Merge the fixed and overridable features to get the edition's default
|
14508
|
+
// feature set.
|
14509
|
+
const UPB_DESC(FeatureSet)* fixed = UPB_DESC(
|
14510
|
+
FeatureSetDefaults_FeatureSetEditionDefault_fixed_features)(result);
|
14511
|
+
const UPB_DESC(FeatureSet)* overridable = UPB_DESC(
|
14512
|
+
FeatureSetDefaults_FeatureSetEditionDefault_overridable_features)(result);
|
14513
|
+
if (!fixed && !overridable) {
|
14514
|
+
_upb_DefBuilder_Errf(ctx, "No valid default found for edition %s",
|
14515
|
+
upb_FileDef_EditionName(edition));
|
14516
|
+
return NULL;
|
14517
|
+
} else if (!fixed) {
|
14518
|
+
return overridable;
|
14519
|
+
}
|
14520
|
+
return _upb_DefBuilder_DoResolveFeatures(ctx, fixed, overridable,
|
14521
|
+
/*is_implicit=*/true);
|
13328
14522
|
}
|
13329
14523
|
|
13330
14524
|
// Allocate and initialize one file def, and add it to the context object.
|
@@ -13964,8 +15158,8 @@ bool upb_Message_HasFieldByDef(const upb_Message* msg, const upb_FieldDef* f) {
|
|
13964
15158
|
}
|
13965
15159
|
}
|
13966
15160
|
|
13967
|
-
const upb_FieldDef*
|
13968
|
-
|
15161
|
+
const upb_FieldDef* upb_Message_WhichOneofByDef(const upb_Message* msg,
|
15162
|
+
const upb_OneofDef* o) {
|
13969
15163
|
const upb_FieldDef* f = upb_OneofDef_Field(o, 0);
|
13970
15164
|
if (upb_OneofDef_IsSynthetic(o)) {
|
13971
15165
|
UPB_ASSERT(upb_OneofDef_FieldCount(o) == 1);
|
@@ -13988,6 +15182,7 @@ upb_MessageValue upb_Message_GetFieldByDef(const upb_Message* msg,
|
|
13988
15182
|
upb_MutableMessageValue upb_Message_Mutable(upb_Message* msg,
|
13989
15183
|
const upb_FieldDef* f,
|
13990
15184
|
upb_Arena* a) {
|
15185
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
13991
15186
|
UPB_ASSERT(upb_FieldDef_IsSubMessage(f) || upb_FieldDef_IsRepeated(f));
|
13992
15187
|
if (upb_FieldDef_HasPresence(f) && !upb_Message_HasFieldByDef(msg, f)) {
|
13993
15188
|
// We need to skip the upb_Message_GetFieldByDef() call in this case.
|
@@ -14026,10 +15221,20 @@ make:
|
|
14026
15221
|
|
14027
15222
|
bool upb_Message_SetFieldByDef(upb_Message* msg, const upb_FieldDef* f,
|
14028
15223
|
upb_MessageValue val, upb_Arena* a) {
|
14029
|
-
|
15224
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
15225
|
+
const upb_MiniTableField* m_f = upb_FieldDef_MiniTable(f);
|
15226
|
+
|
15227
|
+
if (upb_MiniTableField_IsExtension(m_f)) {
|
15228
|
+
return upb_Message_SetExtension(msg, (const upb_MiniTableExtension*)m_f,
|
15229
|
+
&val, a);
|
15230
|
+
} else {
|
15231
|
+
upb_Message_SetBaseField(msg, m_f, &val);
|
15232
|
+
return true;
|
15233
|
+
}
|
14030
15234
|
}
|
14031
15235
|
|
14032
15236
|
void upb_Message_ClearFieldByDef(upb_Message* msg, const upb_FieldDef* f) {
|
15237
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
14033
15238
|
const upb_MiniTableField* m_f = upb_FieldDef_MiniTable(f);
|
14034
15239
|
|
14035
15240
|
if (upb_MiniTableField_IsExtension(m_f)) {
|
@@ -14040,25 +15245,27 @@ void upb_Message_ClearFieldByDef(upb_Message* msg, const upb_FieldDef* f) {
|
|
14040
15245
|
}
|
14041
15246
|
|
14042
15247
|
void upb_Message_ClearByDef(upb_Message* msg, const upb_MessageDef* m) {
|
15248
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
14043
15249
|
upb_Message_Clear(msg, upb_MessageDef_MiniTable(m));
|
14044
15250
|
}
|
14045
15251
|
|
14046
15252
|
bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
|
14047
15253
|
const upb_DefPool* ext_pool, const upb_FieldDef** out_f,
|
14048
15254
|
upb_MessageValue* out_val, size_t* iter) {
|
15255
|
+
const upb_MiniTable* mt = upb_MessageDef_MiniTable(m);
|
14049
15256
|
size_t i = *iter;
|
14050
|
-
size_t n =
|
15257
|
+
size_t n = upb_MiniTable_FieldCount(mt);
|
15258
|
+
const upb_MessageValue zero = {0};
|
14051
15259
|
UPB_UNUSED(ext_pool);
|
14052
15260
|
|
14053
15261
|
// Iterate over normal fields, returning the first one that is set.
|
14054
15262
|
while (++i < n) {
|
14055
|
-
const
|
14056
|
-
|
14057
|
-
upb_MessageValue val = upb_Message_GetFieldByDef(msg, f);
|
15263
|
+
const upb_MiniTableField* field = upb_MiniTable_GetFieldByIndex(mt, i);
|
15264
|
+
upb_MessageValue val = upb_Message_GetField(msg, field, zero);
|
14058
15265
|
|
14059
15266
|
// Skip field if unset or empty.
|
14060
15267
|
if (upb_MiniTableField_HasPresence(field)) {
|
14061
|
-
if (!
|
15268
|
+
if (!upb_Message_HasBaseField(msg, field)) continue;
|
14062
15269
|
} else {
|
14063
15270
|
switch (UPB_PRIVATE(_upb_MiniTableField_Mode)(field)) {
|
14064
15271
|
case kUpb_FieldMode_Map:
|
@@ -14075,7 +15282,8 @@ bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
|
|
14075
15282
|
}
|
14076
15283
|
|
14077
15284
|
*out_val = val;
|
14078
|
-
*out_f =
|
15285
|
+
*out_f =
|
15286
|
+
upb_MessageDef_FindFieldByNumber(m, upb_MiniTableField_Number(field));
|
14079
15287
|
*iter = i;
|
14080
15288
|
return true;
|
14081
15289
|
}
|
@@ -14099,6 +15307,7 @@ bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
|
|
14099
15307
|
|
14100
15308
|
bool _upb_Message_DiscardUnknown(upb_Message* msg, const upb_MessageDef* m,
|
14101
15309
|
int depth) {
|
15310
|
+
UPB_ASSERT(!upb_Message_IsFrozen(msg));
|
14102
15311
|
size_t iter = kUpb_Message_Begin;
|
14103
15312
|
const upb_FieldDef* f;
|
14104
15313
|
upb_MessageValue val;
|
@@ -14539,7 +15748,10 @@ void _upb_MessageDef_InsertField(upb_DefBuilder* ctx, upb_MessageDef* m,
|
|
14539
15748
|
_upb_MessageDef_Insert(m, shortname, shortnamelen, field_v, ctx->arena);
|
14540
15749
|
if (!ok) _upb_DefBuilder_OomErr(ctx);
|
14541
15750
|
|
14542
|
-
|
15751
|
+
bool skip_json_conflicts =
|
15752
|
+
UPB_DESC(MessageOptions_deprecated_legacy_json_field_conflicts)(
|
15753
|
+
upb_MessageDef_Options(m));
|
15754
|
+
if (!skip_json_conflicts && strcmp(shortname, json_name) != 0 &&
|
14543
15755
|
UPB_DESC(FeatureSet_json_format)(m->resolved_features) ==
|
14544
15756
|
UPB_DESC(FeatureSet_ALLOW) &&
|
14545
15757
|
upb_strtable_lookup(&m->ntof, json_name, &v)) {
|
@@ -14549,14 +15761,16 @@ void _upb_MessageDef_InsertField(upb_DefBuilder* ctx, upb_MessageDef* m,
|
|
14549
15761
|
}
|
14550
15762
|
|
14551
15763
|
if (upb_strtable_lookup(&m->jtof, json_name, &v)) {
|
14552
|
-
|
15764
|
+
if (!skip_json_conflicts) {
|
15765
|
+
_upb_DefBuilder_Errf(ctx, "duplicate json_name (%s)", json_name);
|
15766
|
+
}
|
15767
|
+
} else {
|
15768
|
+
const size_t json_size = strlen(json_name);
|
15769
|
+
ok = upb_strtable_insert(&m->jtof, json_name, json_size,
|
15770
|
+
upb_value_constptr(f), ctx->arena);
|
15771
|
+
if (!ok) _upb_DefBuilder_OomErr(ctx);
|
14553
15772
|
}
|
14554
15773
|
|
14555
|
-
const size_t json_size = strlen(json_name);
|
14556
|
-
ok = upb_strtable_insert(&m->jtof, json_name, json_size,
|
14557
|
-
upb_value_constptr(f), ctx->arena);
|
14558
|
-
if (!ok) _upb_DefBuilder_OomErr(ctx);
|
14559
|
-
|
14560
15774
|
if (upb_inttable_lookup(&m->itof, field_number, NULL)) {
|
14561
15775
|
_upb_DefBuilder_Errf(ctx, "duplicate field number (%u)", field_number);
|
14562
15776
|
}
|
@@ -14570,7 +15784,7 @@ void _upb_MessageDef_CreateMiniTable(upb_DefBuilder* ctx, upb_MessageDef* m) {
|
|
14570
15784
|
m->layout = _upb_MessageDef_MakeMiniTable(ctx, m);
|
14571
15785
|
} else {
|
14572
15786
|
m->layout = upb_MiniTableFile_Message(ctx->layout, ctx->msg_count++);
|
14573
|
-
UPB_ASSERT(m->field_count == m->layout
|
15787
|
+
UPB_ASSERT(m->field_count == upb_MiniTable_FieldCount(m->layout));
|
14574
15788
|
|
14575
15789
|
// We don't need the result of this call, but it will assign layout_index
|
14576
15790
|
// for all the fields in O(n lg n) time.
|
@@ -14628,7 +15842,7 @@ void _upb_MessageDef_LinkMiniTable(upb_DefBuilder* ctx,
|
|
14628
15842
|
for (int i = 0; i < m->field_count; i++) {
|
14629
15843
|
const upb_FieldDef* f = upb_MessageDef_Field(m, i);
|
14630
15844
|
const int layout_index = _upb_FieldDef_LayoutIndex(f);
|
14631
|
-
UPB_ASSERT(layout_index < m->layout
|
15845
|
+
UPB_ASSERT(layout_index < upb_MiniTable_FieldCount(m->layout));
|
14632
15846
|
const upb_MiniTableField* mt_f =
|
14633
15847
|
&m->layout->UPB_PRIVATE(fields)[layout_index];
|
14634
15848
|
UPB_ASSERT(upb_FieldDef_Type(f) == upb_MiniTableField_Type(mt_f));
|
@@ -15394,7 +16608,7 @@ upb_ServiceDef* _upb_ServiceDefs_New(upb_DefBuilder* ctx, int n,
|
|
15394
16608
|
#undef UPB_ASAN
|
15395
16609
|
#undef UPB_ASAN_GUARD_SIZE
|
15396
16610
|
#undef UPB_CLANG_ASAN
|
15397
|
-
#undef
|
16611
|
+
#undef UPB_TREAT_CLOSED_ENUMS_LIKE_OPEN
|
15398
16612
|
#undef UPB_DEPRECATED
|
15399
16613
|
#undef UPB_GNUC_MIN
|
15400
16614
|
#undef UPB_DESCRIPTOR_UPB_H_FILENAME
|
@@ -15405,3 +16619,7 @@ upb_ServiceDef* _upb_ServiceDefs_New(upb_DefBuilder* ctx, int n,
|
|
15405
16619
|
#undef UPB_USE_C11_ATOMICS
|
15406
16620
|
#undef UPB_PRIVATE
|
15407
16621
|
#undef UPB_ONLYBITS
|
16622
|
+
#undef UPB_LINKARR_DECLARE
|
16623
|
+
#undef UPB_LINKARR_APPEND
|
16624
|
+
#undef UPB_LINKARR_START
|
16625
|
+
#undef UPB_LINKARR_STOP
|