google-protobuf 3.0.0.alpha.5.0.4 → 3.0.0.alpha.5.0.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

@@ -5,6 +5,7 @@
5
5
  **
6
6
  ** - upb::MessageDef (upb_msgdef): describes a "message" construct.
7
7
  ** - upb::FieldDef (upb_fielddef): describes a message field.
8
+ ** - upb::FileDef (upb_filedef): describes a .proto file and its defs.
8
9
  ** - upb::EnumDef (upb_enumdef): describes an enum.
9
10
  ** - upb::OneofDef (upb_oneofdef): describes a oneof.
10
11
  ** - upb::Def (upb_def): base class of all the others.
@@ -79,6 +80,18 @@
79
80
  #include <stdbool.h>
80
81
  #include <stddef.h>
81
82
 
83
+ #ifdef __cplusplus
84
+ namespace upb {
85
+ class Allocator;
86
+ class Arena;
87
+ class Environment;
88
+ class ErrorSpace;
89
+ class Status;
90
+ template <int N> class InlinedArena;
91
+ template <int N> class InlinedEnvironment;
92
+ }
93
+ #endif
94
+
82
95
  /* UPB_INLINE: inline if possible, emit standalone code if required. */
83
96
  #ifdef __cplusplus
84
97
  #define UPB_INLINE inline
@@ -146,6 +159,7 @@
146
159
  #define UPB_ASSERT_STDLAYOUT(type) \
147
160
  static_assert(std::is_standard_layout<type>::value, \
148
161
  #type " must be standard layout");
162
+ #define UPB_FINAL final
149
163
  #else /* !defined(UPB_CXX11) */
150
164
  #define UPB_DISALLOW_COPY_AND_ASSIGN(class_name) \
151
165
  class_name(const class_name&); \
@@ -155,6 +169,7 @@
155
169
  ~class_name(); \
156
170
  UPB_DISALLOW_COPY_AND_ASSIGN(class_name)
157
171
  #define UPB_ASSERT_STDLAYOUT(type)
172
+ #define UPB_FINAL
158
173
  #endif
159
174
 
160
175
  /* UPB_DECLARE_TYPE()
@@ -193,13 +208,15 @@
193
208
  template <> \
194
209
  class Pointer<cppname> : public PointerBase<cppname, cppbase> { \
195
210
  public: \
196
- explicit Pointer(cppname* ptr) : PointerBase(ptr) {} \
211
+ explicit Pointer(cppname* ptr) \
212
+ : PointerBase<cppname, cppbase>(ptr) {} \
197
213
  }; \
198
214
  template <> \
199
215
  class Pointer<const cppname> \
200
216
  : public PointerBase<const cppname, const cppbase> { \
201
217
  public: \
202
- explicit Pointer(const cppname* ptr) : PointerBase(ptr) {} \
218
+ explicit Pointer(const cppname* ptr) \
219
+ : PointerBase<const cppname, const cppbase>(ptr) {} \
203
220
  }; \
204
221
  }
205
222
 
@@ -211,13 +228,15 @@
211
228
  template <> \
212
229
  class Pointer<cppname> : public PointerBase2<cppname, cppbase, cppbase2> { \
213
230
  public: \
214
- explicit Pointer(cppname* ptr) : PointerBase2(ptr) {} \
231
+ explicit Pointer(cppname* ptr) \
232
+ : PointerBase2<cppname, cppbase, cppbase2>(ptr) {} \
215
233
  }; \
216
234
  template <> \
217
235
  class Pointer<const cppname> \
218
236
  : public PointerBase2<const cppname, const cppbase, const cppbase2> { \
219
237
  public: \
220
- explicit Pointer(const cppname* ptr) : PointerBase2(ptr) {} \
238
+ explicit Pointer(const cppname* ptr) \
239
+ : PointerBase2<const cppname, const cppbase, const cppbase2>(ptr) {} \
221
240
  }; \
222
241
  }
223
242
 
@@ -252,6 +271,7 @@
252
271
  /* Generic function type. */
253
272
  typedef void upb_func();
254
273
 
274
+
255
275
  /* C++ Casts ******************************************************************/
256
276
 
257
277
  #ifdef __cplusplus
@@ -329,243 +349,430 @@ class PointerBase2 : public PointerBase<T, Base> {
329
349
  #endif
330
350
 
331
351
 
332
- /* upb::reffed_ptr ************************************************************/
352
+ /* upb::ErrorSpace ************************************************************/
353
+
354
+ /* A upb::ErrorSpace represents some domain of possible error values. This lets
355
+ * upb::Status attach specific error codes to operations, like POSIX/C errno,
356
+ * Win32 error codes, etc. Clients who want to know the very specific error
357
+ * code can check the error space and then know the type of the integer code.
358
+ *
359
+ * NOTE: upb::ErrorSpace is currently not used and should be considered
360
+ * experimental. It is important primarily in cases where upb is performing
361
+ * I/O, but upb doesn't currently have any components that do this. */
362
+
363
+ UPB_DECLARE_TYPE(upb::ErrorSpace, upb_errorspace)
333
364
 
334
365
  #ifdef __cplusplus
366
+ class upb::ErrorSpace {
367
+ #else
368
+ struct upb_errorspace {
369
+ #endif
370
+ const char *name;
371
+ };
335
372
 
336
- #include <algorithm> /* For std::swap(). */
337
373
 
338
- namespace upb {
374
+ /* upb::Status ****************************************************************/
339
375
 
340
- /* Provides RAII semantics for upb refcounted objects. Each reffed_ptr owns a
341
- * ref on whatever object it points to (if any). */
342
- template <class T> class reffed_ptr {
376
+ /* upb::Status represents a success or failure status and error message.
377
+ * It owns no resources and allocates no memory, so it should work
378
+ * even in OOM situations. */
379
+ UPB_DECLARE_TYPE(upb::Status, upb_status)
380
+
381
+ /* The maximum length of an error message before it will get truncated. */
382
+ #define UPB_STATUS_MAX_MESSAGE 128
383
+
384
+ UPB_BEGIN_EXTERN_C
385
+
386
+ const char *upb_status_errmsg(const upb_status *status);
387
+ bool upb_ok(const upb_status *status);
388
+ upb_errorspace *upb_status_errspace(const upb_status *status);
389
+ int upb_status_errcode(const upb_status *status);
390
+
391
+ /* Any of the functions that write to a status object allow status to be NULL,
392
+ * to support use cases where the function's caller does not care about the
393
+ * status message. */
394
+ void upb_status_clear(upb_status *status);
395
+ void upb_status_seterrmsg(upb_status *status, const char *msg);
396
+ void upb_status_seterrf(upb_status *status, const char *fmt, ...);
397
+ void upb_status_vseterrf(upb_status *status, const char *fmt, va_list args);
398
+ void upb_status_copy(upb_status *to, const upb_status *from);
399
+
400
+ UPB_END_EXTERN_C
401
+
402
+ #ifdef __cplusplus
403
+
404
+ class upb::Status {
343
405
  public:
344
- reffed_ptr() : ptr_(NULL) {}
406
+ Status() { upb_status_clear(this); }
345
407
 
346
- /* If ref_donor is NULL, takes a new ref, otherwise adopts from ref_donor. */
347
- template <class U>
348
- reffed_ptr(U* val, const void* ref_donor = NULL)
349
- : ptr_(upb::upcast(val)) {
350
- if (ref_donor) {
351
- assert(ptr_);
352
- ptr_->DonateRef(ref_donor, this);
353
- } else if (ptr_) {
354
- ptr_->Ref(this);
355
- }
356
- }
408
+ /* Returns true if there is no error. */
409
+ bool ok() const { return upb_ok(this); }
357
410
 
358
- template <class U>
359
- reffed_ptr(const reffed_ptr<U>& other)
360
- : ptr_(upb::upcast(other.get())) {
361
- if (ptr_) ptr_->Ref(this);
362
- }
411
+ /* Optional error space and code, useful if the caller wants to
412
+ * programmatically check the specific kind of error. */
413
+ ErrorSpace* error_space() { return upb_status_errspace(this); }
414
+ int error_code() const { return upb_status_errcode(this); }
363
415
 
364
- ~reffed_ptr() { if (ptr_) ptr_->Unref(this); }
416
+ /* The returned string is invalidated by any other call into the status. */
417
+ const char *error_message() const { return upb_status_errmsg(this); }
365
418
 
366
- template <class U>
367
- reffed_ptr& operator=(const reffed_ptr<U>& other) {
368
- reset(other.get());
369
- return *this;
419
+ /* The error message will be truncated if it is longer than
420
+ * UPB_STATUS_MAX_MESSAGE-4. */
421
+ void SetErrorMessage(const char* msg) { upb_status_seterrmsg(this, msg); }
422
+ void SetFormattedErrorMessage(const char* fmt, ...) {
423
+ va_list args;
424
+ va_start(args, fmt);
425
+ upb_status_vseterrf(this, fmt, args);
426
+ va_end(args);
370
427
  }
371
428
 
372
- reffed_ptr& operator=(const reffed_ptr& other) {
373
- reset(other.get());
374
- return *this;
375
- }
429
+ /* Resets the status to a successful state with no message. */
430
+ void Clear() { upb_status_clear(this); }
376
431
 
377
- /* TODO(haberman): add C++11 move construction/assignment for greater
378
- * efficiency. */
432
+ void CopyFrom(const Status& other) { upb_status_copy(this, &other); }
379
433
 
380
- void swap(reffed_ptr& other) {
381
- if (ptr_ == other.ptr_) {
382
- return;
383
- }
434
+ private:
435
+ UPB_DISALLOW_COPY_AND_ASSIGN(Status)
436
+ #else
437
+ struct upb_status {
438
+ #endif
439
+ bool ok_;
384
440
 
385
- if (ptr_) ptr_->DonateRef(this, &other);
386
- if (other.ptr_) other.ptr_->DonateRef(&other, this);
387
- std::swap(ptr_, other.ptr_);
388
- }
441
+ /* Specific status code defined by some error space (optional). */
442
+ int code_;
443
+ upb_errorspace *error_space_;
389
444
 
390
- T& operator*() const {
391
- assert(ptr_);
392
- return *ptr_;
393
- }
445
+ /* TODO(haberman): add file/line of error? */
394
446
 
395
- T* operator->() const {
396
- assert(ptr_);
397
- return ptr_;
398
- }
447
+ /* Error message; NULL-terminated. */
448
+ char msg[UPB_STATUS_MAX_MESSAGE];
449
+ };
399
450
 
400
- T* get() const { return ptr_; }
451
+ #define UPB_STATUS_INIT {true, 0, NULL, {0}}
401
452
 
402
- /* If ref_donor is NULL, takes a new ref, otherwise adopts from ref_donor. */
403
- template <class U>
404
- void reset(U* ptr = NULL, const void* ref_donor = NULL) {
405
- reffed_ptr(ptr, ref_donor).swap(*this);
406
- }
407
453
 
408
- template <class U>
409
- reffed_ptr<U> down_cast() {
410
- return reffed_ptr<U>(upb::down_cast<U*>(get()));
411
- }
454
+ /** Built-in error spaces. ****************************************************/
412
455
 
413
- template <class U>
414
- reffed_ptr<U> dyn_cast() {
415
- return reffed_ptr<U>(upb::dyn_cast<U*>(get()));
416
- }
456
+ /* Errors raised by upb that we want to be able to detect programmatically. */
457
+ typedef enum {
458
+ UPB_NOMEM /* Can't reuse ENOMEM because it is POSIX, not ISO C. */
459
+ } upb_errcode_t;
417
460
 
418
- /* Plain release() is unsafe; if we were the only owner, it would leak the
419
- * object. Instead we provide this: */
420
- T* ReleaseTo(const void* new_owner) {
421
- T* ret = NULL;
422
- ptr_->DonateRef(this, new_owner);
423
- std::swap(ret, ptr_);
424
- return ret;
425
- }
461
+ extern upb_errorspace upb_upberr;
462
+
463
+ void upb_upberr_setoom(upb_status *s);
464
+
465
+ /* Since errno is defined by standard C, we define an error space for it in
466
+ * core upb. Other error spaces should be defined in other, platform-specific
467
+ * modules. */
468
+
469
+ extern upb_errorspace upb_errnoerr;
470
+
471
+
472
+ /** upb::Allocator ************************************************************/
473
+
474
+ /* A upb::Allocator is a possibly-stateful allocator object.
475
+ *
476
+ * It could either be an arena allocator (which doesn't require individual
477
+ * free() calls) or a regular malloc() (which does). The client must therefore
478
+ * free memory unless it knows that the allocator is an arena allocator. */
479
+ UPB_DECLARE_TYPE(upb::Allocator, upb_alloc)
480
+
481
+ /* A malloc()/free() function.
482
+ * If "size" is 0 then the function acts like free(), otherwise it acts like
483
+ * realloc(). Only "oldsize" bytes from a previous allocation are preserved. */
484
+ typedef void *upb_alloc_func(upb_alloc *alloc, void *ptr, size_t oldsize,
485
+ size_t size);
486
+
487
+ #ifdef __cplusplus
488
+
489
+ class upb::Allocator UPB_FINAL {
490
+ public:
491
+ Allocator() {}
426
492
 
427
493
  private:
428
- T* ptr_;
494
+ UPB_DISALLOW_COPY_AND_ASSIGN(Allocator)
495
+
496
+ public:
497
+ #else
498
+ struct upb_alloc {
499
+ #endif /* __cplusplus */
500
+ upb_alloc_func *func;
429
501
  };
430
502
 
431
- } /* namespace upb */
503
+ UPB_INLINE void *upb_malloc(upb_alloc *alloc, size_t size) {
504
+ assert(size > 0);
505
+ return alloc->func(alloc, NULL, 0, size);
506
+ }
432
507
 
433
- #endif /* __cplusplus */
508
+ UPB_INLINE void *upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize,
509
+ size_t size) {
510
+ assert(size > 0);
511
+ return alloc->func(alloc, ptr, oldsize, size);
512
+ }
434
513
 
514
+ UPB_INLINE void upb_free(upb_alloc *alloc, void *ptr) {
515
+ alloc->func(alloc, ptr, 0, 0);
516
+ }
435
517
 
436
- /* upb::Status ****************************************************************/
518
+ /* The global allocator used by upb. Uses the standard malloc()/free(). */
437
519
 
438
- #ifdef __cplusplus
439
- namespace upb {
440
- class ErrorSpace;
441
- class Status;
520
+ extern upb_alloc upb_alloc_global;
521
+
522
+ /* Functions that hard-code the global malloc.
523
+ *
524
+ * We still get benefit because we can put custom logic into our global
525
+ * allocator, like injecting out-of-memory faults in debug/testing builds. */
526
+
527
+ UPB_INLINE void *upb_gmalloc(size_t size) {
528
+ return upb_malloc(&upb_alloc_global, size);
442
529
  }
443
- #endif
444
530
 
445
- UPB_DECLARE_TYPE(upb::ErrorSpace, upb_errorspace)
446
- UPB_DECLARE_TYPE(upb::Status, upb_status)
531
+ UPB_INLINE void *upb_grealloc(void *ptr, size_t oldsize, size_t size) {
532
+ return upb_realloc(&upb_alloc_global, ptr, oldsize, size);
533
+ }
447
534
 
448
- /* The maximum length of an error message before it will get truncated. */
449
- #define UPB_STATUS_MAX_MESSAGE 128
535
+ UPB_INLINE void upb_gfree(void *ptr) {
536
+ upb_free(&upb_alloc_global, ptr);
537
+ }
538
+
539
+ /* upb::Arena *****************************************************************/
540
+
541
+ /* upb::Arena is a specific allocator implementation that uses arena allocation.
542
+ * The user provides an allocator that will be used to allocate the underlying
543
+ * arena blocks. Arenas by nature do not require the individual allocations
544
+ * to be freed. However the Arena does allow users to register cleanup
545
+ * functions that will run when the arena is destroyed.
546
+ *
547
+ * A upb::Arena is *not* thread-safe.
548
+ *
549
+ * You could write a thread-safe arena allocator that satisfies the
550
+ * upb::Allocator interface, but it would not be as efficient for the
551
+ * single-threaded case. */
552
+ UPB_DECLARE_TYPE(upb::Arena, upb_arena)
450
553
 
451
- /* An error callback function is used to report errors from some component.
452
- * The function can return "true" to indicate that the component should try
453
- * to recover and proceed, but this is not always possible. */
454
- typedef bool upb_errcb_t(void *closure, const upb_status* status);
554
+ typedef void upb_cleanup_func(void *ud);
555
+
556
+ #define UPB_ARENA_BLOCK_OVERHEAD (sizeof(size_t)*4)
557
+
558
+ UPB_BEGIN_EXTERN_C
559
+
560
+ void upb_arena_init(upb_arena *a);
561
+ void upb_arena_init2(upb_arena *a, void *mem, size_t n, upb_alloc *alloc);
562
+ void upb_arena_uninit(upb_arena *a);
563
+ upb_alloc *upb_arena_alloc(upb_arena *a);
564
+ bool upb_arena_addcleanup(upb_arena *a, upb_cleanup_func *func, void *ud);
565
+ size_t upb_arena_bytesallocated(const upb_arena *a);
566
+ void upb_arena_setnextblocksize(upb_arena *a, size_t size);
567
+ void upb_arena_setmaxblocksize(upb_arena *a, size_t size);
568
+
569
+ UPB_END_EXTERN_C
455
570
 
456
571
  #ifdef __cplusplus
457
- class upb::ErrorSpace {
572
+
573
+ class upb::Arena {
574
+ public:
575
+ /* A simple arena with no initial memory block and the default allocator. */
576
+ Arena() { upb_arena_init(this); }
577
+
578
+ /* Constructs an arena with the given initial block which allocates blocks
579
+ * with the given allocator. The given allocator must outlive the Arena.
580
+ *
581
+ * If you pass NULL for the allocator it will default to the global allocator
582
+ * upb_alloc_global, and NULL/0 for the initial block will cause there to be
583
+ * no initial block. */
584
+ Arena(void *mem, size_t len, Allocator* a) {
585
+ upb_arena_init2(this, mem, len, a);
586
+ }
587
+
588
+ ~Arena() { upb_arena_uninit(this); }
589
+
590
+ /* Sets the size of the next block the Arena will request (unless the
591
+ * requested allocation is larger). Each block will double in size until the
592
+ * max limit is reached. */
593
+ void SetNextBlockSize(size_t size) { upb_arena_setnextblocksize(this, size); }
594
+
595
+ /* Sets the maximum block size. No blocks larger than this will be requested
596
+ * from the underlying allocator unless individual arena allocations are
597
+ * larger. */
598
+ void SetMaxBlockSize(size_t size) { upb_arena_setmaxblocksize(this, size); }
599
+
600
+ /* Allows this arena to be used as a generic allocator.
601
+ *
602
+ * The arena does not need free() calls so when using Arena as an allocator
603
+ * it is safe to skip them. However they are no-ops so there is no harm in
604
+ * calling free() either. */
605
+ Allocator* allocator() { return upb_arena_alloc(this); }
606
+
607
+ /* Add a cleanup function to run when the arena is destroyed.
608
+ * Returns false on out-of-memory. */
609
+ bool AddCleanup(upb_cleanup_func* func, void* ud) {
610
+ return upb_arena_addcleanup(this, func, ud);
611
+ }
612
+
613
+ /* Total number of bytes that have been allocated. It is undefined what
614
+ * Realloc() does to this counter. */
615
+ size_t BytesAllocated() const {
616
+ return upb_arena_bytesallocated(this);
617
+ }
618
+
619
+ private:
620
+ UPB_DISALLOW_COPY_AND_ASSIGN(Arena)
621
+
458
622
  #else
459
- struct upb_errorspace {
460
- #endif
461
- const char *name;
462
- /* Should the error message in the status object according to this code. */
463
- void (*set_message)(upb_status* status, int code);
623
+ struct upb_arena {
624
+ #endif /* __cplusplus */
625
+ /* We implement the allocator interface.
626
+ * This must be the first member of upb_arena! */
627
+ upb_alloc alloc;
628
+
629
+ /* Allocator to allocate arena blocks. We are responsible for freeing these
630
+ * when we are destroyed. */
631
+ upb_alloc *block_alloc;
632
+
633
+ size_t bytes_allocated;
634
+ size_t next_block_size;
635
+ size_t max_block_size;
636
+
637
+ /* Linked list of blocks. Points to an arena_block, defined in env.c */
638
+ void *block_head;
639
+
640
+ /* Cleanup entries. Pointer to a cleanup_ent, defined in env.c */
641
+ void *cleanup_head;
642
+
643
+ /* For future expansion, since the size of this struct is exposed to users. */
644
+ void *future1;
645
+ void *future2;
464
646
  };
465
647
 
466
- #ifdef __cplusplus
467
648
 
468
- /* Object representing a success or failure status.
469
- * It owns no resources and allocates no memory, so it should work
470
- * even in OOM situations. */
649
+ /* upb::Environment ***********************************************************/
471
650
 
472
- class upb::Status {
473
- public:
474
- Status();
651
+ /* A upb::Environment provides a means for injecting malloc and an
652
+ * error-reporting callback into encoders/decoders. This allows them to be
653
+ * independent of nearly all assumptions about their actual environment.
654
+ *
655
+ * It is also a container for allocating the encoders/decoders themselves that
656
+ * insulates clients from knowing their actual size. This provides ABI
657
+ * compatibility even if the size of the objects change. And this allows the
658
+ * structure definitions to be in the .c files instead of the .h files, making
659
+ * the .h files smaller and more readable.
660
+ *
661
+ * We might want to consider renaming this to "Pipeline" if/when the concept of
662
+ * a pipeline element becomes more formalized. */
663
+ UPB_DECLARE_TYPE(upb::Environment, upb_env)
475
664
 
476
- /* Returns true if there is no error. */
477
- bool ok() const;
665
+ /* A function that receives an error report from an encoder or decoder. The
666
+ * callback can return true to request that the error should be recovered, but
667
+ * if the error is not recoverable this has no effect. */
668
+ typedef bool upb_error_func(void *ud, const upb_status *status);
478
669
 
479
- /* Optional error space and code, useful if the caller wants to
480
- * programmatically check the specific kind of error. */
481
- ErrorSpace* error_space();
482
- int code() const;
670
+ UPB_BEGIN_EXTERN_C
483
671
 
484
- const char *error_message() const;
672
+ void upb_env_init(upb_env *e);
673
+ void upb_env_init2(upb_env *e, void *mem, size_t n, upb_alloc *alloc);
674
+ void upb_env_uninit(upb_env *e);
485
675
 
486
- /* The error message will be truncated if it is longer than
487
- * UPB_STATUS_MAX_MESSAGE-4. */
488
- void SetErrorMessage(const char* msg);
489
- void SetFormattedErrorMessage(const char* fmt, ...);
676
+ void upb_env_initonly(upb_env *e);
490
677
 
491
- /* If there is no error message already, this will use the ErrorSpace to
492
- * populate the error message for this code. The caller can still call
493
- * SetErrorMessage() to give a more specific message. */
494
- void SetErrorCode(ErrorSpace* space, int code);
678
+ upb_arena *upb_env_arena(upb_env *e);
679
+ bool upb_env_ok(const upb_env *e);
680
+ void upb_env_seterrorfunc(upb_env *e, upb_error_func *func, void *ud);
495
681
 
496
- /* Resets the status to a successful state with no message. */
497
- void Clear();
682
+ /* Convenience wrappers around the methods of the contained arena. */
683
+ void upb_env_reporterrorsto(upb_env *e, upb_status *s);
684
+ bool upb_env_reporterror(upb_env *e, const upb_status *s);
685
+ void *upb_env_malloc(upb_env *e, size_t size);
686
+ void *upb_env_realloc(upb_env *e, void *ptr, size_t oldsize, size_t size);
687
+ void upb_env_free(upb_env *e, void *ptr);
688
+ bool upb_env_addcleanup(upb_env *e, upb_cleanup_func *func, void *ud);
689
+ size_t upb_env_bytesallocated(const upb_env *e);
690
+
691
+ UPB_END_EXTERN_C
692
+
693
+ #ifdef __cplusplus
694
+
695
+ class upb::Environment {
696
+ public:
697
+ /* The given Arena must outlive this environment. */
698
+ Environment() { upb_env_initonly(this); }
699
+
700
+ Environment(void *mem, size_t len, Allocator *a) : arena_(mem, len, a) {
701
+ upb_env_initonly(this);
702
+ }
703
+
704
+ Arena* arena() { return upb_env_arena(this); }
705
+
706
+ /* Set a custom error reporting function. */
707
+ void SetErrorFunction(upb_error_func* func, void* ud) {
708
+ upb_env_seterrorfunc(this, func, ud);
709
+ }
710
+
711
+ /* Set the error reporting function to simply copy the status to the given
712
+ * status and abort. */
713
+ void ReportErrorsTo(Status* status) { upb_env_reporterrorsto(this, status); }
714
+
715
+ /* Returns true if all allocations and AddCleanup() calls have succeeded,
716
+ * and no errors were reported with ReportError() (except ones that recovered
717
+ * successfully). */
718
+ bool ok() const { return upb_env_ok(this); }
498
719
 
499
- void CopyFrom(const Status& other);
720
+ /* Reports an error to this environment's callback, returning true if
721
+ * the caller should try to recover. */
722
+ bool ReportError(const Status* status) {
723
+ return upb_env_reporterror(this, status);
724
+ }
500
725
 
501
726
  private:
502
- UPB_DISALLOW_COPY_AND_ASSIGN(Status)
727
+ UPB_DISALLOW_COPY_AND_ASSIGN(Environment)
728
+
503
729
  #else
504
- struct upb_status {
505
- #endif
730
+ struct upb_env {
731
+ #endif /* __cplusplus */
732
+ upb_arena arena_;
733
+ upb_error_func *error_func_;
734
+ void *error_ud_;
506
735
  bool ok_;
736
+ };
507
737
 
508
- /* Specific status code defined by some error space (optional). */
509
- int code_;
510
- upb_errorspace *error_space_;
511
738
 
512
- /* Error message; NULL-terminated. */
513
- char msg[UPB_STATUS_MAX_MESSAGE];
514
- };
739
+ /* upb::InlinedArena **********************************************************/
740
+ /* upb::InlinedEnvironment ****************************************************/
515
741
 
516
- #define UPB_STATUS_INIT {true, 0, NULL, {0}}
742
+ /* upb::InlinedArena and upb::InlinedEnvironment seed their arenas with a
743
+ * predefined amount of memory. No heap memory will be allocated until the
744
+ * initial block is exceeded.
745
+ *
746
+ * These types only exist in C++ */
517
747
 
518
748
  #ifdef __cplusplus
519
- extern "C" {
520
- #endif
521
749
 
522
- /* The returned string is invalidated by any other call into the status. */
523
- const char *upb_status_errmsg(const upb_status *status);
524
- bool upb_ok(const upb_status *status);
525
- upb_errorspace *upb_status_errspace(const upb_status *status);
526
- int upb_status_errcode(const upb_status *status);
750
+ template <int N> class upb::InlinedArena : public upb::Arena {
751
+ public:
752
+ InlinedArena() : Arena(initial_block_, N, NULL) {}
753
+ explicit InlinedArena(Allocator* a) : Arena(initial_block_, N, a) {}
527
754
 
528
- /* Any of the functions that write to a status object allow status to be NULL,
529
- * to support use cases where the function's caller does not care about the
530
- * status message. */
531
- void upb_status_clear(upb_status *status);
532
- void upb_status_seterrmsg(upb_status *status, const char *msg);
533
- void upb_status_seterrf(upb_status *status, const char *fmt, ...);
534
- void upb_status_vseterrf(upb_status *status, const char *fmt, va_list args);
535
- void upb_status_seterrcode(upb_status *status, upb_errorspace *space, int code);
536
- void upb_status_copy(upb_status *to, const upb_status *from);
755
+ private:
756
+ UPB_DISALLOW_COPY_AND_ASSIGN(InlinedArena)
537
757
 
538
- #ifdef __cplusplus
539
- } /* extern "C" */
758
+ char initial_block_[N + UPB_ARENA_BLOCK_OVERHEAD];
759
+ };
540
760
 
541
- namespace upb {
761
+ template <int N> class upb::InlinedEnvironment : public upb::Environment {
762
+ public:
763
+ InlinedEnvironment() : Environment(initial_block_, N, NULL) {}
764
+ explicit InlinedEnvironment(Allocator *a)
765
+ : Environment(initial_block_, N, a) {}
542
766
 
543
- /* C++ Wrappers */
544
- inline Status::Status() { Clear(); }
545
- inline bool Status::ok() const { return upb_ok(this); }
546
- inline const char* Status::error_message() const {
547
- return upb_status_errmsg(this);
548
- }
549
- inline void Status::SetErrorMessage(const char* msg) {
550
- upb_status_seterrmsg(this, msg);
551
- }
552
- inline void Status::SetFormattedErrorMessage(const char* fmt, ...) {
553
- va_list args;
554
- va_start(args, fmt);
555
- upb_status_vseterrf(this, fmt, args);
556
- va_end(args);
557
- }
558
- inline void Status::SetErrorCode(ErrorSpace* space, int code) {
559
- upb_status_seterrcode(this, space, code);
560
- }
561
- inline void Status::Clear() { upb_status_clear(this); }
562
- inline void Status::CopyFrom(const Status& other) {
563
- upb_status_copy(this, &other);
564
- }
767
+ private:
768
+ UPB_DISALLOW_COPY_AND_ASSIGN(InlinedEnvironment)
769
+
770
+ char initial_block_[N + UPB_ARENA_BLOCK_OVERHEAD];
771
+ };
772
+
773
+ #endif /* __cplusplus */
565
774
 
566
- } /* namespace upb */
567
775
 
568
- #endif
569
776
 
570
777
  #endif /* UPB_H_ */
571
778
 
@@ -607,10 +814,14 @@ typedef struct {
607
814
  #endif
608
815
 
609
816
  /* Like strdup(), which isn't always available since it's not ANSI C. */
610
- char *upb_strdup(const char *s);
817
+ char *upb_strdup(const char *s, upb_alloc *a);
611
818
  /* Variant that works with a length-delimited rather than NULL-delimited string,
612
819
  * as supported by strtable. */
613
- char *upb_strdup2(const char *s, size_t len);
820
+ char *upb_strdup2(const char *s, size_t len, upb_alloc *a);
821
+
822
+ UPB_INLINE char *upb_gstrdup(const char *s) {
823
+ return upb_strdup(s, &upb_alloc_global);
824
+ }
614
825
 
615
826
  UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val,
616
827
  upb_ctype_t ctype) {
@@ -787,14 +998,40 @@ typedef struct {
787
998
  * initialize const hash tables. Then we cast away const when we have to.
788
999
  */
789
1000
  const upb_tabent *entries;
1001
+
1002
+ #ifndef NDEBUG
1003
+ /* This table's allocator. We make the user pass it in to every relevant
1004
+ * function and only use this to check it in debug mode. We do this solely
1005
+ * to keep upb_table as small as possible. This might seem slightly paranoid
1006
+ * but the plan is to use upb_table for all map fields and extension sets in
1007
+ * a forthcoming message representation, so there could be a lot of these.
1008
+ * If this turns out to be too annoying later, we can change it (since this
1009
+ * is an internal-only header file). */
1010
+ upb_alloc *alloc;
1011
+ #endif
790
1012
  } upb_table;
791
1013
 
1014
+ #ifdef NDEBUG
1015
+ # define UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries) \
1016
+ {count, mask, ctype, size_lg2, entries}
1017
+ #else
1018
+ # ifdef UPB_DEBUG_REFS
1019
+ /* At the moment the only mutable tables we statically initialize are debug
1020
+ * ref tables. */
1021
+ # define UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries) \
1022
+ {count, mask, ctype, size_lg2, entries, &upb_alloc_debugrefs}
1023
+ # else
1024
+ # define UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries) \
1025
+ {count, mask, ctype, size_lg2, entries, NULL}
1026
+ # endif
1027
+ #endif
1028
+
792
1029
  typedef struct {
793
1030
  upb_table t;
794
1031
  } upb_strtable;
795
1032
 
796
1033
  #define UPB_STRTABLE_INIT(count, mask, ctype, size_lg2, entries) \
797
- {{count, mask, ctype, size_lg2, entries}}
1034
+ {UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries)}
798
1035
 
799
1036
  #define UPB_EMPTY_STRTABLE_INIT(ctype) \
800
1037
  UPB_STRTABLE_INIT(0, 0, ctype, 0, NULL)
@@ -807,7 +1044,7 @@ typedef struct {
807
1044
  } upb_inttable;
808
1045
 
809
1046
  #define UPB_INTTABLE_INIT(count, mask, ctype, size_lg2, ent, a, asize, acount) \
810
- {{count, mask, ctype, size_lg2, ent}, a, asize, acount}
1047
+ {UPB_TABLE_INIT(count, mask, ctype, size_lg2, ent), a, asize, acount}
811
1048
 
812
1049
  #define UPB_EMPTY_INTTABLE_INIT(ctype) \
813
1050
  UPB_INTTABLE_INIT(0, 0, ctype, 0, NULL, NULL, 0, 0)
@@ -847,10 +1084,26 @@ UPB_INLINE bool upb_arrhas(upb_tabval key) {
847
1084
 
848
1085
  /* Initialize and uninitialize a table, respectively. If memory allocation
849
1086
  * failed, false is returned that the table is uninitialized. */
850
- bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype);
851
- bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype);
852
- void upb_inttable_uninit(upb_inttable *table);
853
- void upb_strtable_uninit(upb_strtable *table);
1087
+ bool upb_inttable_init2(upb_inttable *table, upb_ctype_t ctype, upb_alloc *a);
1088
+ bool upb_strtable_init2(upb_strtable *table, upb_ctype_t ctype, upb_alloc *a);
1089
+ void upb_inttable_uninit2(upb_inttable *table, upb_alloc *a);
1090
+ void upb_strtable_uninit2(upb_strtable *table, upb_alloc *a);
1091
+
1092
+ UPB_INLINE bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype) {
1093
+ return upb_inttable_init2(table, ctype, &upb_alloc_global);
1094
+ }
1095
+
1096
+ UPB_INLINE bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype) {
1097
+ return upb_strtable_init2(table, ctype, &upb_alloc_global);
1098
+ }
1099
+
1100
+ UPB_INLINE void upb_inttable_uninit(upb_inttable *table) {
1101
+ upb_inttable_uninit2(table, &upb_alloc_global);
1102
+ }
1103
+
1104
+ UPB_INLINE void upb_strtable_uninit(upb_strtable *table) {
1105
+ upb_strtable_uninit2(table, &upb_alloc_global);
1106
+ }
854
1107
 
855
1108
  /* Returns the number of values in the table. */
856
1109
  size_t upb_inttable_count(const upb_inttable *t);
@@ -865,9 +1118,20 @@ UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) {
865
1118
  *
866
1119
  * If a table resize was required but memory allocation failed, false is
867
1120
  * returned and the table is unchanged. */
868
- bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val);
869
- bool upb_strtable_insert2(upb_strtable *t, const char *key, size_t len,
870
- upb_value val);
1121
+ bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val,
1122
+ upb_alloc *a);
1123
+ bool upb_strtable_insert3(upb_strtable *t, const char *key, size_t len,
1124
+ upb_value val, upb_alloc *a);
1125
+
1126
+ UPB_INLINE bool upb_inttable_insert(upb_inttable *t, uintptr_t key,
1127
+ upb_value val) {
1128
+ return upb_inttable_insert2(t, key, val, &upb_alloc_global);
1129
+ }
1130
+
1131
+ UPB_INLINE bool upb_strtable_insert2(upb_strtable *t, const char *key,
1132
+ size_t len, upb_value val) {
1133
+ return upb_strtable_insert3(t, key, len, val, &upb_alloc_global);
1134
+ }
871
1135
 
872
1136
  /* For NULL-terminated strings. */
873
1137
  UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key,
@@ -890,8 +1154,13 @@ UPB_INLINE bool upb_strtable_lookup(const upb_strtable *t, const char *key,
890
1154
  /* Removes an item from the table. Returns true if the remove was successful,
891
1155
  * and stores the removed item in *val if non-NULL. */
892
1156
  bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val);
893
- bool upb_strtable_remove2(upb_strtable *t, const char *key, size_t len,
894
- upb_value *val);
1157
+ bool upb_strtable_remove3(upb_strtable *t, const char *key, size_t len,
1158
+ upb_value *val, upb_alloc *alloc);
1159
+
1160
+ UPB_INLINE bool upb_strtable_remove2(upb_strtable *t, const char *key,
1161
+ size_t len, upb_value *val) {
1162
+ return upb_strtable_remove3(t, key, len, val, &upb_alloc_global);
1163
+ }
895
1164
 
896
1165
  /* For NULL-terminated strings. */
897
1166
  UPB_INLINE bool upb_strtable_remove(upb_strtable *t, const char *key,
@@ -906,19 +1175,33 @@ bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val);
906
1175
 
907
1176
  /* Handy routines for treating an inttable like a stack. May not be mixed with
908
1177
  * other insert/remove calls. */
909
- bool upb_inttable_push(upb_inttable *t, upb_value val);
1178
+ bool upb_inttable_push2(upb_inttable *t, upb_value val, upb_alloc *a);
910
1179
  upb_value upb_inttable_pop(upb_inttable *t);
911
1180
 
1181
+ UPB_INLINE bool upb_inttable_push(upb_inttable *t, upb_value val) {
1182
+ return upb_inttable_push2(t, val, &upb_alloc_global);
1183
+ }
1184
+
912
1185
  /* Convenience routines for inttables with pointer keys. */
913
- bool upb_inttable_insertptr(upb_inttable *t, const void *key, upb_value val);
1186
+ bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val,
1187
+ upb_alloc *a);
914
1188
  bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val);
915
1189
  bool upb_inttable_lookupptr(
916
1190
  const upb_inttable *t, const void *key, upb_value *val);
917
1191
 
1192
+ UPB_INLINE bool upb_inttable_insertptr(upb_inttable *t, const void *key,
1193
+ upb_value val) {
1194
+ return upb_inttable_insertptr2(t, key, val, &upb_alloc_global);
1195
+ }
1196
+
918
1197
  /* Optimizes the table for the current set of entries, for both memory use and
919
1198
  * lookup time. Client should call this after all entries have been inserted;
920
1199
  * inserting more entries is legal, but will likely require a table resize. */
921
- void upb_inttable_compact(upb_inttable *t);
1200
+ void upb_inttable_compact2(upb_inttable *t, upb_alloc *a);
1201
+
1202
+ UPB_INLINE void upb_inttable_compact(upb_inttable *t) {
1203
+ upb_inttable_compact2(t, &upb_alloc_global);
1204
+ }
922
1205
 
923
1206
  /* A special-case inlinable version of the lookup routine for 32-bit
924
1207
  * integers. */
@@ -947,7 +1230,7 @@ UPB_INLINE bool upb_inttable_lookup32(const upb_inttable *t, uint32_t key,
947
1230
  }
948
1231
 
949
1232
  /* Exposed for testing only. */
950
- bool upb_strtable_resize(upb_strtable *t, size_t size_lg2);
1233
+ bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_alloc *a);
951
1234
 
952
1235
  /* Iterators ******************************************************************/
953
1236
 
@@ -992,8 +1275,8 @@ typedef struct {
992
1275
  void upb_strtable_begin(upb_strtable_iter *i, const upb_strtable *t);
993
1276
  void upb_strtable_next(upb_strtable_iter *i);
994
1277
  bool upb_strtable_done(const upb_strtable_iter *i);
995
- const char *upb_strtable_iter_key(upb_strtable_iter *i);
996
- size_t upb_strtable_iter_keylength(upb_strtable_iter *i);
1278
+ const char *upb_strtable_iter_key(const upb_strtable_iter *i);
1279
+ size_t upb_strtable_iter_keylength(const upb_strtable_iter *i);
997
1280
  upb_value upb_strtable_iter_value(const upb_strtable_iter *i);
998
1281
  void upb_strtable_iter_setdone(upb_strtable_iter *i);
999
1282
  bool upb_strtable_iter_isequal(const upb_strtable_iter *i1,
@@ -1046,7 +1329,10 @@ bool upb_inttable_iter_isequal(const upb_inttable_iter *i1,
1046
1329
  /* #define UPB_DEBUG_REFS */
1047
1330
 
1048
1331
  #ifdef __cplusplus
1049
- namespace upb { class RefCounted; }
1332
+ namespace upb {
1333
+ class RefCounted;
1334
+ template <class T> class reffed_ptr;
1335
+ }
1050
1336
  #endif
1051
1337
 
1052
1338
  UPB_DECLARE_TYPE(upb::RefCounted, upb_refcounted)
@@ -1114,10 +1400,12 @@ struct upb_refcounted {
1114
1400
  };
1115
1401
 
1116
1402
  #ifdef UPB_DEBUG_REFS
1117
- #define UPB_REFCOUNT_INIT(refs, ref2s) \
1118
- {&static_refcount, NULL, NULL, 0, true, refs, ref2s}
1403
+ extern upb_alloc upb_alloc_debugrefs;
1404
+ #define UPB_REFCOUNT_INIT(vtbl, refs, ref2s) \
1405
+ {&static_refcount, NULL, vtbl, 0, true, refs, ref2s}
1119
1406
  #else
1120
- #define UPB_REFCOUNT_INIT(refs, ref2s) {&static_refcount, NULL, NULL, 0, true}
1407
+ #define UPB_REFCOUNT_INIT(vtbl, refs, ref2s) \
1408
+ {&static_refcount, NULL, vtbl, 0, true}
1121
1409
  #endif
1122
1410
 
1123
1411
  UPB_BEGIN_EXTERN_C
@@ -1250,6 +1538,111 @@ inline void RefCounted::CheckRef(const void *owner) const {
1250
1538
  } /* namespace upb */
1251
1539
  #endif
1252
1540
 
1541
+
1542
+ /* upb::reffed_ptr ************************************************************/
1543
+
1544
+ #ifdef __cplusplus
1545
+
1546
+ #include <algorithm> /* For std::swap(). */
1547
+
1548
+ /* Provides RAII semantics for upb refcounted objects. Each reffed_ptr owns a
1549
+ * ref on whatever object it points to (if any). */
1550
+ template <class T> class upb::reffed_ptr {
1551
+ public:
1552
+ reffed_ptr() : ptr_(NULL) {}
1553
+
1554
+ /* If ref_donor is NULL, takes a new ref, otherwise adopts from ref_donor. */
1555
+ template <class U>
1556
+ reffed_ptr(U* val, const void* ref_donor = NULL)
1557
+ : ptr_(upb::upcast(val)) {
1558
+ if (ref_donor) {
1559
+ assert(ptr_);
1560
+ ptr_->DonateRef(ref_donor, this);
1561
+ } else if (ptr_) {
1562
+ ptr_->Ref(this);
1563
+ }
1564
+ }
1565
+
1566
+ template <class U>
1567
+ reffed_ptr(const reffed_ptr<U>& other)
1568
+ : ptr_(upb::upcast(other.get())) {
1569
+ if (ptr_) ptr_->Ref(this);
1570
+ }
1571
+
1572
+ reffed_ptr(const reffed_ptr& other)
1573
+ : ptr_(upb::upcast(other.get())) {
1574
+ if (ptr_) ptr_->Ref(this);
1575
+ }
1576
+
1577
+ ~reffed_ptr() { if (ptr_) ptr_->Unref(this); }
1578
+
1579
+ template <class U>
1580
+ reffed_ptr& operator=(const reffed_ptr<U>& other) {
1581
+ reset(other.get());
1582
+ return *this;
1583
+ }
1584
+
1585
+ reffed_ptr& operator=(const reffed_ptr& other) {
1586
+ reset(other.get());
1587
+ return *this;
1588
+ }
1589
+
1590
+ /* TODO(haberman): add C++11 move construction/assignment for greater
1591
+ * efficiency. */
1592
+
1593
+ void swap(reffed_ptr& other) {
1594
+ if (ptr_ == other.ptr_) {
1595
+ return;
1596
+ }
1597
+
1598
+ if (ptr_) ptr_->DonateRef(this, &other);
1599
+ if (other.ptr_) other.ptr_->DonateRef(&other, this);
1600
+ std::swap(ptr_, other.ptr_);
1601
+ }
1602
+
1603
+ T& operator*() const {
1604
+ assert(ptr_);
1605
+ return *ptr_;
1606
+ }
1607
+
1608
+ T* operator->() const {
1609
+ assert(ptr_);
1610
+ return ptr_;
1611
+ }
1612
+
1613
+ T* get() const { return ptr_; }
1614
+
1615
+ /* If ref_donor is NULL, takes a new ref, otherwise adopts from ref_donor. */
1616
+ template <class U>
1617
+ void reset(U* ptr = NULL, const void* ref_donor = NULL) {
1618
+ reffed_ptr(ptr, ref_donor).swap(*this);
1619
+ }
1620
+
1621
+ template <class U>
1622
+ reffed_ptr<U> down_cast() {
1623
+ return reffed_ptr<U>(upb::down_cast<U*>(get()));
1624
+ }
1625
+
1626
+ template <class U>
1627
+ reffed_ptr<U> dyn_cast() {
1628
+ return reffed_ptr<U>(upb::dyn_cast<U*>(get()));
1629
+ }
1630
+
1631
+ /* Plain release() is unsafe; if we were the only owner, it would leak the
1632
+ * object. Instead we provide this: */
1633
+ T* ReleaseTo(const void* new_owner) {
1634
+ T* ret = NULL;
1635
+ ptr_->DonateRef(this, new_owner);
1636
+ std::swap(ret, ptr_);
1637
+ return ret;
1638
+ }
1639
+
1640
+ private:
1641
+ T* ptr_;
1642
+ };
1643
+
1644
+ #endif /* __cplusplus */
1645
+
1253
1646
  #endif /* UPB_REFCOUNT_H_ */
1254
1647
 
1255
1648
  #ifdef __cplusplus
@@ -1261,12 +1654,17 @@ namespace upb {
1261
1654
  class Def;
1262
1655
  class EnumDef;
1263
1656
  class FieldDef;
1657
+ class FileDef;
1264
1658
  class MessageDef;
1265
1659
  class OneofDef;
1266
1660
  }
1267
1661
  #endif
1268
1662
 
1269
1663
  UPB_DECLARE_DERIVED_TYPE(upb::Def, upb::RefCounted, upb_def, upb_refcounted)
1664
+ UPB_DECLARE_DERIVED_TYPE(upb::OneofDef, upb::RefCounted, upb_oneofdef,
1665
+ upb_refcounted)
1666
+ UPB_DECLARE_DERIVED_TYPE(upb::FileDef, upb::RefCounted, upb_filedef,
1667
+ upb_refcounted)
1270
1668
 
1271
1669
  /* The maximum message depth that the type graph can have. This is a resource
1272
1670
  * limit for the C stack since we sometimes need to recursively traverse the
@@ -1278,15 +1676,16 @@ UPB_DECLARE_DERIVED_TYPE(upb::Def, upb::RefCounted, upb_def, upb_refcounted)
1278
1676
  #define UPB_MAX_MESSAGE_DEPTH 64
1279
1677
 
1280
1678
 
1281
- /* upb::Def: base class for defs *********************************************/
1679
+ /* upb::Def: base class for top-level defs ***********************************/
1282
1680
 
1283
- /* All the different kind of defs we support. These correspond 1:1 with
1284
- * declarations in a .proto file. */
1681
+ /* All the different kind of defs that can be defined at the top-level and put
1682
+ * in a SymbolTable or appear in a FileDef::defs() list. This excludes some
1683
+ * defs (like oneofs and files). It only includes fields because they can be
1684
+ * defined as extensions. */
1285
1685
  typedef enum {
1286
1686
  UPB_DEF_MSG,
1287
1687
  UPB_DEF_FIELD,
1288
1688
  UPB_DEF_ENUM,
1289
- UPB_DEF_ONEOF,
1290
1689
  UPB_DEF_SERVICE, /* Not yet implemented. */
1291
1690
  UPB_DEF_ANY = -1 /* Wildcard for upb_symtab_get*() */
1292
1691
  } upb_deftype_t;
@@ -1309,6 +1708,9 @@ class upb::Def {
1309
1708
  /* "fullname" is the def's fully-qualified name (eg. foo.bar.Message). */
1310
1709
  const char *full_name() const;
1311
1710
 
1711
+ /* The final part of a def's name (eg. Message). */
1712
+ const char *name() const;
1713
+
1312
1714
  /* The def must be mutable. Caller retains ownership of fullname. Defs are
1313
1715
  * not required to have a name; if a def has no name when it is frozen, it
1314
1716
  * will remain an anonymous def. On failure, returns false and details in "s"
@@ -1316,6 +1718,11 @@ class upb::Def {
1316
1718
  bool set_full_name(const char* fullname, upb::Status* s);
1317
1719
  bool set_full_name(const std::string &fullname, upb::Status* s);
1318
1720
 
1721
+ /* The file in which this def appears. It is not necessary to add a def to a
1722
+ * file (and consequently the accessor may return NULL). Set this by calling
1723
+ * file->Add(def). */
1724
+ FileDef* file() const;
1725
+
1319
1726
  /* Freezes the given defs; this validates all constraints and marks the defs
1320
1727
  * as frozen (read-only). "defs" may not contain any fielddefs, but fields
1321
1728
  * of any msgdefs will be frozen.
@@ -1327,7 +1734,7 @@ class upb::Def {
1327
1734
  *
1328
1735
  * After this operation succeeds, the finalized defs must only be accessed
1329
1736
  * through a const pointer! */
1330
- static bool Freeze(Def* const* defs, int n, Status* status);
1737
+ static bool Freeze(Def* const* defs, size_t n, Status* status);
1331
1738
  static bool Freeze(const std::vector<Def*>& defs, Status* status);
1332
1739
 
1333
1740
  private:
@@ -1346,8 +1753,13 @@ UPB_REFCOUNTED_CMETHODS(upb_def, upb_def_upcast)
1346
1753
 
1347
1754
  upb_deftype_t upb_def_type(const upb_def *d);
1348
1755
  const char *upb_def_fullname(const upb_def *d);
1756
+ const char *upb_def_name(const upb_def *d);
1757
+ const upb_filedef *upb_def_file(const upb_def *d);
1349
1758
  bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s);
1350
- bool upb_def_freeze(upb_def *const *defs, int n, upb_status *s);
1759
+ bool upb_def_freeze(upb_def *const *defs, size_t n, upb_status *s);
1760
+
1761
+ /* Temporary API: for internal use only. */
1762
+ bool _upb_def_validate(upb_def *const*defs, size_t n, upb_status *s);
1351
1763
 
1352
1764
  UPB_END_EXTERN_C
1353
1765
 
@@ -1420,7 +1832,6 @@ UPB_END_EXTERN_C
1420
1832
  UPB_DECLARE_DEF_TYPE(upb::FieldDef, fielddef, FIELD)
1421
1833
  UPB_DECLARE_DEF_TYPE(upb::MessageDef, msgdef, MSG)
1422
1834
  UPB_DECLARE_DEF_TYPE(upb::EnumDef, enumdef, ENUM)
1423
- UPB_DECLARE_DEF_TYPE(upb::OneofDef, oneofdef, ONEOF)
1424
1835
 
1425
1836
  #undef UPB_DECLARE_DEF_TYPE
1426
1837
  #undef UPB_DEF_CASTS
@@ -1483,6 +1894,11 @@ typedef enum {
1483
1894
  UPB_DESCRIPTOR_TYPE_SINT64 = 18
1484
1895
  } upb_descriptortype_t;
1485
1896
 
1897
+ typedef enum {
1898
+ UPB_SYNTAX_PROTO2 = 2,
1899
+ UPB_SYNTAX_PROTO3 = 3
1900
+ } upb_syntax_t;
1901
+
1486
1902
  /* Maximum field number allowed for FieldDefs. This is an inherent limit of the
1487
1903
  * protobuf wire format. */
1488
1904
  #define UPB_MAX_FIELDNUMBER ((1 << 29) - 1)
@@ -1537,6 +1953,27 @@ class upb::FieldDef {
1537
1953
  uint32_t number() const; /* Returns 0 if uninitialized. */
1538
1954
  bool is_extension() const;
1539
1955
 
1956
+ /* Copies the JSON name for this field into the given buffer. Returns the
1957
+ * actual size of the JSON name, including the NULL terminator. If the
1958
+ * return value is 0, the JSON name is unset. If the return value is
1959
+ * greater than len, the JSON name was truncated. The buffer is always
1960
+ * NULL-terminated if len > 0.
1961
+ *
1962
+ * The JSON name always defaults to a camelCased version of the regular
1963
+ * name. However if the regular name is unset, the JSON name will be unset
1964
+ * also.
1965
+ */
1966
+ size_t GetJsonName(char* buf, size_t len) const;
1967
+
1968
+ /* Convenience version of the above function which copies the JSON name
1969
+ * into the given string, returning false if the name is not set. */
1970
+ template <class T>
1971
+ bool GetJsonName(T* str) {
1972
+ str->resize(GetJsonName(NULL, 0));
1973
+ GetJsonName(&(*str)[0], str->size());
1974
+ return str->size() > 0;
1975
+ }
1976
+
1540
1977
  /* For UPB_TYPE_MESSAGE fields only where is_tag_delimited() == false,
1541
1978
  * indicates whether this field should have lazy parsing handlers that yield
1542
1979
  * the unparsed string for the submessage.
@@ -1557,7 +1994,7 @@ class upb::FieldDef {
1557
1994
  * whatever message this field belongs to. Guaranteed to be less than
1558
1995
  * f->containing_type()->field_count(). May only be accessed once the def has
1559
1996
  * been finalized. */
1560
- int index() const;
1997
+ uint32_t index() const;
1561
1998
 
1562
1999
  /* The MessageDef to which this field belongs.
1563
2000
  *
@@ -1589,6 +2026,18 @@ class upb::FieldDef {
1589
2026
  bool IsPrimitive() const;
1590
2027
  bool IsMap() const;
1591
2028
 
2029
+ /* Whether this field must be able to explicitly represent presence:
2030
+ *
2031
+ * * This is always false for repeated fields (an empty repeated field is
2032
+ * equivalent to a repeated field with zero entries).
2033
+ *
2034
+ * * This is always true for submessages.
2035
+ *
2036
+ * * For other fields, it depends on the message (see
2037
+ * MessageDef::SetPrimitivesHavePresence())
2038
+ */
2039
+ bool HasPresence() const;
2040
+
1592
2041
  /* How integers are encoded. Only meaningful for integer types.
1593
2042
  * Defaults to UPB_INTFMT_VARIABLE, and is reset when "type" changes. */
1594
2043
  IntegerFormat integer_format() const;
@@ -1690,6 +2139,16 @@ class upb::FieldDef {
1690
2139
  bool set_name(const char* name, upb::Status* s);
1691
2140
  bool set_name(const std::string& name, upb::Status* s);
1692
2141
 
2142
+ /* Sets the JSON name to the given string. */
2143
+ /* TODO(haberman): implement. Right now only default json_name (camelCase)
2144
+ * is supported. */
2145
+ bool set_json_name(const char* json_name, upb::Status* s);
2146
+ bool set_json_name(const std::string& name, upb::Status* s);
2147
+
2148
+ /* Clears the JSON name. This will make it revert to its default, which is
2149
+ * a camelCased version of the regular field name. */
2150
+ void clear_json_name();
2151
+
1693
2152
  void set_integer_format(IntegerFormat format);
1694
2153
  bool set_tag_delimited(bool tag_delimited, upb::Status* s);
1695
2154
 
@@ -1754,6 +2213,7 @@ const char *upb_fielddef_name(const upb_fielddef *f);
1754
2213
  bool upb_fielddef_isextension(const upb_fielddef *f);
1755
2214
  bool upb_fielddef_lazy(const upb_fielddef *f);
1756
2215
  bool upb_fielddef_packed(const upb_fielddef *f);
2216
+ size_t upb_fielddef_getjsonname(const upb_fielddef *f, char *buf, size_t len);
1757
2217
  const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f);
1758
2218
  const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f);
1759
2219
  upb_msgdef *upb_fielddef_containingtype_mutable(upb_fielddef *f);
@@ -1766,6 +2226,7 @@ bool upb_fielddef_isstring(const upb_fielddef *f);
1766
2226
  bool upb_fielddef_isseq(const upb_fielddef *f);
1767
2227
  bool upb_fielddef_isprimitive(const upb_fielddef *f);
1768
2228
  bool upb_fielddef_ismap(const upb_fielddef *f);
2229
+ bool upb_fielddef_haspresence(const upb_fielddef *f);
1769
2230
  int64_t upb_fielddef_defaultint64(const upb_fielddef *f);
1770
2231
  int32_t upb_fielddef_defaultint32(const upb_fielddef *f);
1771
2232
  uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f);
@@ -1787,6 +2248,8 @@ void upb_fielddef_setdescriptortype(upb_fielddef *f, int type);
1787
2248
  void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label);
1788
2249
  bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s);
1789
2250
  bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s);
2251
+ bool upb_fielddef_setjsonname(upb_fielddef *f, const char *name, upb_status *s);
2252
+ bool upb_fielddef_clearjsonname(upb_fielddef *f);
1790
2253
  bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name,
1791
2254
  upb_status *s);
1792
2255
  void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension);
@@ -1827,6 +2290,10 @@ UPB_END_EXTERN_C
1827
2290
  typedef upb_inttable_iter upb_msg_field_iter;
1828
2291
  typedef upb_strtable_iter upb_msg_oneof_iter;
1829
2292
 
2293
+ /* Well-known field tag numbers for map-entry messages. */
2294
+ #define UPB_MAPENTRY_KEY 1
2295
+ #define UPB_MAPENTRY_VALUE 2
2296
+
1830
2297
  #ifdef __cplusplus
1831
2298
 
1832
2299
  /* Structure that describes a single .proto message type.
@@ -1842,6 +2309,7 @@ class upb::MessageDef {
1842
2309
 
1843
2310
  /* Functionality from upb::Def. */
1844
2311
  const char* full_name() const;
2312
+ const char* name() const;
1845
2313
  bool set_full_name(const char* fullname, Status* s);
1846
2314
  bool set_full_name(const std::string& fullname, Status* s);
1847
2315
 
@@ -1884,6 +2352,16 @@ class upb::MessageDef {
1884
2352
  bool AddOneof(OneofDef* o, Status* s);
1885
2353
  bool AddOneof(const reffed_ptr<OneofDef>& o, Status* s);
1886
2354
 
2355
+ upb_syntax_t syntax() const;
2356
+
2357
+ /* Returns false if we don't support this syntax value. */
2358
+ bool set_syntax(upb_syntax_t syntax);
2359
+
2360
+ /* Set this to false to indicate that primitive fields should not have
2361
+ * explicit presence information associated with them. This will affect all
2362
+ * fields added to this message. Defaults to true. */
2363
+ void SetPrimitivesHavePresence(bool have_presence);
2364
+
1887
2365
  /* These return NULL if the field is not found. */
1888
2366
  FieldDef* FindFieldByNumber(uint32_t number);
1889
2367
  FieldDef* FindFieldByName(const char *name, size_t len);
@@ -2069,14 +2547,20 @@ UPB_REFCOUNTED_CMETHODS(upb_msgdef, upb_msgdef_upcast2)
2069
2547
 
2070
2548
  bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status);
2071
2549
 
2550
+ upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner);
2072
2551
  const char *upb_msgdef_fullname(const upb_msgdef *m);
2073
- bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname, upb_status *s);
2552
+ const char *upb_msgdef_name(const upb_msgdef *m);
2553
+ int upb_msgdef_numoneofs(const upb_msgdef *m);
2554
+ upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m);
2074
2555
 
2075
- upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner);
2076
2556
  bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor,
2077
2557
  upb_status *s);
2078
2558
  bool upb_msgdef_addoneof(upb_msgdef *m, upb_oneofdef *o, const void *ref_donor,
2079
2559
  upb_status *s);
2560
+ bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname, upb_status *s);
2561
+ void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry);
2562
+ bool upb_msgdef_mapentry(const upb_msgdef *m);
2563
+ bool upb_msgdef_setsyntax(upb_msgdef *m, upb_syntax_t syntax);
2080
2564
 
2081
2565
  /* Field lookup in a couple of different variations:
2082
2566
  * - itof = int to field
@@ -2118,18 +2602,21 @@ UPB_INLINE upb_oneofdef *upb_msgdef_ntoo_mutable(upb_msgdef *m,
2118
2602
  return (upb_oneofdef *)upb_msgdef_ntoo(m, name, len);
2119
2603
  }
2120
2604
 
2121
- void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry);
2122
- bool upb_msgdef_mapentry(const upb_msgdef *m);
2123
-
2124
- /* Well-known field tag numbers for map-entry messages. */
2125
- #define UPB_MAPENTRY_KEY 1
2126
- #define UPB_MAPENTRY_VALUE 2
2605
+ /* Lookup of either field or oneof by name. Returns whether either was found.
2606
+ * If the return is true, then the found def will be set, and the non-found
2607
+ * one set to NULL. */
2608
+ bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len,
2609
+ const upb_fielddef **f, const upb_oneofdef **o);
2127
2610
 
2128
- const upb_oneofdef *upb_msgdef_findoneof(const upb_msgdef *m,
2129
- const char *name);
2130
- int upb_msgdef_numoneofs(const upb_msgdef *m);
2611
+ UPB_INLINE bool upb_msgdef_lookupnamez(const upb_msgdef *m, const char *name,
2612
+ const upb_fielddef **f,
2613
+ const upb_oneofdef **o) {
2614
+ return upb_msgdef_lookupname(m, name, strlen(name), f, o);
2615
+ }
2131
2616
 
2132
- /* upb_msg_field_iter i;
2617
+ /* Iteration over fields and oneofs. For example:
2618
+ *
2619
+ * upb_msg_field_iter i;
2133
2620
  * for(upb_msg_field_begin(&i, m);
2134
2621
  * !upb_msg_field_done(&i);
2135
2622
  * upb_msg_field_next(&i)) {
@@ -2175,6 +2662,7 @@ class upb::EnumDef {
2175
2662
 
2176
2663
  /* Functionality from upb::Def. */
2177
2664
  const char* full_name() const;
2665
+ const char* name() const;
2178
2666
  bool set_full_name(const char* fullname, Status* s);
2179
2667
  bool set_full_name(const std::string& fullname, Status* s);
2180
2668
 
@@ -2249,6 +2737,7 @@ bool upb_enumdef_freeze(upb_enumdef *e, upb_status *status);
2249
2737
 
2250
2738
  /* From upb_def. */
2251
2739
  const char *upb_enumdef_fullname(const upb_enumdef *e);
2740
+ const char *upb_enumdef_name(const upb_enumdef *e);
2252
2741
  bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname,
2253
2742
  upb_status *s);
2254
2743
 
@@ -2290,8 +2779,7 @@ typedef upb_inttable_iter upb_oneof_iter;
2290
2779
 
2291
2780
  #ifdef __cplusplus
2292
2781
 
2293
- /* Class that represents a oneof. Its base class is upb::Def (convert with
2294
- * upb::upcast()). */
2782
+ /* Class that represents a oneof. */
2295
2783
  class upb::OneofDef {
2296
2784
  public:
2297
2785
  /* Returns NULL if memory allocation failed. */
@@ -2300,9 +2788,6 @@ class upb::OneofDef {
2300
2788
  /* upb::RefCounted methods like Ref()/Unref(). */
2301
2789
  UPB_REFCOUNTED_CPPMETHODS
2302
2790
 
2303
- /* Functionality from upb::Def. */
2304
- const char* full_name() const;
2305
-
2306
2791
  /* Returns the MessageDef that owns this OneofDef. */
2307
2792
  const MessageDef* containing_type() const;
2308
2793
 
@@ -2310,6 +2795,7 @@ class upb::OneofDef {
2310
2795
  * by name once added to a message def. */
2311
2796
  const char* name() const;
2312
2797
  bool set_name(const char* name, Status* s);
2798
+ bool set_name(const std::string& name, Status* s);
2313
2799
 
2314
2800
  /* Returns the number of fields currently defined in the oneof. */
2315
2801
  int field_count() const;
@@ -2403,7 +2889,7 @@ upb_oneofdef *upb_oneofdef_new(const void *owner);
2403
2889
  upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner);
2404
2890
 
2405
2891
  /* Include upb_refcounted methods like upb_oneofdef_ref(). */
2406
- UPB_REFCOUNTED_CMETHODS(upb_oneofdef, upb_oneofdef_upcast2)
2892
+ UPB_REFCOUNTED_CMETHODS(upb_oneofdef, upb_oneofdef_upcast)
2407
2893
 
2408
2894
  const char *upb_oneofdef_name(const upb_oneofdef *o);
2409
2895
  bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s);
@@ -2439,6 +2925,120 @@ void upb_oneof_iter_setdone(upb_oneof_iter *iter);
2439
2925
 
2440
2926
  UPB_END_EXTERN_C
2441
2927
 
2928
+
2929
+ /* upb::FileDef ***************************************************************/
2930
+
2931
+ #ifdef __cplusplus
2932
+
2933
+ /* Class that represents a .proto file with some things defined in it.
2934
+ *
2935
+ * Many users won't care about FileDefs, but they are necessary if you want to
2936
+ * read the values of file-level options. */
2937
+ class upb::FileDef {
2938
+ public:
2939
+ /* Returns NULL if memory allocation failed. */
2940
+ static reffed_ptr<FileDef> New();
2941
+
2942
+ /* upb::RefCounted methods like Ref()/Unref(). */
2943
+ UPB_REFCOUNTED_CPPMETHODS
2944
+
2945
+ /* Get/set name of the file (eg. "foo/bar.proto"). */
2946
+ const char* name() const;
2947
+ bool set_name(const char* name, Status* s);
2948
+ bool set_name(const std::string& name, Status* s);
2949
+
2950
+ /* Package name for definitions inside the file (eg. "foo.bar"). */
2951
+ const char* package() const;
2952
+ bool set_package(const char* package, Status* s);
2953
+
2954
+ /* Syntax for the file. Defaults to proto2. */
2955
+ upb_syntax_t syntax() const;
2956
+ void set_syntax(upb_syntax_t syntax);
2957
+
2958
+ /* Get the list of defs from the file. These are returned in the order that
2959
+ * they were added to the FileDef. */
2960
+ int def_count() const;
2961
+ const Def* def(int index) const;
2962
+ Def* def(int index);
2963
+
2964
+ /* Get the list of dependencies from the file. These are returned in the
2965
+ * order that they were added to the FileDef. */
2966
+ int dependency_count() const;
2967
+ const FileDef* dependency(int index) const;
2968
+
2969
+ /* Adds defs to this file. The def must not already belong to another
2970
+ * file.
2971
+ *
2972
+ * Note: this does *not* ensure that this def's name is unique in this file!
2973
+ * Use a SymbolTable if you want to check this property. Especially since
2974
+ * properly checking uniqueness would require a check across *all* files
2975
+ * (including dependencies). */
2976
+ bool AddDef(Def* def, Status* s);
2977
+ bool AddMessage(MessageDef* m, Status* s);
2978
+ bool AddEnum(EnumDef* e, Status* s);
2979
+ bool AddExtension(FieldDef* f, Status* s);
2980
+
2981
+ /* Adds a dependency of this file. */
2982
+ bool AddDependency(const FileDef* file);
2983
+
2984
+ /* Freezes this FileDef and all messages/enums under it. All subdefs must be
2985
+ * resolved and all messages/enums must validate. Returns true if this
2986
+ * succeeded.
2987
+ *
2988
+ * TODO(haberman): should we care whether the file's dependencies are frozen
2989
+ * already? */
2990
+ bool Freeze(Status* s);
2991
+
2992
+ private:
2993
+ UPB_DISALLOW_POD_OPS(FileDef, upb::FileDef)
2994
+ };
2995
+
2996
+ #endif
2997
+
2998
+ UPB_BEGIN_EXTERN_C
2999
+
3000
+ upb_filedef *upb_filedef_new(const void *owner);
3001
+
3002
+ /* Include upb_refcounted methods like upb_msgdef_ref(). */
3003
+ UPB_REFCOUNTED_CMETHODS(upb_filedef, upb_filedef_upcast)
3004
+
3005
+ const char *upb_filedef_name(const upb_filedef *f);
3006
+ const char *upb_filedef_package(const upb_filedef *f);
3007
+ upb_syntax_t upb_filedef_syntax(const upb_filedef *f);
3008
+ size_t upb_filedef_defcount(const upb_filedef *f);
3009
+ size_t upb_filedef_depcount(const upb_filedef *f);
3010
+ const upb_def *upb_filedef_def(const upb_filedef *f, size_t i);
3011
+ const upb_filedef *upb_filedef_dep(const upb_filedef *f, size_t i);
3012
+
3013
+ bool upb_filedef_freeze(upb_filedef *f, upb_status *s);
3014
+ bool upb_filedef_setname(upb_filedef *f, const char *name, upb_status *s);
3015
+ bool upb_filedef_setpackage(upb_filedef *f, const char *package, upb_status *s);
3016
+ bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax, upb_status *s);
3017
+
3018
+ bool upb_filedef_adddef(upb_filedef *f, upb_def *def, const void *ref_donor,
3019
+ upb_status *s);
3020
+ bool upb_filedef_adddep(upb_filedef *f, const upb_filedef *dep);
3021
+
3022
+ UPB_INLINE bool upb_filedef_addmsg(upb_filedef *f, upb_msgdef *m,
3023
+ const void *ref_donor, upb_status *s) {
3024
+ return upb_filedef_adddef(f, upb_msgdef_upcast_mutable(m), ref_donor, s);
3025
+ }
3026
+
3027
+ UPB_INLINE bool upb_filedef_addenum(upb_filedef *f, upb_enumdef *e,
3028
+ const void *ref_donor, upb_status *s) {
3029
+ return upb_filedef_adddef(f, upb_enumdef_upcast_mutable(e), ref_donor, s);
3030
+ }
3031
+
3032
+ UPB_INLINE bool upb_filedef_addext(upb_filedef *file, upb_fielddef *f,
3033
+ const void *ref_donor, upb_status *s) {
3034
+ return upb_filedef_adddef(file, upb_fielddef_upcast_mutable(f), ref_donor, s);
3035
+ }
3036
+ UPB_INLINE upb_def *upb_filedef_mutabledef(upb_filedef *f, int i) {
3037
+ return (upb_def*)upb_filedef_def(f, i);
3038
+ }
3039
+
3040
+ UPB_END_EXTERN_C
3041
+
2442
3042
  #ifdef __cplusplus
2443
3043
 
2444
3044
  UPB_INLINE const char* upb_safecstr(const std::string& str) {
@@ -2454,13 +3054,14 @@ inline Def* Def::Dup(const void* owner) const {
2454
3054
  }
2455
3055
  inline Def::Type Def::def_type() const { return upb_def_type(this); }
2456
3056
  inline const char* Def::full_name() const { return upb_def_fullname(this); }
3057
+ inline const char* Def::name() const { return upb_def_name(this); }
2457
3058
  inline bool Def::set_full_name(const char* fullname, Status* s) {
2458
3059
  return upb_def_setfullname(this, fullname, s);
2459
3060
  }
2460
3061
  inline bool Def::set_full_name(const std::string& fullname, Status* s) {
2461
3062
  return upb_def_setfullname(this, upb_safecstr(fullname), s);
2462
3063
  }
2463
- inline bool Def::Freeze(Def* const* defs, int n, Status* status) {
3064
+ inline bool Def::Freeze(Def* const* defs, size_t n, Status* status) {
2464
3065
  return upb_def_freeze(defs, n, status);
2465
3066
  }
2466
3067
  inline bool Def::Freeze(const std::vector<Def*>& defs, Status* status) {
@@ -2527,6 +3128,9 @@ inline const char* FieldDef::name() const { return upb_fielddef_name(this); }
2527
3128
  inline bool FieldDef::is_extension() const {
2528
3129
  return upb_fielddef_isextension(this);
2529
3130
  }
3131
+ inline size_t FieldDef::GetJsonName(char* buf, size_t len) const {
3132
+ return upb_fielddef_getjsonname(this, buf, len);
3133
+ }
2530
3134
  inline bool FieldDef::lazy() const {
2531
3135
  return upb_fielddef_lazy(this);
2532
3136
  }
@@ -2536,6 +3140,9 @@ inline void FieldDef::set_lazy(bool lazy) {
2536
3140
  inline bool FieldDef::packed() const {
2537
3141
  return upb_fielddef_packed(this);
2538
3142
  }
3143
+ inline uint32_t FieldDef::index() const {
3144
+ return upb_fielddef_index(this);
3145
+ }
2539
3146
  inline void FieldDef::set_packed(bool packed) {
2540
3147
  upb_fielddef_setpacked(this, packed);
2541
3148
  }
@@ -2557,6 +3164,15 @@ inline bool FieldDef::set_name(const char *name, Status* s) {
2557
3164
  inline bool FieldDef::set_name(const std::string& name, Status* s) {
2558
3165
  return upb_fielddef_setname(this, upb_safecstr(name), s);
2559
3166
  }
3167
+ inline bool FieldDef::set_json_name(const char *name, Status* s) {
3168
+ return upb_fielddef_setjsonname(this, name, s);
3169
+ }
3170
+ inline bool FieldDef::set_json_name(const std::string& name, Status* s) {
3171
+ return upb_fielddef_setjsonname(this, upb_safecstr(name), s);
3172
+ }
3173
+ inline void FieldDef::clear_json_name() {
3174
+ upb_fielddef_clearjsonname(this);
3175
+ }
2560
3176
  inline bool FieldDef::set_containing_type_name(const char *name, Status* s) {
2561
3177
  return upb_fielddef_setcontainingtypename(this, name, s);
2562
3178
  }
@@ -2671,12 +3287,21 @@ inline reffed_ptr<MessageDef> MessageDef::New() {
2671
3287
  inline const char *MessageDef::full_name() const {
2672
3288
  return upb_msgdef_fullname(this);
2673
3289
  }
3290
+ inline const char *MessageDef::name() const {
3291
+ return upb_msgdef_name(this);
3292
+ }
3293
+ inline upb_syntax_t MessageDef::syntax() const {
3294
+ return upb_msgdef_syntax(this);
3295
+ }
2674
3296
  inline bool MessageDef::set_full_name(const char* fullname, Status* s) {
2675
3297
  return upb_msgdef_setfullname(this, fullname, s);
2676
3298
  }
2677
3299
  inline bool MessageDef::set_full_name(const std::string& fullname, Status* s) {
2678
3300
  return upb_msgdef_setfullname(this, upb_safecstr(fullname), s);
2679
3301
  }
3302
+ inline bool MessageDef::set_syntax(upb_syntax_t syntax) {
3303
+ return upb_msgdef_setsyntax(this, syntax);
3304
+ }
2680
3305
  inline bool MessageDef::Freeze(Status* status) {
2681
3306
  return upb_msgdef_freeze(this, status);
2682
3307
  }
@@ -2858,6 +3483,9 @@ inline reffed_ptr<EnumDef> EnumDef::New() {
2858
3483
  inline const char* EnumDef::full_name() const {
2859
3484
  return upb_enumdef_fullname(this);
2860
3485
  }
3486
+ inline const char* EnumDef::name() const {
3487
+ return upb_enumdef_name(this);
3488
+ }
2861
3489
  inline bool EnumDef::set_full_name(const char* fullname, Status* s) {
2862
3490
  return upb_enumdef_setfullname(this, fullname, s);
2863
3491
  }
@@ -2907,9 +3535,6 @@ inline reffed_ptr<OneofDef> OneofDef::New() {
2907
3535
  upb_oneofdef *o = upb_oneofdef_new(&o);
2908
3536
  return reffed_ptr<OneofDef>(o, &o);
2909
3537
  }
2910
- inline const char* OneofDef::full_name() const {
2911
- return upb_oneofdef_name(this);
2912
- }
2913
3538
 
2914
3539
  inline const MessageDef* OneofDef::containing_type() const {
2915
3540
  return upb_oneofdef_containingtype(this);
@@ -2920,6 +3545,9 @@ inline const char* OneofDef::name() const {
2920
3545
  inline bool OneofDef::set_name(const char* name, Status* s) {
2921
3546
  return upb_oneofdef_setname(this, name, s);
2922
3547
  }
3548
+ inline bool OneofDef::set_name(const std::string& name, Status* s) {
3549
+ return upb_oneofdef_setname(this, upb_safecstr(name), s);
3550
+ }
2923
3551
  inline int OneofDef::field_count() const {
2924
3552
  return upb_oneofdef_numfields(this);
2925
3553
  }
@@ -2983,9 +3611,60 @@ inline bool OneofDef::const_iterator::operator==(
2983
3611
  const const_iterator &other) const {
2984
3612
  return upb_inttable_iter_isequal(&iter_, &other.iter_);
2985
3613
  }
2986
- inline bool OneofDef::const_iterator::operator!=(
2987
- const const_iterator &other) const {
2988
- return !(*this == other);
3614
+ inline bool OneofDef::const_iterator::operator!=(
3615
+ const const_iterator &other) const {
3616
+ return !(*this == other);
3617
+ }
3618
+
3619
+ inline reffed_ptr<FileDef> FileDef::New() {
3620
+ upb_filedef *f = upb_filedef_new(&f);
3621
+ return reffed_ptr<FileDef>(f, &f);
3622
+ }
3623
+
3624
+ inline const char* FileDef::name() const {
3625
+ return upb_filedef_name(this);
3626
+ }
3627
+ inline bool FileDef::set_name(const char* name, Status* s) {
3628
+ return upb_filedef_setname(this, name, s);
3629
+ }
3630
+ inline bool FileDef::set_name(const std::string& name, Status* s) {
3631
+ return upb_filedef_setname(this, upb_safecstr(name), s);
3632
+ }
3633
+ inline const char* FileDef::package() const {
3634
+ return upb_filedef_package(this);
3635
+ }
3636
+ inline bool FileDef::set_package(const char* package, Status* s) {
3637
+ return upb_filedef_setpackage(this, package, s);
3638
+ }
3639
+ inline int FileDef::def_count() const {
3640
+ return upb_filedef_defcount(this);
3641
+ }
3642
+ inline const Def* FileDef::def(int index) const {
3643
+ return upb_filedef_def(this, index);
3644
+ }
3645
+ inline Def* FileDef::def(int index) {
3646
+ return const_cast<Def*>(upb_filedef_def(this, index));
3647
+ }
3648
+ inline int FileDef::dependency_count() const {
3649
+ return upb_filedef_depcount(this);
3650
+ }
3651
+ inline const FileDef* FileDef::dependency(int index) const {
3652
+ return upb_filedef_dep(this, index);
3653
+ }
3654
+ inline bool FileDef::AddDef(Def* def, Status* s) {
3655
+ return upb_filedef_adddef(this, def, NULL, s);
3656
+ }
3657
+ inline bool FileDef::AddMessage(MessageDef* m, Status* s) {
3658
+ return upb_filedef_addmsg(this, m, NULL, s);
3659
+ }
3660
+ inline bool FileDef::AddEnum(EnumDef* e, Status* s) {
3661
+ return upb_filedef_addenum(this, e, NULL, s);
3662
+ }
3663
+ inline bool FileDef::AddExtension(FieldDef* f, Status* s) {
3664
+ return upb_filedef_addext(this, f, NULL, s);
3665
+ }
3666
+ inline bool FileDef::AddDependency(const FileDef* file) {
3667
+ return upb_filedef_adddep(this, file);
2989
3668
  }
2990
3669
 
2991
3670
  } /* namespace upb */
@@ -3026,6 +3705,7 @@ struct upb_def {
3026
3705
  upb_refcounted base;
3027
3706
 
3028
3707
  const char *fullname;
3708
+ const upb_filedef* file;
3029
3709
  char type; /* A upb_deftype_t (char to save space) */
3030
3710
 
3031
3711
  /* Used as a flag during the def's mutable stage. Must be false unless
@@ -3035,8 +3715,8 @@ struct upb_def {
3035
3715
  bool came_from_user;
3036
3716
  };
3037
3717
 
3038
- #define UPB_DEF_INIT(name, type, refs, ref2s) \
3039
- { UPB_REFCOUNT_INIT(refs, ref2s), name, type, false }
3718
+ #define UPB_DEF_INIT(name, type, vtbl, refs, ref2s) \
3719
+ { UPB_REFCOUNT_INIT(vtbl, refs, ref2s), name, NULL, type, false }
3040
3720
 
3041
3721
 
3042
3722
  /* upb_fielddef ***************************************************************/
@@ -3076,12 +3756,14 @@ struct upb_fielddef {
3076
3756
  uint32_t index_;
3077
3757
  };
3078
3758
 
3759
+ extern const struct upb_refcounted_vtbl upb_fielddef_vtbl;
3760
+
3079
3761
  #define UPB_FIELDDEF_INIT(label, type, intfmt, tagdelim, is_extension, lazy, \
3080
3762
  packed, name, num, msgdef, subdef, selector_base, \
3081
3763
  index, defaultval, refs, ref2s) \
3082
3764
  { \
3083
- UPB_DEF_INIT(name, UPB_DEF_FIELD, refs, ref2s), defaultval, {msgdef}, \
3084
- {subdef}, NULL, false, false, \
3765
+ UPB_DEF_INIT(name, UPB_DEF_FIELD, &upb_fielddef_vtbl, refs, ref2s), \
3766
+ defaultval, {msgdef}, {subdef}, NULL, false, false, \
3085
3767
  type == UPB_TYPE_STRING || type == UPB_TYPE_BYTES, true, is_extension, \
3086
3768
  lazy, packed, intfmt, tagdelim, type, label, num, selector_base, index \
3087
3769
  }
@@ -3097,27 +3779,26 @@ struct upb_msgdef {
3097
3779
 
3098
3780
  /* Tables for looking up fields by number and name. */
3099
3781
  upb_inttable itof; /* int to field */
3100
- upb_strtable ntof; /* name to field */
3101
-
3102
- /* Tables for looking up oneofs by name. */
3103
- upb_strtable ntoo; /* name to oneof */
3782
+ upb_strtable ntof; /* name to field/oneof */
3104
3783
 
3105
- /* Is this a map-entry message?
3106
- * TODO: set this flag properly for static descriptors; regenerate
3107
- * descriptor.upb.c. */
3784
+ /* Is this a map-entry message? */
3108
3785
  bool map_entry;
3109
3786
 
3787
+ /* Whether this message has proto2 or proto3 semantics. */
3788
+ upb_syntax_t syntax;
3789
+
3110
3790
  /* TODO(haberman): proper extension ranges (there can be multiple). */
3111
3791
  };
3112
3792
 
3793
+ extern const struct upb_refcounted_vtbl upb_msgdef_vtbl;
3794
+
3113
3795
  /* TODO: also support static initialization of the oneofs table. This will be
3114
3796
  * needed if we compile in descriptors that contain oneofs. */
3115
3797
  #define UPB_MSGDEF_INIT(name, selector_count, submsg_field_count, itof, ntof, \
3116
- refs, ref2s) \
3798
+ map_entry, syntax, refs, ref2s) \
3117
3799
  { \
3118
- UPB_DEF_INIT(name, UPB_DEF_MSG, refs, ref2s), selector_count, \
3119
- submsg_field_count, itof, ntof, \
3120
- UPB_EMPTY_STRTABLE_INIT(UPB_CTYPE_PTR), false \
3800
+ UPB_DEF_INIT(name, UPB_DEF_MSG, &upb_fielddef_vtbl, refs, ref2s), \
3801
+ selector_count, submsg_field_count, itof, ntof, map_entry, syntax \
3121
3802
  }
3122
3803
 
3123
3804
 
@@ -3131,22 +3812,28 @@ struct upb_enumdef {
3131
3812
  int32_t defaultval;
3132
3813
  };
3133
3814
 
3815
+ extern const struct upb_refcounted_vtbl upb_enumdef_vtbl;
3816
+
3134
3817
  #define UPB_ENUMDEF_INIT(name, ntoi, iton, defaultval, refs, ref2s) \
3135
- { UPB_DEF_INIT(name, UPB_DEF_ENUM, refs, ref2s), ntoi, iton, defaultval }
3818
+ { UPB_DEF_INIT(name, UPB_DEF_ENUM, &upb_enumdef_vtbl, refs, ref2s), ntoi, \
3819
+ iton, defaultval }
3136
3820
 
3137
3821
 
3138
3822
  /* upb_oneofdef ***************************************************************/
3139
3823
 
3140
3824
  struct upb_oneofdef {
3141
- upb_def base;
3825
+ upb_refcounted base;
3142
3826
 
3827
+ const char *name;
3143
3828
  upb_strtable ntof;
3144
3829
  upb_inttable itof;
3145
3830
  const upb_msgdef *parent;
3146
3831
  };
3147
3832
 
3833
+ extern const struct upb_refcounted_vtbl upb_oneofdef_vtbl;
3834
+
3148
3835
  #define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \
3149
- { UPB_DEF_INIT(name, UPB_DEF_ENUM, refs, ref2s), ntof, itof }
3836
+ { UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), name, ntof, itof }
3150
3837
 
3151
3838
 
3152
3839
  /* upb_symtab *****************************************************************/
@@ -3157,9 +3844,18 @@ struct upb_symtab {
3157
3844
  upb_strtable symtab;
3158
3845
  };
3159
3846
 
3160
- #define UPB_SYMTAB_INIT(symtab, refs, ref2s) \
3161
- { UPB_REFCOUNT_INIT(refs, ref2s), symtab }
3847
+ struct upb_filedef {
3848
+ upb_refcounted base;
3849
+
3850
+ const char *name;
3851
+ const char *package;
3852
+ upb_syntax_t syntax;
3853
+
3854
+ upb_inttable defs;
3855
+ upb_inttable deps;
3856
+ };
3162
3857
 
3858
+ extern const struct upb_refcounted_vtbl upb_filedef_vtbl;
3163
3859
 
3164
3860
  #endif /* UPB_STATICINIT_H_ */
3165
3861
  /*
@@ -5102,267 +5798,6 @@ inline BytesHandler::~BytesHandler() {}
5102
5798
 
5103
5799
  #endif /* UPB_HANDLERS_H */
5104
5800
  /*
5105
- ** upb::Environment (upb_env)
5106
- **
5107
- ** A upb::Environment provides a means for injecting malloc and an
5108
- ** error-reporting callback into encoders/decoders. This allows them to be
5109
- ** independent of nearly all assumptions about their actual environment.
5110
- **
5111
- ** It is also a container for allocating the encoders/decoders themselves that
5112
- ** insulates clients from knowing their actual size. This provides ABI
5113
- ** compatibility even if the size of the objects change. And this allows the
5114
- ** structure definitions to be in the .c files instead of the .h files, making
5115
- ** the .h files smaller and more readable.
5116
- */
5117
-
5118
-
5119
- #ifndef UPB_ENV_H_
5120
- #define UPB_ENV_H_
5121
-
5122
- #ifdef __cplusplus
5123
- namespace upb {
5124
- class Environment;
5125
- class SeededAllocator;
5126
- }
5127
- #endif
5128
-
5129
- UPB_DECLARE_TYPE(upb::Environment, upb_env)
5130
- UPB_DECLARE_TYPE(upb::SeededAllocator, upb_seededalloc)
5131
-
5132
- typedef void *upb_alloc_func(void *ud, void *ptr, size_t oldsize, size_t size);
5133
- typedef void upb_cleanup_func(void *ud);
5134
- typedef bool upb_error_func(void *ud, const upb_status *status);
5135
-
5136
- #ifdef __cplusplus
5137
-
5138
- /* An environment is *not* thread-safe. */
5139
- class upb::Environment {
5140
- public:
5141
- Environment();
5142
- ~Environment();
5143
-
5144
- /* Set a custom memory allocation function for the environment. May ONLY
5145
- * be called before any calls to Malloc()/Realloc()/AddCleanup() below.
5146
- * If this is not called, the system realloc() function will be used.
5147
- * The given user pointer "ud" will be passed to the allocation function.
5148
- *
5149
- * The allocation function will not receive corresponding "free" calls. it
5150
- * must ensure that the memory is valid for the lifetime of the Environment,
5151
- * but it may be reclaimed any time thereafter. The likely usage is that
5152
- * "ud" points to a stateful allocator, and that the allocator frees all
5153
- * memory, arena-style, when it is destroyed. In this case the allocator must
5154
- * outlive the Environment. Another possibility is that the allocation
5155
- * function returns GC-able memory that is guaranteed to be GC-rooted for the
5156
- * life of the Environment. */
5157
- void SetAllocationFunction(upb_alloc_func* alloc, void* ud);
5158
-
5159
- template<class T>
5160
- void SetAllocator(T* allocator) {
5161
- SetAllocationFunction(allocator->GetAllocationFunction(), allocator);
5162
- }
5163
-
5164
- /* Set a custom error reporting function. */
5165
- void SetErrorFunction(upb_error_func* func, void* ud);
5166
-
5167
- /* Set the error reporting function to simply copy the status to the given
5168
- * status and abort. */
5169
- void ReportErrorsTo(Status* status);
5170
-
5171
- /* Returns true if all allocations and AddCleanup() calls have succeeded,
5172
- * and no errors were reported with ReportError() (except ones that recovered
5173
- * successfully). */
5174
- bool ok() const;
5175
-
5176
- /* Functions for use by encoders/decoders. **********************************/
5177
-
5178
- /* Reports an error to this environment's callback, returning true if
5179
- * the caller should try to recover. */
5180
- bool ReportError(const Status* status);
5181
-
5182
- /* Allocate memory. Uses the environment's allocation function.
5183
- *
5184
- * There is no need to free(). All memory will be freed automatically, but is
5185
- * guaranteed to outlive the Environment. */
5186
- void* Malloc(size_t size);
5187
-
5188
- /* Reallocate memory. Preserves "oldsize" bytes from the existing buffer
5189
- * Requires: oldsize <= existing_size.
5190
- *
5191
- * TODO(haberman): should we also enforce that oldsize <= size? */
5192
- void* Realloc(void* ptr, size_t oldsize, size_t size);
5193
-
5194
- /* Add a cleanup function to run when the environment is destroyed.
5195
- * Returns false on out-of-memory.
5196
- *
5197
- * The first call to AddCleanup() after SetAllocationFunction() is guaranteed
5198
- * to return true -- this makes it possible to robustly set a cleanup handler
5199
- * for a custom allocation function. */
5200
- bool AddCleanup(upb_cleanup_func* func, void* ud);
5201
-
5202
- /* Total number of bytes that have been allocated. It is undefined what
5203
- * Realloc() does to this counter. */
5204
- size_t BytesAllocated() const;
5205
-
5206
- private:
5207
- UPB_DISALLOW_COPY_AND_ASSIGN(Environment)
5208
-
5209
- #else
5210
- struct upb_env {
5211
- #endif /* __cplusplus */
5212
-
5213
- bool ok_;
5214
- size_t bytes_allocated;
5215
-
5216
- /* Alloc function. */
5217
- upb_alloc_func *alloc;
5218
- void *alloc_ud;
5219
-
5220
- /* Error-reporting function. */
5221
- upb_error_func *err;
5222
- void *err_ud;
5223
-
5224
- /* Userdata for default alloc func. */
5225
- void *default_alloc_ud;
5226
-
5227
- /* Cleanup entries. Pointer to a cleanup_ent, defined in env.c */
5228
- void *cleanup_head;
5229
-
5230
- /* For future expansion, since the size of this struct is exposed to users. */
5231
- void *future1;
5232
- void *future2;
5233
- };
5234
-
5235
- UPB_BEGIN_EXTERN_C
5236
-
5237
- void upb_env_init(upb_env *e);
5238
- void upb_env_uninit(upb_env *e);
5239
- void upb_env_setallocfunc(upb_env *e, upb_alloc_func *func, void *ud);
5240
- void upb_env_seterrorfunc(upb_env *e, upb_error_func *func, void *ud);
5241
- void upb_env_reporterrorsto(upb_env *e, upb_status *status);
5242
- bool upb_env_ok(const upb_env *e);
5243
- bool upb_env_reporterror(upb_env *e, const upb_status *status);
5244
- void *upb_env_malloc(upb_env *e, size_t size);
5245
- void *upb_env_realloc(upb_env *e, void *ptr, size_t oldsize, size_t size);
5246
- bool upb_env_addcleanup(upb_env *e, upb_cleanup_func *func, void *ud);
5247
- size_t upb_env_bytesallocated(const upb_env *e);
5248
-
5249
- UPB_END_EXTERN_C
5250
-
5251
- #ifdef __cplusplus
5252
-
5253
- /* An allocator that allocates from an initial memory region (likely the stack)
5254
- * before falling back to another allocator. */
5255
- class upb::SeededAllocator {
5256
- public:
5257
- SeededAllocator(void *mem, size_t len);
5258
- ~SeededAllocator();
5259
-
5260
- /* Set a custom fallback memory allocation function for the allocator, to use
5261
- * once the initial region runs out.
5262
- *
5263
- * May ONLY be called before GetAllocationFunction(). If this is not
5264
- * called, the system realloc() will be the fallback allocator. */
5265
- void SetFallbackAllocator(upb_alloc_func *alloc, void *ud);
5266
-
5267
- /* Gets the allocation function for this allocator. */
5268
- upb_alloc_func* GetAllocationFunction();
5269
-
5270
- private:
5271
- UPB_DISALLOW_COPY_AND_ASSIGN(SeededAllocator)
5272
-
5273
- #else
5274
- struct upb_seededalloc {
5275
- #endif /* __cplusplus */
5276
-
5277
- /* Fallback alloc function. */
5278
- upb_alloc_func *alloc;
5279
- upb_cleanup_func *alloc_cleanup;
5280
- void *alloc_ud;
5281
- bool need_cleanup;
5282
- bool returned_allocfunc;
5283
-
5284
- /* Userdata for default alloc func. */
5285
- void *default_alloc_ud;
5286
-
5287
- /* Pointers for the initial memory region. */
5288
- char *mem_base;
5289
- char *mem_ptr;
5290
- char *mem_limit;
5291
-
5292
- /* For future expansion, since the size of this struct is exposed to users. */
5293
- void *future1;
5294
- void *future2;
5295
- };
5296
-
5297
- UPB_BEGIN_EXTERN_C
5298
-
5299
- void upb_seededalloc_init(upb_seededalloc *a, void *mem, size_t len);
5300
- void upb_seededalloc_uninit(upb_seededalloc *a);
5301
- void upb_seededalloc_setfallbackalloc(upb_seededalloc *a, upb_alloc_func *func,
5302
- void *ud);
5303
- upb_alloc_func *upb_seededalloc_getallocfunc(upb_seededalloc *a);
5304
-
5305
- UPB_END_EXTERN_C
5306
-
5307
- #ifdef __cplusplus
5308
-
5309
- namespace upb {
5310
-
5311
- inline Environment::Environment() {
5312
- upb_env_init(this);
5313
- }
5314
- inline Environment::~Environment() {
5315
- upb_env_uninit(this);
5316
- }
5317
- inline void Environment::SetAllocationFunction(upb_alloc_func *alloc,
5318
- void *ud) {
5319
- upb_env_setallocfunc(this, alloc, ud);
5320
- }
5321
- inline void Environment::SetErrorFunction(upb_error_func *func, void *ud) {
5322
- upb_env_seterrorfunc(this, func, ud);
5323
- }
5324
- inline void Environment::ReportErrorsTo(Status* status) {
5325
- upb_env_reporterrorsto(this, status);
5326
- }
5327
- inline bool Environment::ok() const {
5328
- return upb_env_ok(this);
5329
- }
5330
- inline bool Environment::ReportError(const Status* status) {
5331
- return upb_env_reporterror(this, status);
5332
- }
5333
- inline void *Environment::Malloc(size_t size) {
5334
- return upb_env_malloc(this, size);
5335
- }
5336
- inline void *Environment::Realloc(void *ptr, size_t oldsize, size_t size) {
5337
- return upb_env_realloc(this, ptr, oldsize, size);
5338
- }
5339
- inline bool Environment::AddCleanup(upb_cleanup_func *func, void *ud) {
5340
- return upb_env_addcleanup(this, func, ud);
5341
- }
5342
- inline size_t Environment::BytesAllocated() const {
5343
- return upb_env_bytesallocated(this);
5344
- }
5345
-
5346
- inline SeededAllocator::SeededAllocator(void *mem, size_t len) {
5347
- upb_seededalloc_init(this, mem, len);
5348
- }
5349
- inline SeededAllocator::~SeededAllocator() {
5350
- upb_seededalloc_uninit(this);
5351
- }
5352
- inline void SeededAllocator::SetFallbackAllocator(upb_alloc_func *alloc,
5353
- void *ud) {
5354
- upb_seededalloc_setfallbackalloc(this, alloc, ud);
5355
- }
5356
- inline upb_alloc_func *SeededAllocator::GetAllocationFunction() {
5357
- return upb_seededalloc_getallocfunc(this);
5358
- }
5359
-
5360
- } /* namespace upb */
5361
-
5362
- #endif /* __cplusplus */
5363
-
5364
- #endif /* UPB_ENV_H_ */
5365
- /*
5366
5801
  ** upb::Sink (upb_sink)
5367
5802
  ** upb::BytesSink (upb_bytessink)
5368
5803
  **
@@ -6066,12 +6501,17 @@ class upb::SymbolTable {
6066
6501
  * only a few messages are changing. We may want to add a way of adding a
6067
6502
  * tree of frozen defs to the symtab (perhaps an alternate constructor where
6068
6503
  * you pass the root of the tree?) */
6069
- bool Add(Def*const* defs, int n, void* ref_donor, upb_status* status);
6504
+ bool Add(Def*const* defs, size_t n, void* ref_donor, Status* status);
6070
6505
 
6071
6506
  bool Add(const std::vector<Def*>& defs, void *owner, Status* status) {
6072
6507
  return Add((Def*const*)&defs[0], defs.size(), owner, status);
6073
6508
  }
6074
6509
 
6510
+ /* Resolves all subdefs for messages in this file and attempts to freeze the
6511
+ * file. If this succeeds, adds all the symbols to this SymbolTable
6512
+ * (replacing any existing ones with the same names). */
6513
+ bool AddFile(FileDef* file, Status* s);
6514
+
6075
6515
  private:
6076
6516
  UPB_DISALLOW_POD_OPS(SymbolTable, upb::SymbolTable)
6077
6517
  };
@@ -6092,8 +6532,9 @@ const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
6092
6532
  const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym);
6093
6533
  const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
6094
6534
  const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
6095
- bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, int n, void *ref_donor,
6096
- upb_status *status);
6535
+ bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
6536
+ void *ref_donor, upb_status *status);
6537
+ bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status* status);
6097
6538
 
6098
6539
  /* upb_symtab_iter i;
6099
6540
  * for(upb_symtab_begin(&i, s, type); !upb_symtab_done(&i);
@@ -6135,9 +6576,12 @@ inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const {
6135
6576
  return upb_symtab_lookupmsg(this, sym);
6136
6577
  }
6137
6578
  inline bool SymbolTable::Add(
6138
- Def*const* defs, int n, void* ref_donor, upb_status* status) {
6579
+ Def*const* defs, size_t n, void* ref_donor, Status* status) {
6139
6580
  return upb_symtab_add(this, (upb_def*const*)defs, n, ref_donor, status);
6140
6581
  }
6582
+ inline bool SymbolTable::AddFile(FileDef* file, Status* s) {
6583
+ return upb_symtab_addfile(this, file, s);
6584
+ }
6141
6585
  } /* namespace upb */
6142
6586
  #endif
6143
6587
 
@@ -6181,14 +6625,9 @@ class upb::descriptor::Reader {
6181
6625
  /* The reader's input; this is where descriptor.proto data should be sent. */
6182
6626
  Sink* input();
6183
6627
 
6184
- /* Returns an array of all defs that have been parsed, and transfers ownership
6185
- * of them to "owner". The number of defs is stored in *n. Ownership of the
6186
- * returned array is retained and is invalidated by any other call into
6187
- * Reader.
6188
- *
6189
- * These defs are not frozen or resolved; they are ready to be added to a
6190
- * symtab. */
6191
- upb::Def** GetDefs(void* owner, int* n);
6628
+ /* Use to get the FileDefs that have been parsed. */
6629
+ size_t file_count() const;
6630
+ FileDef* file(size_t i) const;
6192
6631
 
6193
6632
  /* Builds and returns handlers for the reader, owned by "owner." */
6194
6633
  static Handlers* NewHandlers(const void* owner);
@@ -6197,832 +6636,690 @@ class upb::descriptor::Reader {
6197
6636
  UPB_DISALLOW_POD_OPS(Reader, upb::descriptor::Reader)
6198
6637
  };
6199
6638
 
6200
- #endif
6639
+ #endif
6640
+
6641
+ UPB_BEGIN_EXTERN_C
6642
+
6643
+ /* C API. */
6644
+ upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h);
6645
+ upb_sink *upb_descreader_input(upb_descreader *r);
6646
+ size_t upb_descreader_filecount(const upb_descreader *r);
6647
+ upb_filedef *upb_descreader_file(const upb_descreader *r, size_t i);
6648
+ const upb_handlers *upb_descreader_newhandlers(const void *owner);
6649
+
6650
+ UPB_END_EXTERN_C
6651
+
6652
+ #ifdef __cplusplus
6653
+ /* C++ implementation details. ************************************************/
6654
+ namespace upb {
6655
+ namespace descriptor {
6656
+ inline Reader* Reader::Create(Environment* e, const Handlers *h) {
6657
+ return upb_descreader_create(e, h);
6658
+ }
6659
+ inline Sink* Reader::input() { return upb_descreader_input(this); }
6660
+ inline size_t Reader::file_count() const {
6661
+ return upb_descreader_filecount(this);
6662
+ }
6663
+ inline FileDef* Reader::file(size_t i) const {
6664
+ return upb_descreader_file(this, i);
6665
+ }
6666
+ } /* namespace descriptor */
6667
+ } /* namespace upb */
6668
+ #endif
6669
+
6670
+ #endif /* UPB_DESCRIPTOR_H */
6671
+ /* This file contains accessors for a set of compiled-in defs.
6672
+ * Note that unlike Google's protobuf, it does *not* define
6673
+ * generated classes or any other kind of data structure for
6674
+ * actually storing protobufs. It only contains *defs* which
6675
+ * let you reflect over a protobuf *schema*.
6676
+ */
6677
+ /* This file was generated by upbc (the upb compiler) from the input
6678
+ * file:
6679
+ *
6680
+ * upb/descriptor/descriptor.proto
6681
+ *
6682
+ * Do not edit -- your changes will be discarded when the file is
6683
+ * regenerated. */
6684
+
6685
+ #ifndef UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_
6686
+ #define UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_
6687
+
6688
+
6689
+ UPB_BEGIN_EXTERN_C
6690
+
6691
+ /* Enums */
6692
+
6693
+ typedef enum {
6694
+ google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1,
6695
+ google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2,
6696
+ google_protobuf_FieldDescriptorProto_LABEL_REPEATED = 3
6697
+ } google_protobuf_FieldDescriptorProto_Label;
6698
+
6699
+ typedef enum {
6700
+ google_protobuf_FieldDescriptorProto_TYPE_DOUBLE = 1,
6701
+ google_protobuf_FieldDescriptorProto_TYPE_FLOAT = 2,
6702
+ google_protobuf_FieldDescriptorProto_TYPE_INT64 = 3,
6703
+ google_protobuf_FieldDescriptorProto_TYPE_UINT64 = 4,
6704
+ google_protobuf_FieldDescriptorProto_TYPE_INT32 = 5,
6705
+ google_protobuf_FieldDescriptorProto_TYPE_FIXED64 = 6,
6706
+ google_protobuf_FieldDescriptorProto_TYPE_FIXED32 = 7,
6707
+ google_protobuf_FieldDescriptorProto_TYPE_BOOL = 8,
6708
+ google_protobuf_FieldDescriptorProto_TYPE_STRING = 9,
6709
+ google_protobuf_FieldDescriptorProto_TYPE_GROUP = 10,
6710
+ google_protobuf_FieldDescriptorProto_TYPE_MESSAGE = 11,
6711
+ google_protobuf_FieldDescriptorProto_TYPE_BYTES = 12,
6712
+ google_protobuf_FieldDescriptorProto_TYPE_UINT32 = 13,
6713
+ google_protobuf_FieldDescriptorProto_TYPE_ENUM = 14,
6714
+ google_protobuf_FieldDescriptorProto_TYPE_SFIXED32 = 15,
6715
+ google_protobuf_FieldDescriptorProto_TYPE_SFIXED64 = 16,
6716
+ google_protobuf_FieldDescriptorProto_TYPE_SINT32 = 17,
6717
+ google_protobuf_FieldDescriptorProto_TYPE_SINT64 = 18
6718
+ } google_protobuf_FieldDescriptorProto_Type;
6719
+
6720
+ typedef enum {
6721
+ google_protobuf_FieldOptions_STRING = 0,
6722
+ google_protobuf_FieldOptions_CORD = 1,
6723
+ google_protobuf_FieldOptions_STRING_PIECE = 2
6724
+ } google_protobuf_FieldOptions_CType;
6725
+
6726
+ typedef enum {
6727
+ google_protobuf_FieldOptions_JS_NORMAL = 0,
6728
+ google_protobuf_FieldOptions_JS_STRING = 1,
6729
+ google_protobuf_FieldOptions_JS_NUMBER = 2
6730
+ } google_protobuf_FieldOptions_JSType;
6731
+
6732
+ typedef enum {
6733
+ google_protobuf_FileOptions_SPEED = 1,
6734
+ google_protobuf_FileOptions_CODE_SIZE = 2,
6735
+ google_protobuf_FileOptions_LITE_RUNTIME = 3
6736
+ } google_protobuf_FileOptions_OptimizeMode;
6737
+
6738
+ /* MessageDefs: call these functions to get a ref to a msgdef. */
6739
+ const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_get(const void *owner);
6740
+ const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_get(const void *owner);
6741
+ const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_get(const void *owner);
6742
+ const upb_msgdef *upbdefs_google_protobuf_EnumDescriptorProto_get(const void *owner);
6743
+ const upb_msgdef *upbdefs_google_protobuf_EnumOptions_get(const void *owner);
6744
+ const upb_msgdef *upbdefs_google_protobuf_EnumValueDescriptorProto_get(const void *owner);
6745
+ const upb_msgdef *upbdefs_google_protobuf_EnumValueOptions_get(const void *owner);
6746
+ const upb_msgdef *upbdefs_google_protobuf_FieldDescriptorProto_get(const void *owner);
6747
+ const upb_msgdef *upbdefs_google_protobuf_FieldOptions_get(const void *owner);
6748
+ const upb_msgdef *upbdefs_google_protobuf_FileDescriptorProto_get(const void *owner);
6749
+ const upb_msgdef *upbdefs_google_protobuf_FileDescriptorSet_get(const void *owner);
6750
+ const upb_msgdef *upbdefs_google_protobuf_FileOptions_get(const void *owner);
6751
+ const upb_msgdef *upbdefs_google_protobuf_MessageOptions_get(const void *owner);
6752
+ const upb_msgdef *upbdefs_google_protobuf_MethodDescriptorProto_get(const void *owner);
6753
+ const upb_msgdef *upbdefs_google_protobuf_MethodOptions_get(const void *owner);
6754
+ const upb_msgdef *upbdefs_google_protobuf_OneofDescriptorProto_get(const void *owner);
6755
+ const upb_msgdef *upbdefs_google_protobuf_ServiceDescriptorProto_get(const void *owner);
6756
+ const upb_msgdef *upbdefs_google_protobuf_ServiceOptions_get(const void *owner);
6757
+ const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_get(const void *owner);
6758
+ const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_Location_get(const void *owner);
6759
+ const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_get(const void *owner);
6760
+ const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_NamePart_get(const void *owner);
6761
+
6762
+ /* EnumDefs: call these functions to get a ref to an enumdef. */
6763
+ const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Label_get(const void *owner);
6764
+ const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Type_get(const void *owner);
6765
+ const upb_enumdef *upbdefs_google_protobuf_FieldOptions_CType_get(const void *owner);
6766
+ const upb_enumdef *upbdefs_google_protobuf_FieldOptions_JSType_get(const void *owner);
6767
+ const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode_get(const void *owner);
6768
+
6769
+ /* Functions to test whether this message is of a certain type. */
6770
+ UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_is(const upb_msgdef *m) {
6771
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto") == 0;
6772
+ }
6773
+ UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(const upb_msgdef *m) {
6774
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto.ExtensionRange") == 0;
6775
+ }
6776
+ UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(const upb_msgdef *m) {
6777
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto.ReservedRange") == 0;
6778
+ }
6779
+ UPB_INLINE bool upbdefs_google_protobuf_EnumDescriptorProto_is(const upb_msgdef *m) {
6780
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumDescriptorProto") == 0;
6781
+ }
6782
+ UPB_INLINE bool upbdefs_google_protobuf_EnumOptions_is(const upb_msgdef *m) {
6783
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumOptions") == 0;
6784
+ }
6785
+ UPB_INLINE bool upbdefs_google_protobuf_EnumValueDescriptorProto_is(const upb_msgdef *m) {
6786
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumValueDescriptorProto") == 0;
6787
+ }
6788
+ UPB_INLINE bool upbdefs_google_protobuf_EnumValueOptions_is(const upb_msgdef *m) {
6789
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumValueOptions") == 0;
6790
+ }
6791
+ UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_is(const upb_msgdef *m) {
6792
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.FieldDescriptorProto") == 0;
6793
+ }
6794
+ UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_is(const upb_msgdef *m) {
6795
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.FieldOptions") == 0;
6796
+ }
6797
+ UPB_INLINE bool upbdefs_google_protobuf_FileDescriptorProto_is(const upb_msgdef *m) {
6798
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileDescriptorProto") == 0;
6799
+ }
6800
+ UPB_INLINE bool upbdefs_google_protobuf_FileDescriptorSet_is(const upb_msgdef *m) {
6801
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileDescriptorSet") == 0;
6802
+ }
6803
+ UPB_INLINE bool upbdefs_google_protobuf_FileOptions_is(const upb_msgdef *m) {
6804
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileOptions") == 0;
6805
+ }
6806
+ UPB_INLINE bool upbdefs_google_protobuf_MessageOptions_is(const upb_msgdef *m) {
6807
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.MessageOptions") == 0;
6808
+ }
6809
+ UPB_INLINE bool upbdefs_google_protobuf_MethodDescriptorProto_is(const upb_msgdef *m) {
6810
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.MethodDescriptorProto") == 0;
6811
+ }
6812
+ UPB_INLINE bool upbdefs_google_protobuf_MethodOptions_is(const upb_msgdef *m) {
6813
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.MethodOptions") == 0;
6814
+ }
6815
+ UPB_INLINE bool upbdefs_google_protobuf_OneofDescriptorProto_is(const upb_msgdef *m) {
6816
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.OneofDescriptorProto") == 0;
6817
+ }
6818
+ UPB_INLINE bool upbdefs_google_protobuf_ServiceDescriptorProto_is(const upb_msgdef *m) {
6819
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.ServiceDescriptorProto") == 0;
6820
+ }
6821
+ UPB_INLINE bool upbdefs_google_protobuf_ServiceOptions_is(const upb_msgdef *m) {
6822
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.ServiceOptions") == 0;
6823
+ }
6824
+ UPB_INLINE bool upbdefs_google_protobuf_SourceCodeInfo_is(const upb_msgdef *m) {
6825
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.SourceCodeInfo") == 0;
6826
+ }
6827
+ UPB_INLINE bool upbdefs_google_protobuf_SourceCodeInfo_Location_is(const upb_msgdef *m) {
6828
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.SourceCodeInfo.Location") == 0;
6829
+ }
6830
+ UPB_INLINE bool upbdefs_google_protobuf_UninterpretedOption_is(const upb_msgdef *m) {
6831
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.UninterpretedOption") == 0;
6832
+ }
6833
+ UPB_INLINE bool upbdefs_google_protobuf_UninterpretedOption_NamePart_is(const upb_msgdef *m) {
6834
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.UninterpretedOption.NamePart") == 0;
6835
+ }
6836
+
6837
+ /* Functions to test whether this enum is of a certain type. */
6838
+ UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_Label_is(const upb_enumdef *e) {
6839
+ return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldDescriptorProto.Label") == 0;
6840
+ }
6841
+ UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_Type_is(const upb_enumdef *e) {
6842
+ return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldDescriptorProto.Type") == 0;
6843
+ }
6844
+ UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_CType_is(const upb_enumdef *e) {
6845
+ return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldOptions.CType") == 0;
6846
+ }
6847
+ UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_JSType_is(const upb_enumdef *e) {
6848
+ return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldOptions.JSType") == 0;
6849
+ }
6850
+ UPB_INLINE bool upbdefs_google_protobuf_FileOptions_OptimizeMode_is(const upb_enumdef *e) {
6851
+ return strcmp(upb_enumdef_fullname(e), "google.protobuf.FileOptions.OptimizeMode") == 0;
6852
+ }
6853
+
6854
+
6855
+ /* Functions to get a fielddef from a msgdef reference. */
6856
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_end(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 2); }
6857
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_start(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 1); }
6858
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_end(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 2); }
6859
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_start(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 1); }
6860
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
6861
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
6862
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension_range(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
6863
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
6864
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
6865
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
6866
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_decl(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
6867
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
6868
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
6869
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_range(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
6870
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
6871
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
6872
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
6873
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 2); }
6874
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 3); }
6875
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 999); }
6876
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
6877
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_number(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
6878
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
6879
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 1); }
6880
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 999); }
6881
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_default_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
6882
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_extendee(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
6883
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_json_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
6884
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_label(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
6885
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
6886
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_number(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
6887
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_oneof_index(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
6888
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
6889
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
6890
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
6891
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 1); }
6892
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 3); }
6893
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 6); }
6894
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 5); }
6895
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 2); }
6896
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 999); }
6897
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 10); }
6898
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
6899
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enum_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
6900
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
6901
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_message_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
6902
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
6903
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
6904
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
6905
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_public_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
6906
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_service(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
6907
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_source_code_info(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
6908
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syntax(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 12); }
6909
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_weak_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 11); }
6910
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorSet_is(m)); return upb_msgdef_itof(m, 1); }
6911
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_arenas(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 31); }
6912
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 16); }
6913
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_namespace(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 37); }
6914
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 23); }
6915
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 11); }
6916
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generate_equals_and_hash(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 20); }
6917
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 17); }
6918
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multiple_files(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 10); }
6919
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_classname(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 8); }
6920
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 1); }
6921
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string_check_utf8(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 27); }
6922
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_use_deprecated_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 38); }
6923
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 36); }
6924
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); }
6925
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 18); }
6926
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 999); }
6927
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 3); }
6928
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entry(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 7); }
6929
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_set_wire_format(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 1); }
6930
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_standard_descriptor_accessor(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 2); }
6931
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 999); }
6932
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_client_streaming(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
6933
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_input_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
6934
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
6935
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
6936
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_output_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
6937
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_server_streaming(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
6938
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 33); }
6939
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 999); }
6940
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
6941
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_method(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
6942
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
6943
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
6944
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 33); }
6945
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 999); }
6946
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 3); }
6947
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_detached_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 6); }
6948
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_path(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 1); }
6949
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_span(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 2); }
6950
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_trailing_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 4); }
6951
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_is(m)); return upb_msgdef_itof(m, 1); }
6952
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_is_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 2); }
6953
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_name_part(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 1); }
6954
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_aggregate_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 8); }
6955
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_double_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 6); }
6956
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_identifier_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 3); }
6957
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 2); }
6958
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_negative_int_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 5); }
6959
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_positive_int_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 4); }
6960
+ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_string_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 7); }
6961
+
6962
+ UPB_END_EXTERN_C
6963
+
6964
+ #ifdef __cplusplus
6965
+
6966
+ namespace upbdefs {
6967
+ namespace google {
6968
+ namespace protobuf {
6969
+
6970
+ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
6971
+ public:
6972
+ DescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
6973
+ : reffed_ptr(m, ref_donor) {
6974
+ assert(upbdefs_google_protobuf_DescriptorProto_is(m));
6975
+ }
6976
+
6977
+ static DescriptorProto get() {
6978
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_get(&m);
6979
+ return DescriptorProto(m, &m);
6980
+ }
6981
+
6982
+ class ExtensionRange : public ::upb::reffed_ptr<const ::upb::MessageDef> {
6983
+ public:
6984
+ ExtensionRange(const ::upb::MessageDef* m, const void *ref_donor = NULL)
6985
+ : reffed_ptr(m, ref_donor) {
6986
+ assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m));
6987
+ }
6988
+
6989
+ static ExtensionRange get() {
6990
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_ExtensionRange_get(&m);
6991
+ return ExtensionRange(m, &m);
6992
+ }
6993
+ };
6994
+
6995
+ class ReservedRange : public ::upb::reffed_ptr<const ::upb::MessageDef> {
6996
+ public:
6997
+ ReservedRange(const ::upb::MessageDef* m, const void *ref_donor = NULL)
6998
+ : reffed_ptr(m, ref_donor) {
6999
+ assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m));
7000
+ }
7001
+
7002
+ static ReservedRange get() {
7003
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_ReservedRange_get(&m);
7004
+ return ReservedRange(m, &m);
7005
+ }
7006
+ };
7007
+ };
7008
+
7009
+ class EnumDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7010
+ public:
7011
+ EnumDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7012
+ : reffed_ptr(m, ref_donor) {
7013
+ assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m));
7014
+ }
7015
+
7016
+ static EnumDescriptorProto get() {
7017
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumDescriptorProto_get(&m);
7018
+ return EnumDescriptorProto(m, &m);
7019
+ }
7020
+ };
7021
+
7022
+ class EnumOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7023
+ public:
7024
+ EnumOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7025
+ : reffed_ptr(m, ref_donor) {
7026
+ assert(upbdefs_google_protobuf_EnumOptions_is(m));
7027
+ }
7028
+
7029
+ static EnumOptions get() {
7030
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumOptions_get(&m);
7031
+ return EnumOptions(m, &m);
7032
+ }
7033
+ };
7034
+
7035
+ class EnumValueDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7036
+ public:
7037
+ EnumValueDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7038
+ : reffed_ptr(m, ref_donor) {
7039
+ assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m));
7040
+ }
7041
+
7042
+ static EnumValueDescriptorProto get() {
7043
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumValueDescriptorProto_get(&m);
7044
+ return EnumValueDescriptorProto(m, &m);
7045
+ }
7046
+ };
6201
7047
 
6202
- UPB_BEGIN_EXTERN_C
7048
+ class EnumValueOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7049
+ public:
7050
+ EnumValueOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7051
+ : reffed_ptr(m, ref_donor) {
7052
+ assert(upbdefs_google_protobuf_EnumValueOptions_is(m));
7053
+ }
6203
7054
 
6204
- /* C API. */
6205
- upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h);
6206
- upb_sink *upb_descreader_input(upb_descreader *r);
6207
- upb_def **upb_descreader_getdefs(upb_descreader *r, void *owner, int *n);
6208
- const upb_handlers *upb_descreader_newhandlers(const void *owner);
7055
+ static EnumValueOptions get() {
7056
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumValueOptions_get(&m);
7057
+ return EnumValueOptions(m, &m);
7058
+ }
7059
+ };
6209
7060
 
6210
- UPB_END_EXTERN_C
7061
+ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7062
+ public:
7063
+ FieldDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7064
+ : reffed_ptr(m, ref_donor) {
7065
+ assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m));
7066
+ }
6211
7067
 
6212
- #ifdef __cplusplus
6213
- /* C++ implementation details. ************************************************/
6214
- namespace upb {
6215
- namespace descriptor {
6216
- inline Reader* Reader::Create(Environment* e, const Handlers *h) {
6217
- return upb_descreader_create(e, h);
6218
- }
6219
- inline Sink* Reader::input() { return upb_descreader_input(this); }
6220
- inline upb::Def** Reader::GetDefs(void* owner, int* n) {
6221
- return upb_descreader_getdefs(this, owner, n);
6222
- }
6223
- } /* namespace descriptor */
6224
- } /* namespace upb */
6225
- #endif
7068
+ static FieldDescriptorProto get() {
7069
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_FieldDescriptorProto_get(&m);
7070
+ return FieldDescriptorProto(m, &m);
7071
+ }
6226
7072
 
6227
- #endif /* UPB_DESCRIPTOR_H */
6228
- /* This file contains accessors for a set of compiled-in defs.
6229
- * Note that unlike Google's protobuf, it does *not* define
6230
- * generated classes or any other kind of data structure for
6231
- * actually storing protobufs. It only contains *defs* which
6232
- * let you reflect over a protobuf *schema*.
6233
- */
6234
- /* This file was generated by upbc (the upb compiler).
6235
- * Do not edit -- your changes will be discarded when the file is
6236
- * regenerated. */
7073
+ class Label : public ::upb::reffed_ptr<const ::upb::EnumDef> {
7074
+ public:
7075
+ Label(const ::upb::EnumDef* e, const void *ref_donor = NULL)
7076
+ : reffed_ptr(e, ref_donor) {
7077
+ assert(upbdefs_google_protobuf_FieldDescriptorProto_Label_is(e));
7078
+ }
7079
+ static Label get() {
7080
+ const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Label_get(&e);
7081
+ return Label(e, &e);
7082
+ }
7083
+ };
6237
7084
 
6238
- #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_UPB_H_
6239
- #define GOOGLE_PROTOBUF_DESCRIPTOR_UPB_H_
7085
+ class Type : public ::upb::reffed_ptr<const ::upb::EnumDef> {
7086
+ public:
7087
+ Type(const ::upb::EnumDef* e, const void *ref_donor = NULL)
7088
+ : reffed_ptr(e, ref_donor) {
7089
+ assert(upbdefs_google_protobuf_FieldDescriptorProto_Type_is(e));
7090
+ }
7091
+ static Type get() {
7092
+ const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Type_get(&e);
7093
+ return Type(e, &e);
7094
+ }
7095
+ };
7096
+ };
6240
7097
 
7098
+ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7099
+ public:
7100
+ FieldOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7101
+ : reffed_ptr(m, ref_donor) {
7102
+ assert(upbdefs_google_protobuf_FieldOptions_is(m));
7103
+ }
6241
7104
 
6242
- #ifdef __cplusplus
6243
- UPB_BEGIN_EXTERN_C
6244
- #endif
7105
+ static FieldOptions get() {
7106
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_FieldOptions_get(&m);
7107
+ return FieldOptions(m, &m);
7108
+ }
6245
7109
 
6246
- /* Enums */
7110
+ class CType : public ::upb::reffed_ptr<const ::upb::EnumDef> {
7111
+ public:
7112
+ CType(const ::upb::EnumDef* e, const void *ref_donor = NULL)
7113
+ : reffed_ptr(e, ref_donor) {
7114
+ assert(upbdefs_google_protobuf_FieldOptions_CType_is(e));
7115
+ }
7116
+ static CType get() {
7117
+ const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_CType_get(&e);
7118
+ return CType(e, &e);
7119
+ }
7120
+ };
6247
7121
 
6248
- typedef enum {
6249
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_OPTIONAL = 1,
6250
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_REQUIRED = 2,
6251
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_REPEATED = 3
6252
- } google_protobuf_FieldDescriptorProto_Label;
7122
+ class JSType : public ::upb::reffed_ptr<const ::upb::EnumDef> {
7123
+ public:
7124
+ JSType(const ::upb::EnumDef* e, const void *ref_donor = NULL)
7125
+ : reffed_ptr(e, ref_donor) {
7126
+ assert(upbdefs_google_protobuf_FieldOptions_JSType_is(e));
7127
+ }
7128
+ static JSType get() {
7129
+ const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_JSType_get(&e);
7130
+ return JSType(e, &e);
7131
+ }
7132
+ };
7133
+ };
6253
7134
 
6254
- typedef enum {
6255
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_DOUBLE = 1,
6256
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_FLOAT = 2,
6257
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT64 = 3,
6258
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_UINT64 = 4,
6259
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT32 = 5,
6260
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_FIXED64 = 6,
6261
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_FIXED32 = 7,
6262
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_BOOL = 8,
6263
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_STRING = 9,
6264
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_GROUP = 10,
6265
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_MESSAGE = 11,
6266
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_BYTES = 12,
6267
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_UINT32 = 13,
6268
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_ENUM = 14,
6269
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SFIXED32 = 15,
6270
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SFIXED64 = 16,
6271
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SINT32 = 17,
6272
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SINT64 = 18
6273
- } google_protobuf_FieldDescriptorProto_Type;
7135
+ class FileDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7136
+ public:
7137
+ FileDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7138
+ : reffed_ptr(m, ref_donor) {
7139
+ assert(upbdefs_google_protobuf_FileDescriptorProto_is(m));
7140
+ }
6274
7141
 
6275
- typedef enum {
6276
- GOOGLE_PROTOBUF_FIELDOPTIONS_STRING = 0,
6277
- GOOGLE_PROTOBUF_FIELDOPTIONS_CORD = 1,
6278
- GOOGLE_PROTOBUF_FIELDOPTIONS_STRING_PIECE = 2
6279
- } google_protobuf_FieldOptions_CType;
7142
+ static FileDescriptorProto get() {
7143
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_FileDescriptorProto_get(&m);
7144
+ return FileDescriptorProto(m, &m);
7145
+ }
7146
+ };
6280
7147
 
6281
- typedef enum {
6282
- GOOGLE_PROTOBUF_FILEOPTIONS_SPEED = 1,
6283
- GOOGLE_PROTOBUF_FILEOPTIONS_CODE_SIZE = 2,
6284
- GOOGLE_PROTOBUF_FILEOPTIONS_LITE_RUNTIME = 3
6285
- } google_protobuf_FileOptions_OptimizeMode;
7148
+ class FileDescriptorSet : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7149
+ public:
7150
+ FileDescriptorSet(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7151
+ : reffed_ptr(m, ref_donor) {
7152
+ assert(upbdefs_google_protobuf_FileDescriptorSet_is(m));
7153
+ }
6286
7154
 
6287
- /* Selectors */
6288
-
6289
- /* google.protobuf.DescriptorProto */
6290
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSUBMSG 2
6291
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSUBMSG 3
6292
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSUBMSG 4
6293
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSUBMSG 5
6294
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSUBMSG 6
6295
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_STARTSUBMSG 7
6296
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSEQ 8
6297
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSEQ 9
6298
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSUBMSG 10
6299
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSEQ 11
6300
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSEQ 12
6301
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSUBMSG 13
6302
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 14
6303
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 15
6304
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 16
6305
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSEQ 17
6306
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSEQ 18
6307
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSUBMSG 19
6308
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSEQ 20
6309
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSEQ 21
6310
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSUBMSG 22
6311
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_ENDSUBMSG 23
6312
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STRING 24
6313
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STARTSTR 25
6314
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_ENDSTR 26
6315
-
6316
- /* google.protobuf.DescriptorProto.ExtensionRange */
6317
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_START_INT32 2
6318
- #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_END_INT32 3
6319
-
6320
- /* google.protobuf.EnumDescriptorProto */
6321
- #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSUBMSG 2
6322
- #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 3
6323
- #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSEQ 4
6324
- #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_ENDSEQ 5
6325
- #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_ENDSUBMSG 6
6326
- #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 7
6327
- #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_STRING 8
6328
- #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_STARTSTR 9
6329
- #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_ENDSTR 10
6330
-
6331
- /* google.protobuf.EnumOptions */
6332
- #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6333
- #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6334
- #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6335
- #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6336
- #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_ALLOW_ALIAS_BOOL 6
6337
-
6338
- /* google.protobuf.EnumValueDescriptorProto */
6339
- #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
6340
- #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 3
6341
- #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_STRING 4
6342
- #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_STARTSTR 5
6343
- #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_ENDSTR 6
6344
- #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NUMBER_INT32 7
6345
-
6346
- /* google.protobuf.EnumValueOptions */
6347
- #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6348
- #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6349
- #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6350
- #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6351
-
6352
- /* google.protobuf.FieldDescriptorProto */
6353
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
6354
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 3
6355
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_STRING 4
6356
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_STARTSTR 5
6357
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_ENDSTR 6
6358
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_STRING 7
6359
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_STARTSTR 8
6360
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_ENDSTR 9
6361
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NUMBER_INT32 10
6362
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_INT32 11
6363
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT32 12
6364
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_STRING 13
6365
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_STARTSTR 14
6366
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_ENDSTR 15
6367
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STRING 16
6368
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STARTSTR 17
6369
- #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_ENDSTR 18
6370
-
6371
- /* google.protobuf.FieldOptions */
6372
- #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6373
- #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6374
- #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6375
- #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6376
- #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_CTYPE_INT32 6
6377
- #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_PACKED_BOOL 7
6378
- #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_DEPRECATED_BOOL 8
6379
- #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_LAZY_BOOL 9
6380
- #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_STRING 10
6381
- #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_STARTSTR 11
6382
- #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_ENDSTR 12
6383
- #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_WEAK_BOOL 13
6384
-
6385
- /* google.protobuf.FileDescriptorProto */
6386
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSUBMSG 2
6387
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_STARTSUBMSG 3
6388
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_STARTSUBMSG 4
6389
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_STARTSUBMSG 5
6390
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 6
6391
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SOURCE_CODE_INFO_STARTSUBMSG 7
6392
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSEQ 8
6393
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_ENDSEQ 9
6394
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_ENDSUBMSG 10
6395
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 11
6396
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 12
6397
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 13
6398
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_STARTSEQ 14
6399
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_ENDSEQ 15
6400
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_ENDSUBMSG 16
6401
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_STARTSEQ 17
6402
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_ENDSEQ 18
6403
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_ENDSUBMSG 19
6404
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 20
6405
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SOURCE_CODE_INFO_ENDSUBMSG 21
6406
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_STRING 22
6407
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_STARTSTR 23
6408
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_ENDSTR 24
6409
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_STRING 25
6410
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_STARTSTR 26
6411
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_ENDSTR 27
6412
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STARTSEQ 28
6413
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_ENDSEQ 29
6414
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STRING 30
6415
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STARTSTR 31
6416
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_ENDSTR 32
6417
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PUBLIC_DEPENDENCY_STARTSEQ 33
6418
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PUBLIC_DEPENDENCY_ENDSEQ 34
6419
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PUBLIC_DEPENDENCY_INT32 35
6420
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_STARTSEQ 36
6421
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_ENDSEQ 37
6422
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_INT32 38
6423
-
6424
- /* google.protobuf.FileDescriptorSet */
6425
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSUBMSG 2
6426
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSEQ 3
6427
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_ENDSEQ 4
6428
- #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_ENDSUBMSG 5
6429
-
6430
- /* google.protobuf.FileOptions */
6431
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6432
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6433
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6434
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6435
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_STRING 6
6436
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_STARTSTR 7
6437
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_ENDSTR 8
6438
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_STRING 9
6439
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_STARTSTR 10
6440
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_ENDSTR 11
6441
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_OPTIMIZE_FOR_INT32 12
6442
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_MULTIPLE_FILES_BOOL 13
6443
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_GO_PACKAGE_STRING 14
6444
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_GO_PACKAGE_STARTSTR 15
6445
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_GO_PACKAGE_ENDSTR 16
6446
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_CC_GENERIC_SERVICES_BOOL 17
6447
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERIC_SERVICES_BOOL 18
6448
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_PY_GENERIC_SERVICES_BOOL 19
6449
- #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERATE_EQUALS_AND_HASH_BOOL 20
6450
-
6451
- /* google.protobuf.MessageOptions */
6452
- #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6453
- #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6454
- #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6455
- #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6456
- #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_MESSAGE_SET_WIRE_FORMAT_BOOL 6
6457
- #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_NO_STANDARD_DESCRIPTOR_ACCESSOR_BOOL 7
6458
-
6459
- /* google.protobuf.MethodDescriptorProto */
6460
- #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
6461
- #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 3
6462
- #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_STRING 4
6463
- #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_STARTSTR 5
6464
- #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_ENDSTR 6
6465
- #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_STRING 7
6466
- #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_STARTSTR 8
6467
- #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_ENDSTR 9
6468
- #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STRING 10
6469
- #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STARTSTR 11
6470
- #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_ENDSTR 12
6471
-
6472
- /* google.protobuf.MethodOptions */
6473
- #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6474
- #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6475
- #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6476
- #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6477
-
6478
- /* google.protobuf.ServiceDescriptorProto */
6479
- #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSUBMSG 2
6480
- #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 3
6481
- #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSEQ 4
6482
- #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_ENDSEQ 5
6483
- #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_ENDSUBMSG 6
6484
- #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 7
6485
- #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_STRING 8
6486
- #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_STARTSTR 9
6487
- #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_ENDSTR 10
6488
-
6489
- /* google.protobuf.ServiceOptions */
6490
- #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6491
- #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6492
- #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6493
- #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6494
-
6495
- /* google.protobuf.SourceCodeInfo */
6496
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSUBMSG 2
6497
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSEQ 3
6498
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_ENDSEQ 4
6499
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_ENDSUBMSG 5
6500
-
6501
- /* google.protobuf.SourceCodeInfo.Location */
6502
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_STARTSEQ 2
6503
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_ENDSEQ 3
6504
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_INT32 4
6505
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_STARTSEQ 5
6506
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_ENDSEQ 6
6507
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_INT32 7
6508
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_COMMENTS_STRING 8
6509
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_COMMENTS_STARTSTR 9
6510
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_COMMENTS_ENDSTR 10
6511
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_TRAILING_COMMENTS_STRING 11
6512
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_TRAILING_COMMENTS_STARTSTR 12
6513
- #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_TRAILING_COMMENTS_ENDSTR 13
6514
-
6515
- /* google.protobuf.UninterpretedOption */
6516
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_STARTSUBMSG 2
6517
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_STARTSEQ 3
6518
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_ENDSEQ 4
6519
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_ENDSUBMSG 5
6520
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_IDENTIFIER_VALUE_STRING 6
6521
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_IDENTIFIER_VALUE_STARTSTR 7
6522
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_IDENTIFIER_VALUE_ENDSTR 8
6523
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_POSITIVE_INT_VALUE_UINT64 9
6524
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NEGATIVE_INT_VALUE_INT64 10
6525
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_DOUBLE_VALUE_DOUBLE 11
6526
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_STRING_VALUE_STRING 12
6527
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_STRING_VALUE_STARTSTR 13
6528
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_STRING_VALUE_ENDSTR 14
6529
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_AGGREGATE_VALUE_STRING 15
6530
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_AGGREGATE_VALUE_STARTSTR 16
6531
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_AGGREGATE_VALUE_ENDSTR 17
6532
-
6533
- /* google.protobuf.UninterpretedOption.NamePart */
6534
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_NAME_PART_STRING 2
6535
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_NAME_PART_STARTSTR 3
6536
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_NAME_PART_ENDSTR 4
6537
- #define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_IS_EXTENSION_BOOL 5
6538
-
6539
- const upb_symtab *upbdefs_google_protobuf_descriptor(const void *owner);
6540
-
6541
- /* MessageDefs */
6542
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_DescriptorProto(const upb_symtab *s) {
6543
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto");
6544
- assert(m);
6545
- return m;
6546
- }
6547
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange(const upb_symtab *s) {
6548
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto.ExtensionRange");
6549
- assert(m);
6550
- return m;
6551
- }
6552
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_EnumDescriptorProto(const upb_symtab *s) {
6553
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.EnumDescriptorProto");
6554
- assert(m);
6555
- return m;
6556
- }
6557
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_EnumOptions(const upb_symtab *s) {
6558
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.EnumOptions");
6559
- assert(m);
6560
- return m;
6561
- }
6562
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_EnumValueDescriptorProto(const upb_symtab *s) {
6563
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.EnumValueDescriptorProto");
6564
- assert(m);
6565
- return m;
6566
- }
6567
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_EnumValueOptions(const upb_symtab *s) {
6568
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.EnumValueOptions");
6569
- assert(m);
6570
- return m;
6571
- }
6572
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_FieldDescriptorProto(const upb_symtab *s) {
6573
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.FieldDescriptorProto");
6574
- assert(m);
6575
- return m;
6576
- }
6577
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_FieldOptions(const upb_symtab *s) {
6578
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.FieldOptions");
6579
- assert(m);
6580
- return m;
6581
- }
6582
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_FileDescriptorProto(const upb_symtab *s) {
6583
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.FileDescriptorProto");
6584
- assert(m);
6585
- return m;
6586
- }
6587
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_FileDescriptorSet(const upb_symtab *s) {
6588
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.FileDescriptorSet");
6589
- assert(m);
6590
- return m;
6591
- }
6592
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_FileOptions(const upb_symtab *s) {
6593
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.FileOptions");
6594
- assert(m);
6595
- return m;
6596
- }
6597
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_MessageOptions(const upb_symtab *s) {
6598
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.MessageOptions");
6599
- assert(m);
6600
- return m;
6601
- }
6602
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_MethodDescriptorProto(const upb_symtab *s) {
6603
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.MethodDescriptorProto");
6604
- assert(m);
6605
- return m;
6606
- }
6607
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_MethodOptions(const upb_symtab *s) {
6608
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.MethodOptions");
6609
- assert(m);
6610
- return m;
6611
- }
6612
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_ServiceDescriptorProto(const upb_symtab *s) {
6613
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.ServiceDescriptorProto");
6614
- assert(m);
6615
- return m;
6616
- }
6617
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_ServiceOptions(const upb_symtab *s) {
6618
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.ServiceOptions");
6619
- assert(m);
6620
- return m;
6621
- }
6622
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo(const upb_symtab *s) {
6623
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.SourceCodeInfo");
6624
- assert(m);
6625
- return m;
6626
- }
6627
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_Location(const upb_symtab *s) {
6628
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.SourceCodeInfo.Location");
6629
- assert(m);
6630
- return m;
6631
- }
6632
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption(const upb_symtab *s) {
6633
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.UninterpretedOption");
6634
- assert(m);
6635
- return m;
6636
- }
6637
- UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_NamePart(const upb_symtab *s) {
6638
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.UninterpretedOption.NamePart");
6639
- assert(m);
6640
- return m;
6641
- }
6642
-
6643
-
6644
- /* EnumDefs */
6645
- UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Label(const upb_symtab *s) {
6646
- const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FieldDescriptorProto.Label");
6647
- assert(e);
6648
- return e;
6649
- }
6650
- UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Type(const upb_symtab *s) {
6651
- const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FieldDescriptorProto.Type");
6652
- assert(e);
6653
- return e;
6654
- }
6655
- UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FieldOptions_CType(const upb_symtab *s) {
6656
- const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FieldOptions.CType");
6657
- assert(e);
6658
- return e;
6659
- }
6660
- UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode(const upb_symtab *s) {
6661
- const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FileOptions.OptimizeMode");
6662
- assert(e);
6663
- return e;
6664
- }
6665
-
6666
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_end(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto_ExtensionRange(s), 2); }
6667
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_start(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto_ExtensionRange(s), 1); }
6668
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_enum_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 4); }
6669
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_extension(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 6); }
6670
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_extension_range(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 5); }
6671
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_field(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 2); }
6672
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 1); }
6673
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_nested_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 3); }
6674
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 7); }
6675
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescriptorProto(s), 1); }
6676
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescriptorProto(s), 3); }
6677
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescriptorProto(s), 2); }
6678
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_allow_alias(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumOptions(s), 2); }
6679
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumOptions(s), 999); }
6680
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueDescriptorProto(s), 1); }
6681
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_number(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueDescriptorProto(s), 2); }
6682
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueDescriptorProto(s), 3); }
6683
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueOptions(s), 999); }
6684
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_default_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 7); }
6685
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_extendee(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 2); }
6686
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_label(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 4); }
6687
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 1); }
6688
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_number(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 3); }
6689
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 8); }
6690
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 5); }
6691
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_type_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 6); }
6692
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_ctype(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 1); }
6693
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 3); }
6694
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_experimental_map_key(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 9); }
6695
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_lazy(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 5); }
6696
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_packed(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 2); }
6697
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 999); }
6698
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_weak(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 10); }
6699
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_dependency(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 3); }
6700
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_enum_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 5); }
6701
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_extension(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 7); }
6702
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_message_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 4); }
6703
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 1); }
6704
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 8); }
6705
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_package(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 2); }
6706
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_public_dependency(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 10); }
6707
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_service(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 6); }
6708
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_source_code_info(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 9); }
6709
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_weak_dependency(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 11); }
6710
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_file(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorSet(s), 1); }
6711
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_cc_generic_services(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 16); }
6712
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_go_package(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 11); }
6713
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_generate_equals_and_hash(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 20); }
6714
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_generic_services(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 17); }
6715
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_multiple_files(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 10); }
6716
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_outer_classname(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 8); }
6717
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_package(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 1); }
6718
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_optimize_for(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 9); }
6719
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_py_generic_services(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 18); }
6720
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 999); }
6721
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_message_set_wire_format(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 1); }
6722
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_no_standard_descriptor_accessor(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 2); }
6723
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 999); }
6724
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_input_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 2); }
6725
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 1); }
6726
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 4); }
6727
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_output_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 3); }
6728
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodOptions(s), 999); }
6729
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_method(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceDescriptorProto(s), 2); }
6730
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceDescriptorProto(s), 1); }
6731
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceDescriptorProto(s), 3); }
6732
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceOptions(s), 999); }
6733
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_leading_comments(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 3); }
6734
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_path(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 1); }
6735
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_span(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 2); }
6736
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_trailing_comments(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 4); }
6737
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_location(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo(s), 1); }
6738
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_is_extension(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption_NamePart(s), 2); }
6739
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_name_part(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption_NamePart(s), 1); }
6740
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_aggregate_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 8); }
6741
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_double_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 6); }
6742
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_identifier_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 3); }
6743
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 2); }
6744
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_negative_int_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 5); }
6745
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_positive_int_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 4); }
6746
- UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_string_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 7); }
7155
+ static FileDescriptorSet get() {
7156
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_FileDescriptorSet_get(&m);
7157
+ return FileDescriptorSet(m, &m);
7158
+ }
7159
+ };
6747
7160
 
6748
- UPB_END_EXTERN_C
7161
+ class FileOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7162
+ public:
7163
+ FileOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7164
+ : reffed_ptr(m, ref_donor) {
7165
+ assert(upbdefs_google_protobuf_FileOptions_is(m));
7166
+ }
6749
7167
 
6750
- #ifdef __cplusplus
7168
+ static FileOptions get() {
7169
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_FileOptions_get(&m);
7170
+ return FileOptions(m, &m);
7171
+ }
6751
7172
 
6752
- namespace upbdefs {
6753
- namespace google {
6754
- namespace protobuf {
6755
- namespace descriptor {
6756
- inline upb::reffed_ptr<const upb::SymbolTable> SymbolTable() {
6757
- const upb::SymbolTable* s = upbdefs_google_protobuf_descriptor(&s);
6758
- return upb::reffed_ptr<const upb::SymbolTable>(s, &s);
6759
- }
6760
- } /* namespace descriptor */
6761
- } /* namespace protobuf */
6762
- } /* namespace google */
7173
+ class OptimizeMode : public ::upb::reffed_ptr<const ::upb::EnumDef> {
7174
+ public:
7175
+ OptimizeMode(const ::upb::EnumDef* e, const void *ref_donor = NULL)
7176
+ : reffed_ptr(e, ref_donor) {
7177
+ assert(upbdefs_google_protobuf_FileOptions_OptimizeMode_is(e));
7178
+ }
7179
+ static OptimizeMode get() {
7180
+ const ::upb::EnumDef* e = upbdefs_google_protobuf_FileOptions_OptimizeMode_get(&e);
7181
+ return OptimizeMode(e, &e);
7182
+ }
7183
+ };
7184
+ };
6763
7185
 
6764
- #define RETURN_REFFED(type, func) \
6765
- const type* obj = func(upbdefs::google::protobuf::descriptor::SymbolTable().get()); \
6766
- return upb::reffed_ptr<const type>(obj);
7186
+ class MessageOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7187
+ public:
7188
+ MessageOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7189
+ : reffed_ptr(m, ref_donor) {
7190
+ assert(upbdefs_google_protobuf_MessageOptions_is(m));
7191
+ }
6767
7192
 
6768
- namespace google {
6769
- namespace protobuf {
6770
- namespace DescriptorProto {
6771
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_DescriptorProto) }
6772
- inline upb::reffed_ptr<const upb::FieldDef> enum_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_enum_type) }
6773
- inline upb::reffed_ptr<const upb::FieldDef> extension() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_extension) }
6774
- inline upb::reffed_ptr<const upb::FieldDef> extension_range() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_extension_range) }
6775
- inline upb::reffed_ptr<const upb::FieldDef> field() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_field) }
6776
- inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_name) }
6777
- inline upb::reffed_ptr<const upb::FieldDef> nested_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_nested_type) }
6778
- inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_options) }
6779
- } /* namespace DescriptorProto */
6780
- } /* namespace protobuf */
6781
- } /* namespace google */
7193
+ static MessageOptions get() {
7194
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_MessageOptions_get(&m);
7195
+ return MessageOptions(m, &m);
7196
+ }
7197
+ };
6782
7198
 
6783
- namespace google {
6784
- namespace protobuf {
6785
- namespace DescriptorProto {
6786
- namespace ExtensionRange {
6787
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_DescriptorProto_ExtensionRange) }
6788
- inline upb::reffed_ptr<const upb::FieldDef> end() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_ExtensionRange_end) }
6789
- inline upb::reffed_ptr<const upb::FieldDef> start() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_ExtensionRange_start) }
6790
- } /* namespace ExtensionRange */
6791
- } /* namespace DescriptorProto */
6792
- } /* namespace protobuf */
6793
- } /* namespace google */
7199
+ class MethodDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7200
+ public:
7201
+ MethodDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7202
+ : reffed_ptr(m, ref_donor) {
7203
+ assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m));
7204
+ }
6794
7205
 
6795
- namespace google {
6796
- namespace protobuf {
6797
- namespace EnumDescriptorProto {
6798
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_EnumDescriptorProto) }
6799
- inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumDescriptorProto_name) }
6800
- inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumDescriptorProto_options) }
6801
- inline upb::reffed_ptr<const upb::FieldDef> value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumDescriptorProto_value) }
6802
- } /* namespace EnumDescriptorProto */
6803
- } /* namespace protobuf */
6804
- } /* namespace google */
7206
+ static MethodDescriptorProto get() {
7207
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_MethodDescriptorProto_get(&m);
7208
+ return MethodDescriptorProto(m, &m);
7209
+ }
7210
+ };
6805
7211
 
6806
- namespace google {
6807
- namespace protobuf {
6808
- namespace EnumOptions {
6809
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_EnumOptions) }
6810
- inline upb::reffed_ptr<const upb::FieldDef> allow_alias() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumOptions_allow_alias) }
6811
- inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumOptions_uninterpreted_option) }
6812
- } /* namespace EnumOptions */
6813
- } /* namespace protobuf */
6814
- } /* namespace google */
7212
+ class MethodOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7213
+ public:
7214
+ MethodOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7215
+ : reffed_ptr(m, ref_donor) {
7216
+ assert(upbdefs_google_protobuf_MethodOptions_is(m));
7217
+ }
6815
7218
 
6816
- namespace google {
6817
- namespace protobuf {
6818
- namespace EnumValueDescriptorProto {
6819
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_EnumValueDescriptorProto) }
6820
- inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumValueDescriptorProto_name) }
6821
- inline upb::reffed_ptr<const upb::FieldDef> number() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumValueDescriptorProto_number) }
6822
- inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumValueDescriptorProto_options) }
6823
- } /* namespace EnumValueDescriptorProto */
6824
- } /* namespace protobuf */
6825
- } /* namespace google */
7219
+ static MethodOptions get() {
7220
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_MethodOptions_get(&m);
7221
+ return MethodOptions(m, &m);
7222
+ }
7223
+ };
6826
7224
 
6827
- namespace google {
6828
- namespace protobuf {
6829
- namespace EnumValueOptions {
6830
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_EnumValueOptions) }
6831
- inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumValueOptions_uninterpreted_option) }
6832
- } /* namespace EnumValueOptions */
6833
- } /* namespace protobuf */
6834
- } /* namespace google */
7225
+ class OneofDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7226
+ public:
7227
+ OneofDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7228
+ : reffed_ptr(m, ref_donor) {
7229
+ assert(upbdefs_google_protobuf_OneofDescriptorProto_is(m));
7230
+ }
6835
7231
 
6836
- namespace google {
6837
- namespace protobuf {
6838
- namespace FieldDescriptorProto {
6839
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FieldDescriptorProto) }
6840
- inline upb::reffed_ptr<const upb::FieldDef> default_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_default_value) }
6841
- inline upb::reffed_ptr<const upb::FieldDef> extendee() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_extendee) }
6842
- inline upb::reffed_ptr<const upb::FieldDef> label() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_label) }
6843
- inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_name) }
6844
- inline upb::reffed_ptr<const upb::FieldDef> number() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_number) }
6845
- inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_options) }
6846
- inline upb::reffed_ptr<const upb::FieldDef> type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_type) }
6847
- inline upb::reffed_ptr<const upb::FieldDef> type_name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_type_name) }
6848
- inline upb::reffed_ptr<const upb::EnumDef> Label() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldDescriptorProto_Label) }
6849
- inline upb::reffed_ptr<const upb::EnumDef> Type() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldDescriptorProto_Type) }
6850
- } /* namespace FieldDescriptorProto */
6851
- } /* namespace protobuf */
6852
- } /* namespace google */
7232
+ static OneofDescriptorProto get() {
7233
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_OneofDescriptorProto_get(&m);
7234
+ return OneofDescriptorProto(m, &m);
7235
+ }
7236
+ };
6853
7237
 
6854
- namespace google {
6855
- namespace protobuf {
6856
- namespace FieldOptions {
6857
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FieldOptions) }
6858
- inline upb::reffed_ptr<const upb::FieldDef> ctype() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_ctype) }
6859
- inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_deprecated) }
6860
- inline upb::reffed_ptr<const upb::FieldDef> experimental_map_key() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_experimental_map_key) }
6861
- inline upb::reffed_ptr<const upb::FieldDef> lazy() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_lazy) }
6862
- inline upb::reffed_ptr<const upb::FieldDef> packed() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_packed) }
6863
- inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_uninterpreted_option) }
6864
- inline upb::reffed_ptr<const upb::FieldDef> weak() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_weak) }
6865
- inline upb::reffed_ptr<const upb::EnumDef> CType() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldOptions_CType) }
6866
- } /* namespace FieldOptions */
6867
- } /* namespace protobuf */
6868
- } /* namespace google */
7238
+ class ServiceDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7239
+ public:
7240
+ ServiceDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7241
+ : reffed_ptr(m, ref_donor) {
7242
+ assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m));
7243
+ }
6869
7244
 
6870
- namespace google {
6871
- namespace protobuf {
6872
- namespace FileDescriptorProto {
6873
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FileDescriptorProto) }
6874
- inline upb::reffed_ptr<const upb::FieldDef> dependency() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_dependency) }
6875
- inline upb::reffed_ptr<const upb::FieldDef> enum_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_enum_type) }
6876
- inline upb::reffed_ptr<const upb::FieldDef> extension() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_extension) }
6877
- inline upb::reffed_ptr<const upb::FieldDef> message_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_message_type) }
6878
- inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_name) }
6879
- inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_options) }
6880
- inline upb::reffed_ptr<const upb::FieldDef> package() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_package) }
6881
- inline upb::reffed_ptr<const upb::FieldDef> public_dependency() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_public_dependency) }
6882
- inline upb::reffed_ptr<const upb::FieldDef> service() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_service) }
6883
- inline upb::reffed_ptr<const upb::FieldDef> source_code_info() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_source_code_info) }
6884
- inline upb::reffed_ptr<const upb::FieldDef> weak_dependency() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_weak_dependency) }
6885
- } /* namespace FileDescriptorProto */
6886
- } /* namespace protobuf */
6887
- } /* namespace google */
7245
+ static ServiceDescriptorProto get() {
7246
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_ServiceDescriptorProto_get(&m);
7247
+ return ServiceDescriptorProto(m, &m);
7248
+ }
7249
+ };
6888
7250
 
6889
- namespace google {
6890
- namespace protobuf {
6891
- namespace FileDescriptorSet {
6892
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FileDescriptorSet) }
6893
- inline upb::reffed_ptr<const upb::FieldDef> file() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorSet_file) }
6894
- } /* namespace FileDescriptorSet */
6895
- } /* namespace protobuf */
6896
- } /* namespace google */
7251
+ class ServiceOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7252
+ public:
7253
+ ServiceOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7254
+ : reffed_ptr(m, ref_donor) {
7255
+ assert(upbdefs_google_protobuf_ServiceOptions_is(m));
7256
+ }
6897
7257
 
6898
- namespace google {
6899
- namespace protobuf {
6900
- namespace FileOptions {
6901
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FileOptions) }
6902
- inline upb::reffed_ptr<const upb::FieldDef> cc_generic_services() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_cc_generic_services) }
6903
- inline upb::reffed_ptr<const upb::FieldDef> go_package() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_go_package) }
6904
- inline upb::reffed_ptr<const upb::FieldDef> java_generate_equals_and_hash() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_generate_equals_and_hash) }
6905
- inline upb::reffed_ptr<const upb::FieldDef> java_generic_services() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_generic_services) }
6906
- inline upb::reffed_ptr<const upb::FieldDef> java_multiple_files() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_multiple_files) }
6907
- inline upb::reffed_ptr<const upb::FieldDef> java_outer_classname() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_outer_classname) }
6908
- inline upb::reffed_ptr<const upb::FieldDef> java_package() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_package) }
6909
- inline upb::reffed_ptr<const upb::FieldDef> optimize_for() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_optimize_for) }
6910
- inline upb::reffed_ptr<const upb::FieldDef> py_generic_services() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_py_generic_services) }
6911
- inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_uninterpreted_option) }
6912
- inline upb::reffed_ptr<const upb::EnumDef> OptimizeMode() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FileOptions_OptimizeMode) }
6913
- } /* namespace FileOptions */
6914
- } /* namespace protobuf */
6915
- } /* namespace google */
7258
+ static ServiceOptions get() {
7259
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_ServiceOptions_get(&m);
7260
+ return ServiceOptions(m, &m);
7261
+ }
7262
+ };
6916
7263
 
6917
- namespace google {
6918
- namespace protobuf {
6919
- namespace MessageOptions {
6920
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_MessageOptions) }
6921
- inline upb::reffed_ptr<const upb::FieldDef> message_set_wire_format() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_message_set_wire_format) }
6922
- inline upb::reffed_ptr<const upb::FieldDef> no_standard_descriptor_accessor() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_no_standard_descriptor_accessor) }
6923
- inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_uninterpreted_option) }
6924
- } /* namespace MessageOptions */
6925
- } /* namespace protobuf */
6926
- } /* namespace google */
7264
+ class SourceCodeInfo : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7265
+ public:
7266
+ SourceCodeInfo(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7267
+ : reffed_ptr(m, ref_donor) {
7268
+ assert(upbdefs_google_protobuf_SourceCodeInfo_is(m));
7269
+ }
6927
7270
 
6928
- namespace google {
6929
- namespace protobuf {
6930
- namespace MethodDescriptorProto {
6931
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_MethodDescriptorProto) }
6932
- inline upb::reffed_ptr<const upb::FieldDef> input_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_input_type) }
6933
- inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_name) }
6934
- inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_options) }
6935
- inline upb::reffed_ptr<const upb::FieldDef> output_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_output_type) }
6936
- } /* namespace MethodDescriptorProto */
6937
- } /* namespace protobuf */
6938
- } /* namespace google */
7271
+ static SourceCodeInfo get() {
7272
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_SourceCodeInfo_get(&m);
7273
+ return SourceCodeInfo(m, &m);
7274
+ }
6939
7275
 
6940
- namespace google {
6941
- namespace protobuf {
6942
- namespace MethodOptions {
6943
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_MethodOptions) }
6944
- inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodOptions_uninterpreted_option) }
6945
- } /* namespace MethodOptions */
6946
- } /* namespace protobuf */
6947
- } /* namespace google */
7276
+ class Location : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7277
+ public:
7278
+ Location(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7279
+ : reffed_ptr(m, ref_donor) {
7280
+ assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m));
7281
+ }
6948
7282
 
6949
- namespace google {
6950
- namespace protobuf {
6951
- namespace ServiceDescriptorProto {
6952
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_ServiceDescriptorProto) }
6953
- inline upb::reffed_ptr<const upb::FieldDef> method() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_ServiceDescriptorProto_method) }
6954
- inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_ServiceDescriptorProto_name) }
6955
- inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_ServiceDescriptorProto_options) }
6956
- } /* namespace ServiceDescriptorProto */
6957
- } /* namespace protobuf */
6958
- } /* namespace google */
7283
+ static Location get() {
7284
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_SourceCodeInfo_Location_get(&m);
7285
+ return Location(m, &m);
7286
+ }
7287
+ };
7288
+ };
6959
7289
 
6960
- namespace google {
6961
- namespace protobuf {
6962
- namespace ServiceOptions {
6963
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_ServiceOptions) }
6964
- inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_ServiceOptions_uninterpreted_option) }
6965
- } /* namespace ServiceOptions */
6966
- } /* namespace protobuf */
6967
- } /* namespace google */
7290
+ class UninterpretedOption : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7291
+ public:
7292
+ UninterpretedOption(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7293
+ : reffed_ptr(m, ref_donor) {
7294
+ assert(upbdefs_google_protobuf_UninterpretedOption_is(m));
7295
+ }
6968
7296
 
6969
- namespace google {
6970
- namespace protobuf {
6971
- namespace SourceCodeInfo {
6972
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_SourceCodeInfo) }
6973
- inline upb::reffed_ptr<const upb::FieldDef> location() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_location) }
6974
- } /* namespace SourceCodeInfo */
6975
- } /* namespace protobuf */
6976
- } /* namespace google */
7297
+ static UninterpretedOption get() {
7298
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_UninterpretedOption_get(&m);
7299
+ return UninterpretedOption(m, &m);
7300
+ }
6977
7301
 
6978
- namespace google {
6979
- namespace protobuf {
6980
- namespace SourceCodeInfo {
6981
- namespace Location {
6982
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_SourceCodeInfo_Location) }
6983
- inline upb::reffed_ptr<const upb::FieldDef> leading_comments() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_leading_comments) }
6984
- inline upb::reffed_ptr<const upb::FieldDef> path() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_path) }
6985
- inline upb::reffed_ptr<const upb::FieldDef> span() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_span) }
6986
- inline upb::reffed_ptr<const upb::FieldDef> trailing_comments() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_trailing_comments) }
6987
- } /* namespace Location */
6988
- } /* namespace SourceCodeInfo */
6989
- } /* namespace protobuf */
6990
- } /* namespace google */
7302
+ class NamePart : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7303
+ public:
7304
+ NamePart(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7305
+ : reffed_ptr(m, ref_donor) {
7306
+ assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m));
7307
+ }
6991
7308
 
6992
- namespace google {
6993
- namespace protobuf {
6994
- namespace UninterpretedOption {
6995
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_UninterpretedOption) }
6996
- inline upb::reffed_ptr<const upb::FieldDef> aggregate_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_aggregate_value) }
6997
- inline upb::reffed_ptr<const upb::FieldDef> double_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_double_value) }
6998
- inline upb::reffed_ptr<const upb::FieldDef> identifier_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_identifier_value) }
6999
- inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_name) }
7000
- inline upb::reffed_ptr<const upb::FieldDef> negative_int_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_negative_int_value) }
7001
- inline upb::reffed_ptr<const upb::FieldDef> positive_int_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_positive_int_value) }
7002
- inline upb::reffed_ptr<const upb::FieldDef> string_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_string_value) }
7003
- } /* namespace UninterpretedOption */
7004
- } /* namespace protobuf */
7005
- } /* namespace google */
7309
+ static NamePart get() {
7310
+ const ::upb::MessageDef* m = upbdefs_google_protobuf_UninterpretedOption_NamePart_get(&m);
7311
+ return NamePart(m, &m);
7312
+ }
7313
+ };
7314
+ };
7006
7315
 
7007
- namespace google {
7008
- namespace protobuf {
7009
- namespace UninterpretedOption {
7010
- namespace NamePart {
7011
- inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_UninterpretedOption_NamePart) }
7012
- inline upb::reffed_ptr<const upb::FieldDef> is_extension() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_NamePart_is_extension) }
7013
- inline upb::reffed_ptr<const upb::FieldDef> name_part() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_NamePart_name_part) }
7014
- } /* namespace NamePart */
7015
- } /* namespace UninterpretedOption */
7016
7316
  } /* namespace protobuf */
7017
7317
  } /* namespace google */
7018
-
7019
7318
  } /* namespace upbdefs */
7020
7319
 
7320
+ #endif /* __cplusplus */
7021
7321
 
7022
- #undef RETURN_REFFED
7023
- #endif /* __cplusplus */
7024
-
7025
- #endif /* GOOGLE_PROTOBUF_DESCRIPTOR_UPB_H_ */
7322
+ #endif /* UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_ */
7026
7323
  /*
7027
7324
  ** Internal-only definitions for the decoder.
7028
7325
  */
@@ -7030,7 +7327,6 @@ inline upb::reffed_ptr<const upb::FieldDef> name_part() { RETURN_REFFED(upb::Fie
7030
7327
  #ifndef UPB_DECODER_INT_H_
7031
7328
  #define UPB_DECODER_INT_H_
7032
7329
 
7033
- #include <stdlib.h>
7034
7330
  /*
7035
7331
  ** upb::pb::Decoder
7036
7332
  **
@@ -7067,6 +7363,13 @@ UPB_DECLARE_TYPE(upb::pb::DecoderMethodOptions, upb_pbdecodermethodopts)
7067
7363
  UPB_DECLARE_DERIVED_TYPE(upb::pb::DecoderMethod, upb::RefCounted,
7068
7364
  upb_pbdecodermethod, upb_refcounted)
7069
7365
 
7366
+ /* The maximum number of bytes we are required to buffer internally between
7367
+ * calls to the decoder. The value is 14: a 5 byte unknown tag plus ten-byte
7368
+ * varint, less one because we are buffering an incomplete value.
7369
+ *
7370
+ * Should only be used by unit tests. */
7371
+ #define UPB_DECODER_MAX_RESIDUAL_BYTES 14
7372
+
7070
7373
  #ifdef __cplusplus
7071
7374
 
7072
7375
  /* The parameters one uses to construct a DecoderMethod.
@@ -7123,7 +7426,7 @@ class upb::pb::DecoderMethod {
7123
7426
  * constructed. This hint may be an overestimate for some build configurations.
7124
7427
  * But if the decoder library is upgraded without recompiling the application,
7125
7428
  * it may be an underestimate. */
7126
- #define UPB_PB_DECODER_SIZE 4408
7429
+ #define UPB_PB_DECODER_SIZE 4416
7127
7430
 
7128
7431
  #ifdef __cplusplus
7129
7432
 
@@ -7541,11 +7844,8 @@ struct upb_pbdecoder {
7541
7844
  /* Overall stream offset of "buf." */
7542
7845
  uint64_t bufstart_ofs;
7543
7846
 
7544
- /* Buffer for residual bytes not parsed from the previous buffer.
7545
- * The maximum number of residual bytes we require is 12; a five-byte
7546
- * unknown tag plus an eight-byte value, less one because the value
7547
- * is only a partial value. */
7548
- char residual[12];
7847
+ /* Buffer for residual bytes not parsed from the previous buffer. */
7848
+ char residual[UPB_DECODER_MAX_RESIDUAL_BYTES];
7549
7849
  char *residual_end;
7550
7850
 
7551
7851
  /* Bytes of data that should be discarded from the input beore we start
@@ -7939,49 +8239,44 @@ inline reffed_ptr<const Handlers> Encoder::NewHandlers(
7939
8239
  #include <stdbool.h>
7940
8240
 
7941
8241
  #ifdef __cplusplus
8242
+ #include <vector>
8243
+
7942
8244
  extern "C" {
7943
8245
  #endif
7944
8246
 
7945
- /* Loads all defs from the given protobuf binary descriptor, setting default
7946
- * accessors and a default layout on all messages. The caller owns the
7947
- * returned array of defs, which will be of length *n. On error NULL is
7948
- * returned and status is set (if non-NULL). */
7949
- upb_def **upb_load_defs_from_descriptor(const char *str, size_t len, int *n,
7950
- void *owner, upb_status *status);
7951
-
7952
- /* Like the previous but also adds the loaded defs to the given symtab. */
7953
- bool upb_load_descriptor_into_symtab(upb_symtab *symtab, const char *str,
7954
- size_t len, upb_status *status);
7955
-
7956
- /* Like the previous but also reads the descriptor from the given filename. */
7957
- bool upb_load_descriptor_file_into_symtab(upb_symtab *symtab, const char *fname,
7958
- upb_status *status);
7959
-
7960
- /* Reads the given filename into a character string, returning NULL if there
7961
- * was an error. */
7962
- char *upb_readfile(const char *filename, size_t *len);
8247
+ /* Loads a binary descriptor and returns a NULL-terminated array of unfrozen
8248
+ * filedefs. The caller owns the returned array, which must be freed with
8249
+ * upb_gfree(). */
8250
+ upb_filedef **upb_loaddescriptor(const char *buf, size_t n, const void *owner,
8251
+ upb_status *status);
7963
8252
 
7964
8253
  #ifdef __cplusplus
7965
8254
  } /* extern "C" */
7966
8255
 
7967
8256
  namespace upb {
7968
8257
 
7969
- /* All routines that load descriptors expect the descriptor to be a
7970
- * FileDescriptorSet. */
7971
- inline bool LoadDescriptorFileIntoSymtab(SymbolTable* s, const char *fname,
7972
- Status* status) {
7973
- return upb_load_descriptor_file_into_symtab(s, fname, status);
7974
- }
8258
+ inline bool LoadDescriptor(const char* buf, size_t n, Status* status,
8259
+ std::vector<reffed_ptr<FileDef> >* files) {
8260
+ FileDef** parsed_files = upb_loaddescriptor(buf, n, &parsed_files, status);
7975
8261
 
7976
- inline bool LoadDescriptorIntoSymtab(SymbolTable* s, const char* str,
7977
- size_t len, Status* status) {
7978
- return upb_load_descriptor_into_symtab(s, str, len, status);
8262
+ if (parsed_files) {
8263
+ FileDef** p = parsed_files;
8264
+ while (*p) {
8265
+ files->push_back(reffed_ptr<FileDef>(*p, &parsed_files));
8266
+ ++p;
8267
+ }
8268
+ free(parsed_files);
8269
+ return true;
8270
+ } else {
8271
+ return false;
8272
+ }
7979
8273
  }
7980
8274
 
7981
8275
  /* Templated so it can accept both string and std::string. */
7982
8276
  template <typename T>
7983
- bool LoadDescriptorIntoSymtab(SymbolTable* s, const T& desc, Status* status) {
7984
- return upb_load_descriptor_into_symtab(s, desc.c_str(), desc.size(), status);
8277
+ bool LoadDescriptor(const T& desc, Status* status,
8278
+ std::vector<reffed_ptr<FileDef> >* files) {
8279
+ return LoadDescriptor(desc.c_str(), desc.size(), status, files);
7985
8280
  }
7986
8281
 
7987
8282
  } /* namespace upb */
@@ -8083,11 +8378,14 @@ inline reffed_ptr<const Handlers> TextPrinter::NewHandlers(
8083
8378
  namespace upb {
8084
8379
  namespace json {
8085
8380
  class Parser;
8381
+ class ParserMethod;
8086
8382
  } /* namespace json */
8087
8383
  } /* namespace upb */
8088
8384
  #endif
8089
8385
 
8090
8386
  UPB_DECLARE_TYPE(upb::json::Parser, upb_json_parser)
8387
+ UPB_DECLARE_DERIVED_TYPE(upb::json::ParserMethod, upb::RefCounted,
8388
+ upb_json_parsermethod, upb_refcounted)
8091
8389
 
8092
8390
  /* upb::json::Parser **********************************************************/
8093
8391
 
@@ -8095,7 +8393,7 @@ UPB_DECLARE_TYPE(upb::json::Parser, upb_json_parser)
8095
8393
  * constructed. This hint may be an overestimate for some build configurations.
8096
8394
  * But if the parser library is upgraded without recompiling the application,
8097
8395
  * it may be an underestimate. */
8098
- #define UPB_JSON_PARSER_SIZE 3704
8396
+ #define UPB_JSON_PARSER_SIZE 4112
8099
8397
 
8100
8398
  #ifdef __cplusplus
8101
8399
 
@@ -8103,7 +8401,8 @@ UPB_DECLARE_TYPE(upb::json::Parser, upb_json_parser)
8103
8401
  * sink. */
8104
8402
  class upb::json::Parser {
8105
8403
  public:
8106
- static Parser* Create(Environment* env, Sink* output);
8404
+ static Parser* Create(Environment* env, const ParserMethod* method,
8405
+ Sink* output);
8107
8406
 
8108
8407
  BytesSink* input();
8109
8408
 
@@ -8111,25 +8410,72 @@ class upb::json::Parser {
8111
8410
  UPB_DISALLOW_POD_OPS(Parser, upb::json::Parser)
8112
8411
  };
8113
8412
 
8413
+ class upb::json::ParserMethod {
8414
+ public:
8415
+ /* Include base methods from upb::ReferenceCounted. */
8416
+ UPB_REFCOUNTED_CPPMETHODS
8417
+
8418
+ /* Returns handlers for parsing according to the specified schema. */
8419
+ static reffed_ptr<const ParserMethod> New(const upb::MessageDef* md);
8420
+
8421
+ /* The destination handlers that are statically bound to this method.
8422
+ * This method is only capable of outputting to a sink that uses these
8423
+ * handlers. */
8424
+ const Handlers* dest_handlers() const;
8425
+
8426
+ /* The input handlers for this decoder method. */
8427
+ const BytesHandler* input_handler() const;
8428
+
8429
+ private:
8430
+ UPB_DISALLOW_POD_OPS(ParserMethod, upb::json::ParserMethod)
8431
+ };
8432
+
8114
8433
  #endif
8115
8434
 
8116
8435
  UPB_BEGIN_EXTERN_C
8117
8436
 
8118
- upb_json_parser *upb_json_parser_create(upb_env *e, upb_sink *output);
8437
+ upb_json_parser* upb_json_parser_create(upb_env* e,
8438
+ const upb_json_parsermethod* m,
8439
+ upb_sink* output);
8119
8440
  upb_bytessink *upb_json_parser_input(upb_json_parser *p);
8120
8441
 
8442
+ upb_json_parsermethod* upb_json_parsermethod_new(const upb_msgdef* md,
8443
+ const void* owner);
8444
+ const upb_handlers *upb_json_parsermethod_desthandlers(
8445
+ const upb_json_parsermethod *m);
8446
+ const upb_byteshandler *upb_json_parsermethod_inputhandler(
8447
+ const upb_json_parsermethod *m);
8448
+
8449
+ /* Include refcounted methods like upb_json_parsermethod_ref(). */
8450
+ UPB_REFCOUNTED_CMETHODS(upb_json_parsermethod, upb_json_parsermethod_upcast)
8451
+
8121
8452
  UPB_END_EXTERN_C
8122
8453
 
8123
8454
  #ifdef __cplusplus
8124
8455
 
8125
8456
  namespace upb {
8126
8457
  namespace json {
8127
- inline Parser* Parser::Create(Environment* env, Sink* output) {
8128
- return upb_json_parser_create(env, output);
8458
+ inline Parser* Parser::Create(Environment* env, const ParserMethod* method,
8459
+ Sink* output) {
8460
+ return upb_json_parser_create(env, method, output);
8129
8461
  }
8130
8462
  inline BytesSink* Parser::input() {
8131
8463
  return upb_json_parser_input(this);
8132
8464
  }
8465
+
8466
+ inline const Handlers* ParserMethod::dest_handlers() const {
8467
+ return upb_json_parsermethod_desthandlers(this);
8468
+ }
8469
+ inline const BytesHandler* ParserMethod::input_handler() const {
8470
+ return upb_json_parsermethod_inputhandler(this);
8471
+ }
8472
+ /* static */
8473
+ inline reffed_ptr<const ParserMethod> ParserMethod::New(
8474
+ const MessageDef* md) {
8475
+ const upb_json_parsermethod *m = upb_json_parsermethod_new(md, &m);
8476
+ return reffed_ptr<const ParserMethod>(m, &m);
8477
+ }
8478
+
8133
8479
  } /* namespace json */
8134
8480
  } /* namespace upb */
8135
8481
 
@@ -8160,7 +8506,7 @@ UPB_DECLARE_TYPE(upb::json::Printer, upb_json_printer)
8160
8506
 
8161
8507
  /* upb::json::Printer *********************************************************/
8162
8508
 
8163
- #define UPB_JSON_PRINTER_SIZE 168
8509
+ #define UPB_JSON_PRINTER_SIZE 176
8164
8510
 
8165
8511
  #ifdef __cplusplus
8166
8512
 
@@ -8173,8 +8519,12 @@ class upb::json::Printer {
8173
8519
  /* The input to the printer. */
8174
8520
  Sink* input();
8175
8521
 
8176
- /* Returns handlers for printing according to the specified schema. */
8177
- static reffed_ptr<const Handlers> NewHandlers(const upb::MessageDef* md);
8522
+ /* Returns handlers for printing according to the specified schema.
8523
+ * If preserve_proto_fieldnames is true, the output JSON will use the
8524
+ * original .proto field names (ie. {"my_field":3}) instead of using
8525
+ * camelCased names, which is the default: (eg. {"myField":3}). */
8526
+ static reffed_ptr<const Handlers> NewHandlers(const upb::MessageDef* md,
8527
+ bool preserve_proto_fieldnames);
8178
8528
 
8179
8529
  static const size_t kSize = UPB_JSON_PRINTER_SIZE;
8180
8530
 
@@ -8191,6 +8541,7 @@ upb_json_printer *upb_json_printer_create(upb_env *e, const upb_handlers *h,
8191
8541
  upb_bytessink *output);
8192
8542
  upb_sink *upb_json_printer_input(upb_json_printer *p);
8193
8543
  const upb_handlers *upb_json_printer_newhandlers(const upb_msgdef *md,
8544
+ bool preserve_fieldnames,
8194
8545
  const void *owner);
8195
8546
 
8196
8547
  UPB_END_EXTERN_C
@@ -8205,8 +8556,9 @@ inline Printer* Printer::Create(Environment* env, const upb::Handlers* handlers,
8205
8556
  }
8206
8557
  inline Sink* Printer::input() { return upb_json_printer_input(this); }
8207
8558
  inline reffed_ptr<const Handlers> Printer::NewHandlers(
8208
- const upb::MessageDef *md) {
8209
- const Handlers* h = upb_json_printer_newhandlers(md, &h);
8559
+ const upb::MessageDef *md, bool preserve_proto_fieldnames) {
8560
+ const Handlers* h = upb_json_printer_newhandlers(
8561
+ md, preserve_proto_fieldnames, &h);
8210
8562
  return reffed_ptr<const Handlers>(h, &h);
8211
8563
  }
8212
8564
  } /* namespace json */