Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: third_party/protobuf/php/ext/google/protobuf/upb.h

Issue 2600753002: Reverts third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Amalgamated source file 1 // Amalgamated source file
2 /* 2 /*
3 ** Defs are upb's internal representation of the constructs that can appear 3 ** Defs are upb's internal representation of the constructs that can appear
4 ** in a .proto file: 4 ** in a .proto file:
5 ** 5 **
6 ** - upb::MessageDef (upb_msgdef): describes a "message" construct. 6 ** - upb::MessageDef (upb_msgdef): describes a "message" construct.
7 ** - upb::FieldDef (upb_fielddef): describes a message field. 7 ** - upb::FieldDef (upb_fielddef): describes a message field.
8 ** - upb::FileDef (upb_filedef): describes a .proto file and its defs.
9 ** - upb::EnumDef (upb_enumdef): describes an enum. 8 ** - upb::EnumDef (upb_enumdef): describes an enum.
10 ** - upb::OneofDef (upb_oneofdef): describes a oneof. 9 ** - upb::OneofDef (upb_oneofdef): describes a oneof.
11 ** - upb::Def (upb_def): base class of all the others. 10 ** - upb::Def (upb_def): base class of all the others.
12 ** 11 **
13 ** TODO: definitions of services. 12 ** TODO: definitions of services.
14 ** 13 **
15 ** Like upb_refcounted objects, defs are mutable only until frozen, and are 14 ** Like upb_refcounted objects, defs are mutable only until frozen, and are
16 ** only thread-safe once frozen. 15 ** only thread-safe once frozen.
17 ** 16 **
18 ** This is a mixed C/C++ interface that offers a full API to both languages. 17 ** This is a mixed C/C++ interface that offers a full API to both languages.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 ** store pointers or integers of at least 32 bits (upb isn't really useful on 54 ** store pointers or integers of at least 32 bits (upb isn't really useful on
56 ** systems where sizeof(void*) < 4). 55 ** systems where sizeof(void*) < 4).
57 ** 56 **
58 ** The table must be homogenous (all values of the same type). In debug 57 ** The table must be homogenous (all values of the same type). In debug
59 ** mode, we check this on insert and lookup. 58 ** mode, we check this on insert and lookup.
60 */ 59 */
61 60
62 #ifndef UPB_TABLE_H_ 61 #ifndef UPB_TABLE_H_
63 #define UPB_TABLE_H_ 62 #define UPB_TABLE_H_
64 63
65 // php.h intentionally defined NDEBUG. We have to define this macro in order to 64 #include <assert.h>
66 // be used together with php.h
67 #ifndef NDEBUG
68 #define NDEBUG
69 #endif
70
71 #include <stdint.h> 65 #include <stdint.h>
72 #include <string.h> 66 #include <string.h>
73 /* 67 /*
74 ** This file contains shared definitions that are widely used across upb. 68 ** This file contains shared definitions that are widely used across upb.
75 ** 69 **
76 ** This is a mixed C/C++ interface that offers a full API to both languages. 70 ** This is a mixed C/C++ interface that offers a full API to both languages.
77 ** See the top-level README for more information. 71 ** See the top-level README for more information.
78 */ 72 */
79 73
80 #ifndef UPB_H_ 74 #ifndef UPB_H_
81 #define UPB_H_ 75 #define UPB_H_
82 76
83 #include <assert.h> 77 #include <assert.h>
84 #include <stdarg.h> 78 #include <stdarg.h>
85 #include <stdbool.h> 79 #include <stdbool.h>
86 #include <stddef.h> 80 #include <stddef.h>
87 81
88 #ifdef __cplusplus
89 namespace upb {
90 class Allocator;
91 class Arena;
92 class Environment;
93 class ErrorSpace;
94 class Status;
95 template <int N> class InlinedArena;
96 template <int N> class InlinedEnvironment;
97 }
98 #endif
99
100 /* UPB_INLINE: inline if possible, emit standalone code if required. */ 82 /* UPB_INLINE: inline if possible, emit standalone code if required. */
101 #ifdef __cplusplus 83 #ifdef __cplusplus
102 #define UPB_INLINE inline 84 #define UPB_INLINE inline
103 #elif defined (__GNUC__) 85 #elif defined (__GNUC__)
104 #define UPB_INLINE static __inline__ 86 #define UPB_INLINE static __inline__
105 #else 87 #else
106 #define UPB_INLINE static 88 #define UPB_INLINE static
107 #endif 89 #endif
108 90
109 /* Define UPB_BIG_ENDIAN manually if you're on big endian and your compiler 91 /* Define UPB_BIG_ENDIAN manually if you're on big endian and your compiler
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 #define UPB_DISALLOW_COPY_AND_ASSIGN(class_name) \ 139 #define UPB_DISALLOW_COPY_AND_ASSIGN(class_name) \
158 class_name(const class_name&) = delete; \ 140 class_name(const class_name&) = delete; \
159 void operator=(const class_name&) = delete; 141 void operator=(const class_name&) = delete;
160 #define UPB_DISALLOW_POD_OPS(class_name, full_class_name) \ 142 #define UPB_DISALLOW_POD_OPS(class_name, full_class_name) \
161 class_name() = delete; \ 143 class_name() = delete; \
162 ~class_name() = delete; \ 144 ~class_name() = delete; \
163 UPB_DISALLOW_COPY_AND_ASSIGN(class_name) 145 UPB_DISALLOW_COPY_AND_ASSIGN(class_name)
164 #define UPB_ASSERT_STDLAYOUT(type) \ 146 #define UPB_ASSERT_STDLAYOUT(type) \
165 static_assert(std::is_standard_layout<type>::value, \ 147 static_assert(std::is_standard_layout<type>::value, \
166 #type " must be standard layout"); 148 #type " must be standard layout");
167 #define UPB_FINAL final
168 #else /* !defined(UPB_CXX11) */ 149 #else /* !defined(UPB_CXX11) */
169 #define UPB_DISALLOW_COPY_AND_ASSIGN(class_name) \ 150 #define UPB_DISALLOW_COPY_AND_ASSIGN(class_name) \
170 class_name(const class_name&); \ 151 class_name(const class_name&); \
171 void operator=(const class_name&); 152 void operator=(const class_name&);
172 #define UPB_DISALLOW_POD_OPS(class_name, full_class_name) \ 153 #define UPB_DISALLOW_POD_OPS(class_name, full_class_name) \
173 class_name(); \ 154 class_name(); \
174 ~class_name(); \ 155 ~class_name(); \
175 UPB_DISALLOW_COPY_AND_ASSIGN(class_name) 156 UPB_DISALLOW_COPY_AND_ASSIGN(class_name)
176 #define UPB_ASSERT_STDLAYOUT(type) 157 #define UPB_ASSERT_STDLAYOUT(type)
177 #define UPB_FINAL
178 #endif 158 #endif
179 159
180 /* UPB_DECLARE_TYPE() 160 /* UPB_DECLARE_TYPE()
181 * UPB_DECLARE_DERIVED_TYPE() 161 * UPB_DECLARE_DERIVED_TYPE()
182 * UPB_DECLARE_DERIVED_TYPE2() 162 * UPB_DECLARE_DERIVED_TYPE2()
183 * 163 *
184 * Macros for declaring C and C++ types both, including inheritance. 164 * Macros for declaring C and C++ types both, including inheritance.
185 * The inheritance doesn't use real C++ inheritance, to stay compatible with C. 165 * The inheritance doesn't use real C++ inheritance, to stay compatible with C.
186 * 166 *
187 * These macros also provide upcasts: 167 * These macros also provide upcasts:
(...skipping 18 matching lines...) Expand all
206 #define UPB_PRIVATE_FOR_CPP private: 186 #define UPB_PRIVATE_FOR_CPP private:
207 #define UPB_DECLARE_TYPE(cppname, cname) typedef cppname cname; 187 #define UPB_DECLARE_TYPE(cppname, cname) typedef cppname cname;
208 188
209 #define UPB_DECLARE_DERIVED_TYPE(cppname, cppbase, cname, cbase) \ 189 #define UPB_DECLARE_DERIVED_TYPE(cppname, cppbase, cname, cbase) \
210 UPB_DECLARE_TYPE(cppname, cname) \ 190 UPB_DECLARE_TYPE(cppname, cname) \
211 UPB_C_UPCASTS(cname, cbase) \ 191 UPB_C_UPCASTS(cname, cbase) \
212 namespace upb { \ 192 namespace upb { \
213 template <> \ 193 template <> \
214 class Pointer<cppname> : public PointerBase<cppname, cppbase> { \ 194 class Pointer<cppname> : public PointerBase<cppname, cppbase> { \
215 public: \ 195 public: \
216 explicit Pointer(cppname* ptr) \ 196 explicit Pointer(cppname* ptr) : PointerBase(ptr) {} \
217 : PointerBase<cppname, cppbase>(ptr) {} \
218 }; \ 197 }; \
219 template <> \ 198 template <> \
220 class Pointer<const cppname> \ 199 class Pointer<const cppname> \
221 : public PointerBase<const cppname, const cppbase> { \ 200 : public PointerBase<const cppname, const cppbase> { \
222 public: \ 201 public: \
223 explicit Pointer(const cppname* ptr) \ 202 explicit Pointer(const cppname* ptr) : PointerBase(ptr) {} \
224 : PointerBase<const cppname, const cppbase>(ptr) {} \
225 }; \ 203 }; \
226 } 204 }
227 205
228 #define UPB_DECLARE_DERIVED_TYPE2(cppname, cppbase, cppbase2, cname, cbase, \ 206 #define UPB_DECLARE_DERIVED_TYPE2(cppname, cppbase, cppbase2, cname, cbase, \
229 cbase2) \ 207 cbase2) \
230 UPB_DECLARE_TYPE(cppname, cname) \ 208 UPB_DECLARE_TYPE(cppname, cname) \
231 UPB_C_UPCASTS2(cname, cbase, cbase2) \ 209 UPB_C_UPCASTS2(cname, cbase, cbase2) \
232 namespace upb { \ 210 namespace upb { \
233 template <> \ 211 template <> \
234 class Pointer<cppname> : public PointerBase2<cppname, cppbase, cppbase2> { \ 212 class Pointer<cppname> : public PointerBase2<cppname, cppbase, cppbase2> { \
235 public: \ 213 public: \
236 explicit Pointer(cppname* ptr) \ 214 explicit Pointer(cppname* ptr) : PointerBase2(ptr) {} \
237 : PointerBase2<cppname, cppbase, cppbase2>(ptr) {} \
238 }; \ 215 }; \
239 template <> \ 216 template <> \
240 class Pointer<const cppname> \ 217 class Pointer<const cppname> \
241 : public PointerBase2<const cppname, const cppbase, const cppbase2> { \ 218 : public PointerBase2<const cppname, const cppbase, const cppbase2> { \
242 public: \ 219 public: \
243 explicit Pointer(const cppname* ptr) \ 220 explicit Pointer(const cppname* ptr) : PointerBase2(ptr) {} \
244 : PointerBase2<const cppname, const cppbase, const cppbase2>(ptr) {} \
245 }; \ 221 }; \
246 } 222 }
247 223
248 #else /* !defined(__cplusplus) */ 224 #else /* !defined(__cplusplus) */
249 225
250 #define UPB_BEGIN_EXTERN_C 226 #define UPB_BEGIN_EXTERN_C
251 #define UPB_END_EXTERN_C 227 #define UPB_END_EXTERN_C
252 #define UPB_PRIVATE_FOR_CPP 228 #define UPB_PRIVATE_FOR_CPP
253 #define UPB_DECLARE_TYPE(cppname, cname) \ 229 #define UPB_DECLARE_TYPE(cppname, cname) \
254 struct cname; \ 230 struct cname; \
255 typedef struct cname cname; 231 typedef struct cname cname;
256 #define UPB_DECLARE_DERIVED_TYPE(cppname, cppbase, cname, cbase) \ 232 #define UPB_DECLARE_DERIVED_TYPE(cppname, cppbase, cname, cbase) \
257 UPB_DECLARE_TYPE(cppname, cname) \ 233 UPB_DECLARE_TYPE(cppname, cname) \
258 UPB_C_UPCASTS(cname, cbase) 234 UPB_C_UPCASTS(cname, cbase)
259 #define UPB_DECLARE_DERIVED_TYPE2(cppname, cppbase, cppbase2, \ 235 #define UPB_DECLARE_DERIVED_TYPE2(cppname, cppbase, cppbase2, \
260 cname, cbase, cbase2) \ 236 cname, cbase, cbase2) \
261 UPB_DECLARE_TYPE(cppname, cname) \ 237 UPB_DECLARE_TYPE(cppname, cname) \
262 UPB_C_UPCASTS2(cname, cbase, cbase2) 238 UPB_C_UPCASTS2(cname, cbase, cbase2)
263 239
264 #endif /* defined(__cplusplus) */ 240 #endif /* defined(__cplusplus) */
265 241
266 #define UPB_MAX(x, y) ((x) > (y) ? (x) : (y)) 242 #define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
267 #define UPB_MIN(x, y) ((x) < (y) ? (x) : (y)) 243 #define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
268 244
269 #define UPB_UNUSED(var) (void)var 245 #define UPB_UNUSED(var) (void)var
270 246
271 /* UPB_ASSERT(): in release mode, we use the expression without letting it be 247 /* For asserting something about a variable when the variable is not used for
272 * evaluated. This prevents "unused variable" warnings. */ 248 * anything else. This prevents "unused variable" warnings when compiling in
273 #ifdef NDEBUG 249 * debug mode. */
274 #define UPB_ASSERT(expr) do {} while (false && (expr)) 250 #define UPB_ASSERT_VAR(var, predicate) UPB_UNUSED(var); assert(predicate)
275 #else
276 #define UPB_ASSERT(expr) assert(expr)
277 #endif
278
279 /* UPB_ASSERT_DEBUGVAR(): assert that uses functions or variables that only
280 * exist in debug mode. This turns into regular assert. */
281 #define UPB_ASSERT_DEBUGVAR(expr) assert(expr)
282 251
283 /* Generic function type. */ 252 /* Generic function type. */
284 typedef void upb_func(); 253 typedef void upb_func();
285 254
286
287 /* C++ Casts ******************************************************************/ 255 /* C++ Casts ******************************************************************/
288 256
289 #ifdef __cplusplus 257 #ifdef __cplusplus
290 258
291 namespace upb { 259 namespace upb {
292 260
293 template <class T> class Pointer; 261 template <class T> class Pointer;
294 262
295 /* Casts to a subclass. The caller must know that cast is correct; an 263 /* Casts to a subclass. The caller must know that cast is correct; an
296 * incorrect cast will throw an assertion failure in debug mode. 264 * incorrect cast will throw an assertion failure in debug mode.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 public: 322 public:
355 explicit PointerBase2(T* ptr) : PointerBase<T, Base>(ptr) {} 323 explicit PointerBase2(T* ptr) : PointerBase<T, Base>(ptr) {}
356 operator Base2*() { return Pointer<Base>(*this); } 324 operator Base2*() { return Pointer<Base>(*this); }
357 }; 325 };
358 326
359 } 327 }
360 328
361 #endif 329 #endif
362 330
363 331
364 /* upb::ErrorSpace ************************************************************/ 332 /* upb::reffed_ptr ************************************************************/
365 333
366 /* A upb::ErrorSpace represents some domain of possible error values. This lets 334 #ifdef __cplusplus
367 * upb::Status attach specific error codes to operations, like POSIX/C errno, 335
368 * Win32 error codes, etc. Clients who want to know the very specific error 336 #include <algorithm> /* For std::swap(). */
369 * code can check the error space and then know the type of the integer code. 337
370 * 338 namespace upb {
371 * NOTE: upb::ErrorSpace is currently not used and should be considered 339
372 * experimental. It is important primarily in cases where upb is performing 340 /* Provides RAII semantics for upb refcounted objects. Each reffed_ptr owns a
373 * I/O, but upb doesn't currently have any components that do this. */ 341 * ref on whatever object it points to (if any). */
342 template <class T> class reffed_ptr {
343 public:
344 reffed_ptr() : ptr_(NULL) {}
345
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 }
357
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 }
363
364 ~reffed_ptr() { if (ptr_) ptr_->Unref(this); }
365
366 template <class U>
367 reffed_ptr& operator=(const reffed_ptr<U>& other) {
368 reset(other.get());
369 return *this;
370 }
371
372 reffed_ptr& operator=(const reffed_ptr& other) {
373 reset(other.get());
374 return *this;
375 }
376
377 /* TODO(haberman): add C++11 move construction/assignment for greater
378 * efficiency. */
379
380 void swap(reffed_ptr& other) {
381 if (ptr_ == other.ptr_) {
382 return;
383 }
384
385 if (ptr_) ptr_->DonateRef(this, &other);
386 if (other.ptr_) other.ptr_->DonateRef(&other, this);
387 std::swap(ptr_, other.ptr_);
388 }
389
390 T& operator*() const {
391 assert(ptr_);
392 return *ptr_;
393 }
394
395 T* operator->() const {
396 assert(ptr_);
397 return ptr_;
398 }
399
400 T* get() const { return ptr_; }
401
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
408 template <class U>
409 reffed_ptr<U> down_cast() {
410 return reffed_ptr<U>(upb::down_cast<U*>(get()));
411 }
412
413 template <class U>
414 reffed_ptr<U> dyn_cast() {
415 return reffed_ptr<U>(upb::dyn_cast<U*>(get()));
416 }
417
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 }
426
427 private:
428 T* ptr_;
429 };
430
431 } /* namespace upb */
432
433 #endif /* __cplusplus */
434
435
436 /* upb::Status ****************************************************************/
437
438 #ifdef __cplusplus
439 namespace upb {
440 class ErrorSpace;
441 class Status;
442 }
443 #endif
374 444
375 UPB_DECLARE_TYPE(upb::ErrorSpace, upb_errorspace) 445 UPB_DECLARE_TYPE(upb::ErrorSpace, upb_errorspace)
446 UPB_DECLARE_TYPE(upb::Status, upb_status)
447
448 /* The maximum length of an error message before it will get truncated. */
449 #define UPB_STATUS_MAX_MESSAGE 128
450
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);
376 455
377 #ifdef __cplusplus 456 #ifdef __cplusplus
378 class upb::ErrorSpace { 457 class upb::ErrorSpace {
379 #else 458 #else
380 struct upb_errorspace { 459 struct upb_errorspace {
381 #endif 460 #endif
382 const char *name; 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);
383 }; 464 };
384 465
385 466 #ifdef __cplusplus
386 /* upb::Status ****************************************************************/ 467
387 468 /* Object representing a success or failure status.
388 /* upb::Status represents a success or failure status and error message.
389 * It owns no resources and allocates no memory, so it should work 469 * It owns no resources and allocates no memory, so it should work
390 * even in OOM situations. */ 470 * even in OOM situations. */
391 UPB_DECLARE_TYPE(upb::Status, upb_status) 471
392 472 class upb::Status {
393 /* The maximum length of an error message before it will get truncated. */ 473 public:
394 #define UPB_STATUS_MAX_MESSAGE 128 474 Status();
395 475
396 UPB_BEGIN_EXTERN_C 476 /* Returns true if there is no error. */
397 477 bool ok() const;
478
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;
483
484 const char *error_message() const;
485
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, ...);
490
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);
495
496 /* Resets the status to a successful state with no message. */
497 void Clear();
498
499 void CopyFrom(const Status& other);
500
501 private:
502 UPB_DISALLOW_COPY_AND_ASSIGN(Status)
503 #else
504 struct upb_status {
505 #endif
506 bool ok_;
507
508 /* Specific status code defined by some error space (optional). */
509 int code_;
510 upb_errorspace *error_space_;
511
512 /* Error message; NULL-terminated. */
513 char msg[UPB_STATUS_MAX_MESSAGE];
514 };
515
516 #define UPB_STATUS_INIT {true, 0, NULL, {0}}
517
518 #ifdef __cplusplus
519 extern "C" {
520 #endif
521
522 /* The returned string is invalidated by any other call into the status. */
398 const char *upb_status_errmsg(const upb_status *status); 523 const char *upb_status_errmsg(const upb_status *status);
399 bool upb_ok(const upb_status *status); 524 bool upb_ok(const upb_status *status);
400 upb_errorspace *upb_status_errspace(const upb_status *status); 525 upb_errorspace *upb_status_errspace(const upb_status *status);
401 int upb_status_errcode(const upb_status *status); 526 int upb_status_errcode(const upb_status *status);
402 527
403 /* Any of the functions that write to a status object allow status to be NULL, 528 /* Any of the functions that write to a status object allow status to be NULL,
404 * to support use cases where the function's caller does not care about the 529 * to support use cases where the function's caller does not care about the
405 * status message. */ 530 * status message. */
406 void upb_status_clear(upb_status *status); 531 void upb_status_clear(upb_status *status);
407 void upb_status_seterrmsg(upb_status *status, const char *msg); 532 void upb_status_seterrmsg(upb_status *status, const char *msg);
408 void upb_status_seterrf(upb_status *status, const char *fmt, ...); 533 void upb_status_seterrf(upb_status *status, const char *fmt, ...);
409 void upb_status_vseterrf(upb_status *status, const char *fmt, va_list args); 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);
410 void upb_status_copy(upb_status *to, const upb_status *from); 536 void upb_status_copy(upb_status *to, const upb_status *from);
411 537
412 UPB_END_EXTERN_C 538 #ifdef __cplusplus
413 539 } /* extern "C" */
414 #ifdef __cplusplus 540
415 541 namespace upb {
416 class upb::Status { 542
417 public: 543 /* C++ Wrappers */
418 Status() { upb_status_clear(this); } 544 inline Status::Status() { Clear(); }
419 545 inline bool Status::ok() const { return upb_ok(this); }
420 /* Returns true if there is no error. */ 546 inline const char* Status::error_message() const {
421 bool ok() const { return upb_ok(this); } 547 return upb_status_errmsg(this);
422 548 }
423 /* Optional error space and code, useful if the caller wants to 549 inline void Status::SetErrorMessage(const char* msg) {
424 * programmatically check the specific kind of error. */ 550 upb_status_seterrmsg(this, msg);
425 ErrorSpace* error_space() { return upb_status_errspace(this); } 551 }
426 int error_code() const { return upb_status_errcode(this); } 552 inline void Status::SetFormattedErrorMessage(const char* fmt, ...) {
427 553 va_list args;
428 /* The returned string is invalidated by any other call into the status. */ 554 va_start(args, fmt);
429 const char *error_message() const { return upb_status_errmsg(this); } 555 upb_status_vseterrf(this, fmt, args);
430 556 va_end(args);
431 /* The error message will be truncated if it is longer than 557 }
432 * UPB_STATUS_MAX_MESSAGE-4. */ 558 inline void Status::SetErrorCode(ErrorSpace* space, int code) {
433 void SetErrorMessage(const char* msg) { upb_status_seterrmsg(this, msg); } 559 upb_status_seterrcode(this, space, code);
434 void SetFormattedErrorMessage(const char* fmt, ...) { 560 }
435 va_list args; 561 inline void Status::Clear() { upb_status_clear(this); }
436 va_start(args, fmt); 562 inline void Status::CopyFrom(const Status& other) {
437 upb_status_vseterrf(this, fmt, args); 563 upb_status_copy(this, &other);
438 va_end(args); 564 }
439 } 565
440 566 } /* namespace upb */
441 /* Resets the status to a successful state with no message. */ 567
442 void Clear() { upb_status_clear(this); } 568 #endif
443
444 void CopyFrom(const Status& other) { upb_status_copy(this, &other); }
445
446 private:
447 UPB_DISALLOW_COPY_AND_ASSIGN(Status)
448 #else
449 struct upb_status {
450 #endif
451 bool ok_;
452
453 /* Specific status code defined by some error space (optional). */
454 int code_;
455 upb_errorspace *error_space_;
456
457 /* TODO(haberman): add file/line of error? */
458
459 /* Error message; NULL-terminated. */
460 char msg[UPB_STATUS_MAX_MESSAGE];
461 };
462
463 #define UPB_STATUS_INIT {true, 0, NULL, {0}}
464
465
466 /** Built-in error spaces. ****************************************************/
467
468 /* Errors raised by upb that we want to be able to detect programmatically. */
469 typedef enum {
470 UPB_NOMEM /* Can't reuse ENOMEM because it is POSIX, not ISO C. */
471 } upb_errcode_t;
472
473 extern upb_errorspace upb_upberr;
474
475 void upb_upberr_setoom(upb_status *s);
476
477 /* Since errno is defined by standard C, we define an error space for it in
478 * core upb. Other error spaces should be defined in other, platform-specific
479 * modules. */
480
481 extern upb_errorspace upb_errnoerr;
482
483
484 /** upb::Allocator ************************************************************/
485
486 /* A upb::Allocator is a possibly-stateful allocator object.
487 *
488 * It could either be an arena allocator (which doesn't require individual
489 * free() calls) or a regular malloc() (which does). The client must therefore
490 * free memory unless it knows that the allocator is an arena allocator. */
491 UPB_DECLARE_TYPE(upb::Allocator, upb_alloc)
492
493 /* A malloc()/free() function.
494 * If "size" is 0 then the function acts like free(), otherwise it acts like
495 * realloc(). Only "oldsize" bytes from a previous allocation are preserved. */
496 typedef void *upb_alloc_func(upb_alloc *alloc, void *ptr, size_t oldsize,
497 size_t size);
498
499 #ifdef __cplusplus
500
501 class upb::Allocator UPB_FINAL {
502 public:
503 Allocator() {}
504
505 private:
506 UPB_DISALLOW_COPY_AND_ASSIGN(Allocator)
507
508 public:
509 #else
510 struct upb_alloc {
511 #endif /* __cplusplus */
512 upb_alloc_func *func;
513 };
514
515 UPB_INLINE void *upb_malloc(upb_alloc *alloc, size_t size) {
516 UPB_ASSERT(size > 0);
517 return alloc->func(alloc, NULL, 0, size);
518 }
519
520 UPB_INLINE void *upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize,
521 size_t size) {
522 UPB_ASSERT(size > 0);
523 return alloc->func(alloc, ptr, oldsize, size);
524 }
525
526 UPB_INLINE void upb_free(upb_alloc *alloc, void *ptr) {
527 alloc->func(alloc, ptr, 0, 0);
528 }
529
530 /* The global allocator used by upb. Uses the standard malloc()/free(). */
531
532 extern upb_alloc upb_alloc_global;
533
534 /* Functions that hard-code the global malloc.
535 *
536 * We still get benefit because we can put custom logic into our global
537 * allocator, like injecting out-of-memory faults in debug/testing builds. */
538
539 UPB_INLINE void *upb_gmalloc(size_t size) {
540 return upb_malloc(&upb_alloc_global, size);
541 }
542
543 UPB_INLINE void *upb_grealloc(void *ptr, size_t oldsize, size_t size) {
544 return upb_realloc(&upb_alloc_global, ptr, oldsize, size);
545 }
546
547 UPB_INLINE void upb_gfree(void *ptr) {
548 upb_free(&upb_alloc_global, ptr);
549 }
550
551 /* upb::Arena *****************************************************************/
552
553 /* upb::Arena is a specific allocator implementation that uses arena allocation.
554 * The user provides an allocator that will be used to allocate the underlying
555 * arena blocks. Arenas by nature do not require the individual allocations
556 * to be freed. However the Arena does allow users to register cleanup
557 * functions that will run when the arena is destroyed.
558 *
559 * A upb::Arena is *not* thread-safe.
560 *
561 * You could write a thread-safe arena allocator that satisfies the
562 * upb::Allocator interface, but it would not be as efficient for the
563 * single-threaded case. */
564 UPB_DECLARE_TYPE(upb::Arena, upb_arena)
565
566 typedef void upb_cleanup_func(void *ud);
567
568 #define UPB_ARENA_BLOCK_OVERHEAD (sizeof(size_t)*4)
569
570 UPB_BEGIN_EXTERN_C
571
572 void upb_arena_init(upb_arena *a);
573 void upb_arena_init2(upb_arena *a, void *mem, size_t n, upb_alloc *alloc);
574 void upb_arena_uninit(upb_arena *a);
575 upb_alloc *upb_arena_alloc(upb_arena *a);
576 bool upb_arena_addcleanup(upb_arena *a, upb_cleanup_func *func, void *ud);
577 size_t upb_arena_bytesallocated(const upb_arena *a);
578 void upb_arena_setnextblocksize(upb_arena *a, size_t size);
579 void upb_arena_setmaxblocksize(upb_arena *a, size_t size);
580
581 UPB_END_EXTERN_C
582
583 #ifdef __cplusplus
584
585 class upb::Arena {
586 public:
587 /* A simple arena with no initial memory block and the default allocator. */
588 Arena() { upb_arena_init(this); }
589
590 /* Constructs an arena with the given initial block which allocates blocks
591 * with the given allocator. The given allocator must outlive the Arena.
592 *
593 * If you pass NULL for the allocator it will default to the global allocator
594 * upb_alloc_global, and NULL/0 for the initial block will cause there to be
595 * no initial block. */
596 Arena(void *mem, size_t len, Allocator* a) {
597 upb_arena_init2(this, mem, len, a);
598 }
599
600 ~Arena() { upb_arena_uninit(this); }
601
602 /* Sets the size of the next block the Arena will request (unless the
603 * requested allocation is larger). Each block will double in size until the
604 * max limit is reached. */
605 void SetNextBlockSize(size_t size) { upb_arena_setnextblocksize(this, size); }
606
607 /* Sets the maximum block size. No blocks larger than this will be requested
608 * from the underlying allocator unless individual arena allocations are
609 * larger. */
610 void SetMaxBlockSize(size_t size) { upb_arena_setmaxblocksize(this, size); }
611
612 /* Allows this arena to be used as a generic allocator.
613 *
614 * The arena does not need free() calls so when using Arena as an allocator
615 * it is safe to skip them. However they are no-ops so there is no harm in
616 * calling free() either. */
617 Allocator* allocator() { return upb_arena_alloc(this); }
618
619 /* Add a cleanup function to run when the arena is destroyed.
620 * Returns false on out-of-memory. */
621 bool AddCleanup(upb_cleanup_func* func, void* ud) {
622 return upb_arena_addcleanup(this, func, ud);
623 }
624
625 /* Total number of bytes that have been allocated. It is undefined what
626 * Realloc() does to this counter. */
627 size_t BytesAllocated() const {
628 return upb_arena_bytesallocated(this);
629 }
630
631 private:
632 UPB_DISALLOW_COPY_AND_ASSIGN(Arena)
633
634 #else
635 struct upb_arena {
636 #endif /* __cplusplus */
637 /* We implement the allocator interface.
638 * This must be the first member of upb_arena! */
639 upb_alloc alloc;
640
641 /* Allocator to allocate arena blocks. We are responsible for freeing these
642 * when we are destroyed. */
643 upb_alloc *block_alloc;
644
645 size_t bytes_allocated;
646 size_t next_block_size;
647 size_t max_block_size;
648
649 /* Linked list of blocks. Points to an arena_block, defined in env.c */
650 void *block_head;
651
652 /* Cleanup entries. Pointer to a cleanup_ent, defined in env.c */
653 void *cleanup_head;
654
655 /* For future expansion, since the size of this struct is exposed to users. */
656 void *future1;
657 void *future2;
658 };
659
660
661 /* upb::Environment ***********************************************************/
662
663 /* A upb::Environment provides a means for injecting malloc and an
664 * error-reporting callback into encoders/decoders. This allows them to be
665 * independent of nearly all assumptions about their actual environment.
666 *
667 * It is also a container for allocating the encoders/decoders themselves that
668 * insulates clients from knowing their actual size. This provides ABI
669 * compatibility even if the size of the objects change. And this allows the
670 * structure definitions to be in the .c files instead of the .h files, making
671 * the .h files smaller and more readable.
672 *
673 * We might want to consider renaming this to "Pipeline" if/when the concept of
674 * a pipeline element becomes more formalized. */
675 UPB_DECLARE_TYPE(upb::Environment, upb_env)
676
677 /* A function that receives an error report from an encoder or decoder. The
678 * callback can return true to request that the error should be recovered, but
679 * if the error is not recoverable this has no effect. */
680 typedef bool upb_error_func(void *ud, const upb_status *status);
681
682 UPB_BEGIN_EXTERN_C
683
684 void upb_env_init(upb_env *e);
685 void upb_env_init2(upb_env *e, void *mem, size_t n, upb_alloc *alloc);
686 void upb_env_uninit(upb_env *e);
687
688 void upb_env_initonly(upb_env *e);
689
690 upb_arena *upb_env_arena(upb_env *e);
691 bool upb_env_ok(const upb_env *e);
692 void upb_env_seterrorfunc(upb_env *e, upb_error_func *func, void *ud);
693
694 /* Convenience wrappers around the methods of the contained arena. */
695 void upb_env_reporterrorsto(upb_env *e, upb_status *s);
696 bool upb_env_reporterror(upb_env *e, const upb_status *s);
697 void *upb_env_malloc(upb_env *e, size_t size);
698 void *upb_env_realloc(upb_env *e, void *ptr, size_t oldsize, size_t size);
699 void upb_env_free(upb_env *e, void *ptr);
700 bool upb_env_addcleanup(upb_env *e, upb_cleanup_func *func, void *ud);
701 size_t upb_env_bytesallocated(const upb_env *e);
702
703 UPB_END_EXTERN_C
704
705 #ifdef __cplusplus
706
707 class upb::Environment {
708 public:
709 /* The given Arena must outlive this environment. */
710 Environment() { upb_env_initonly(this); }
711
712 Environment(void *mem, size_t len, Allocator *a) : arena_(mem, len, a) {
713 upb_env_initonly(this);
714 }
715
716 Arena* arena() { return upb_env_arena(this); }
717
718 /* Set a custom error reporting function. */
719 void SetErrorFunction(upb_error_func* func, void* ud) {
720 upb_env_seterrorfunc(this, func, ud);
721 }
722
723 /* Set the error reporting function to simply copy the status to the given
724 * status and abort. */
725 void ReportErrorsTo(Status* status) { upb_env_reporterrorsto(this, status); }
726
727 /* Returns true if all allocations and AddCleanup() calls have succeeded,
728 * and no errors were reported with ReportError() (except ones that recovered
729 * successfully). */
730 bool ok() const { return upb_env_ok(this); }
731
732 /* Reports an error to this environment's callback, returning true if
733 * the caller should try to recover. */
734 bool ReportError(const Status* status) {
735 return upb_env_reporterror(this, status);
736 }
737
738 private:
739 UPB_DISALLOW_COPY_AND_ASSIGN(Environment)
740
741 #else
742 struct upb_env {
743 #endif /* __cplusplus */
744 upb_arena arena_;
745 upb_error_func *error_func_;
746 void *error_ud_;
747 bool ok_;
748 };
749
750
751 /* upb::InlinedArena **********************************************************/
752 /* upb::InlinedEnvironment ****************************************************/
753
754 /* upb::InlinedArena and upb::InlinedEnvironment seed their arenas with a
755 * predefined amount of memory. No heap memory will be allocated until the
756 * initial block is exceeded.
757 *
758 * These types only exist in C++ */
759
760 #ifdef __cplusplus
761
762 template <int N> class upb::InlinedArena : public upb::Arena {
763 public:
764 InlinedArena() : Arena(initial_block_, N, NULL) {}
765 explicit InlinedArena(Allocator* a) : Arena(initial_block_, N, a) {}
766
767 private:
768 UPB_DISALLOW_COPY_AND_ASSIGN(InlinedArena)
769
770 char initial_block_[N + UPB_ARENA_BLOCK_OVERHEAD];
771 };
772
773 template <int N> class upb::InlinedEnvironment : public upb::Environment {
774 public:
775 InlinedEnvironment() : Environment(initial_block_, N, NULL) {}
776 explicit InlinedEnvironment(Allocator *a)
777 : Environment(initial_block_, N, a) {}
778
779 private:
780 UPB_DISALLOW_COPY_AND_ASSIGN(InlinedEnvironment)
781
782 char initial_block_[N + UPB_ARENA_BLOCK_OVERHEAD];
783 };
784
785 #endif /* __cplusplus */
786
787
788 569
789 #endif /* UPB_H_ */ 570 #endif /* UPB_H_ */
790 571
791 #ifdef __cplusplus 572 #ifdef __cplusplus
792 extern "C" { 573 extern "C" {
793 #endif 574 #endif
794 575
795 576
796 /* upb_value ******************************************************************/ 577 /* upb_value ******************************************************************/
797 578
(...skipping 21 matching lines...) Expand all
819 #endif 600 #endif
820 } upb_value; 601 } upb_value;
821 602
822 #ifdef NDEBUG 603 #ifdef NDEBUG
823 #define SET_TYPE(dest, val) UPB_UNUSED(val) 604 #define SET_TYPE(dest, val) UPB_UNUSED(val)
824 #else 605 #else
825 #define SET_TYPE(dest, val) dest = val 606 #define SET_TYPE(dest, val) dest = val
826 #endif 607 #endif
827 608
828 /* Like strdup(), which isn't always available since it's not ANSI C. */ 609 /* Like strdup(), which isn't always available since it's not ANSI C. */
829 char *upb_strdup(const char *s, upb_alloc *a); 610 char *upb_strdup(const char *s);
830 /* Variant that works with a length-delimited rather than NULL-delimited string, 611 /* Variant that works with a length-delimited rather than NULL-delimited string,
831 * as supported by strtable. */ 612 * as supported by strtable. */
832 char *upb_strdup2(const char *s, size_t len, upb_alloc *a); 613 char *upb_strdup2(const char *s, size_t len);
833
834 UPB_INLINE char *upb_gstrdup(const char *s) {
835 return upb_strdup(s, &upb_alloc_global);
836 }
837 614
838 UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val, 615 UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val,
839 upb_ctype_t ctype) { 616 upb_ctype_t ctype) {
840 v->val = val; 617 v->val = val;
841 SET_TYPE(v->ctype, ctype); 618 SET_TYPE(v->ctype, ctype);
842 } 619 }
843 620
844 UPB_INLINE upb_value _upb_value_val(uint64_t val, upb_ctype_t ctype) { 621 UPB_INLINE upb_value _upb_value_val(uint64_t val, upb_ctype_t ctype) {
845 upb_value ret; 622 upb_value ret;
846 _upb_value_setval(&ret, val, ctype); 623 _upb_value_setval(&ret, val, ctype);
(...skipping 12 matching lines...) Expand all
859 UPB_INLINE void upb_value_set ## name(upb_value *val, type_t cval) { \ 636 UPB_INLINE void upb_value_set ## name(upb_value *val, type_t cval) { \
860 val->val = (converter)cval; \ 637 val->val = (converter)cval; \
861 SET_TYPE(val->ctype, proto_type); \ 638 SET_TYPE(val->ctype, proto_type); \
862 } \ 639 } \
863 UPB_INLINE upb_value upb_value_ ## name(type_t val) { \ 640 UPB_INLINE upb_value upb_value_ ## name(type_t val) { \
864 upb_value ret; \ 641 upb_value ret; \
865 upb_value_set ## name(&ret, val); \ 642 upb_value_set ## name(&ret, val); \
866 return ret; \ 643 return ret; \
867 } \ 644 } \
868 UPB_INLINE type_t upb_value_get ## name(upb_value val) { \ 645 UPB_INLINE type_t upb_value_get ## name(upb_value val) { \
869 UPB_ASSERT_DEBUGVAR(val.ctype == proto_type); \ 646 assert(val.ctype == proto_type); \
870 return (type_t)(converter)val.val; \ 647 return (type_t)(converter)val.val; \
871 } 648 }
872 649
873 FUNCS(int32, int32, int32_t, int32_t, UPB_CTYPE_INT32) 650 FUNCS(int32, int32, int32_t, int32_t, UPB_CTYPE_INT32)
874 FUNCS(int64, int64, int64_t, int64_t, UPB_CTYPE_INT64) 651 FUNCS(int64, int64, int64_t, int64_t, UPB_CTYPE_INT64)
875 FUNCS(uint32, uint32, uint32_t, uint32_t, UPB_CTYPE_UINT32) 652 FUNCS(uint32, uint32, uint32_t, uint32_t, UPB_CTYPE_UINT32)
876 FUNCS(uint64, uint64, uint64_t, uint64_t, UPB_CTYPE_UINT64) 653 FUNCS(uint64, uint64, uint64_t, uint64_t, UPB_CTYPE_UINT64)
877 FUNCS(bool, _bool, bool, bool, UPB_CTYPE_BOOL) 654 FUNCS(bool, _bool, bool, bool, UPB_CTYPE_BOOL)
878 FUNCS(cstr, cstr, char*, uintptr_t, UPB_CTYPE_CSTR) 655 FUNCS(cstr, cstr, char*, uintptr_t, UPB_CTYPE_CSTR)
879 FUNCS(ptr, ptr, void*, uintptr_t, UPB_CTYPE_PTR) 656 FUNCS(ptr, ptr, void*, uintptr_t, UPB_CTYPE_PTR)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 upb_ctype_t ctype; /* Type of all values. */ 780 upb_ctype_t ctype; /* Type of all values. */
1004 uint8_t size_lg2; /* Size of the hashtable part is 2^size_lg2 entries. */ 781 uint8_t size_lg2; /* Size of the hashtable part is 2^size_lg2 entries. */
1005 782
1006 /* Hash table entries. 783 /* Hash table entries.
1007 * Making this const isn't entirely accurate; what we really want is for it to 784 * Making this const isn't entirely accurate; what we really want is for it to
1008 * have the same const-ness as the table it's inside. But there's no way to 785 * have the same const-ness as the table it's inside. But there's no way to
1009 * declare that in C. So we have to make it const so that we can statically 786 * declare that in C. So we have to make it const so that we can statically
1010 * initialize const hash tables. Then we cast away const when we have to. 787 * initialize const hash tables. Then we cast away const when we have to.
1011 */ 788 */
1012 const upb_tabent *entries; 789 const upb_tabent *entries;
1013
1014 #ifndef NDEBUG
1015 /* This table's allocator. We make the user pass it in to every relevant
1016 * function and only use this to check it in debug mode. We do this solely
1017 * to keep upb_table as small as possible. This might seem slightly paranoid
1018 * but the plan is to use upb_table for all map fields and extension sets in
1019 * a forthcoming message representation, so there could be a lot of these.
1020 * If this turns out to be too annoying later, we can change it (since this
1021 * is an internal-only header file). */
1022 upb_alloc *alloc;
1023 #endif
1024 } upb_table; 790 } upb_table;
1025 791
1026 #ifdef NDEBUG
1027 # define UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries) \
1028 {count, mask, ctype, size_lg2, entries}
1029 #else
1030 # ifdef UPB_DEBUG_REFS
1031 /* At the moment the only mutable tables we statically initialize are debug
1032 * ref tables. */
1033 # define UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries) \
1034 {count, mask, ctype, size_lg2, entries, &upb_alloc_debugrefs}
1035 # else
1036 # define UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries) \
1037 {count, mask, ctype, size_lg2, entries, NULL}
1038 # endif
1039 #endif
1040
1041 typedef struct { 792 typedef struct {
1042 upb_table t; 793 upb_table t;
1043 } upb_strtable; 794 } upb_strtable;
1044 795
1045 #define UPB_STRTABLE_INIT(count, mask, ctype, size_lg2, entries) \ 796 #define UPB_STRTABLE_INIT(count, mask, ctype, size_lg2, entries) \
1046 {UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries)} 797 {{count, mask, ctype, size_lg2, entries}}
1047 798
1048 #define UPB_EMPTY_STRTABLE_INIT(ctype) \ 799 #define UPB_EMPTY_STRTABLE_INIT(ctype) \
1049 UPB_STRTABLE_INIT(0, 0, ctype, 0, NULL) 800 UPB_STRTABLE_INIT(0, 0, ctype, 0, NULL)
1050 801
1051 typedef struct { 802 typedef struct {
1052 upb_table t; /* For entries that don't fit in the array part. */ 803 upb_table t; /* For entries that don't fit in the array part. */
1053 const upb_tabval *array; /* Array part of the table. See const note above. */ 804 const upb_tabval *array; /* Array part of the table. See const note above. */
1054 size_t array_size; /* Array part size. */ 805 size_t array_size; /* Array part size. */
1055 size_t array_count; /* Array part number of elements. */ 806 size_t array_count; /* Array part number of elements. */
1056 } upb_inttable; 807 } upb_inttable;
1057 808
1058 #define UPB_INTTABLE_INIT(count, mask, ctype, size_lg2, ent, a, asize, acount) \ 809 #define UPB_INTTABLE_INIT(count, mask, ctype, size_lg2, ent, a, asize, acount) \
1059 {UPB_TABLE_INIT(count, mask, ctype, size_lg2, ent), a, asize, acount} 810 {{count, mask, ctype, size_lg2, ent}, a, asize, acount}
1060 811
1061 #define UPB_EMPTY_INTTABLE_INIT(ctype) \ 812 #define UPB_EMPTY_INTTABLE_INIT(ctype) \
1062 UPB_INTTABLE_INIT(0, 0, ctype, 0, NULL, NULL, 0, 0) 813 UPB_INTTABLE_INIT(0, 0, ctype, 0, NULL, NULL, 0, 0)
1063 814
1064 #define UPB_ARRAY_EMPTYENT -1 815 #define UPB_ARRAY_EMPTYENT -1
1065 816
1066 UPB_INLINE size_t upb_table_size(const upb_table *t) { 817 UPB_INLINE size_t upb_table_size(const upb_table *t) {
1067 if (t->size_lg2 == 0) 818 if (t->size_lg2 == 0)
1068 return 0; 819 return 0;
1069 else 820 else
(...skipping 19 matching lines...) Expand all
1089 static const upb_tabent *upb_getentry(const upb_table *t, uint32_t hash) { 840 static const upb_tabent *upb_getentry(const upb_table *t, uint32_t hash) {
1090 return t->entries + (hash & t->mask); 841 return t->entries + (hash & t->mask);
1091 } 842 }
1092 843
1093 UPB_INLINE bool upb_arrhas(upb_tabval key) { 844 UPB_INLINE bool upb_arrhas(upb_tabval key) {
1094 return key.val != (uint64_t)-1; 845 return key.val != (uint64_t)-1;
1095 } 846 }
1096 847
1097 /* Initialize and uninitialize a table, respectively. If memory allocation 848 /* Initialize and uninitialize a table, respectively. If memory allocation
1098 * failed, false is returned that the table is uninitialized. */ 849 * failed, false is returned that the table is uninitialized. */
1099 bool upb_inttable_init2(upb_inttable *table, upb_ctype_t ctype, upb_alloc *a); 850 bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype);
1100 bool upb_strtable_init2(upb_strtable *table, upb_ctype_t ctype, upb_alloc *a); 851 bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype);
1101 void upb_inttable_uninit2(upb_inttable *table, upb_alloc *a); 852 void upb_inttable_uninit(upb_inttable *table);
1102 void upb_strtable_uninit2(upb_strtable *table, upb_alloc *a); 853 void upb_strtable_uninit(upb_strtable *table);
1103
1104 UPB_INLINE bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype) {
1105 return upb_inttable_init2(table, ctype, &upb_alloc_global);
1106 }
1107
1108 UPB_INLINE bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype) {
1109 return upb_strtable_init2(table, ctype, &upb_alloc_global);
1110 }
1111
1112 UPB_INLINE void upb_inttable_uninit(upb_inttable *table) {
1113 upb_inttable_uninit2(table, &upb_alloc_global);
1114 }
1115
1116 UPB_INLINE void upb_strtable_uninit(upb_strtable *table) {
1117 upb_strtable_uninit2(table, &upb_alloc_global);
1118 }
1119 854
1120 /* Returns the number of values in the table. */ 855 /* Returns the number of values in the table. */
1121 size_t upb_inttable_count(const upb_inttable *t); 856 size_t upb_inttable_count(const upb_inttable *t);
1122 UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) { 857 UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) {
1123 return t->t.count; 858 return t->t.count;
1124 } 859 }
1125 860
1126 /* Inserts the given key into the hashtable with the given value. The key must 861 /* Inserts the given key into the hashtable with the given value. The key must
1127 * not already exist in the hash table. For string tables, the key must be 862 * not already exist in the hash table. For string tables, the key must be
1128 * NULL-terminated, and the table will make an internal copy of the key. 863 * NULL-terminated, and the table will make an internal copy of the key.
1129 * Inttables must not insert a value of UINTPTR_MAX. 864 * Inttables must not insert a value of UINTPTR_MAX.
1130 * 865 *
1131 * If a table resize was required but memory allocation failed, false is 866 * If a table resize was required but memory allocation failed, false is
1132 * returned and the table is unchanged. */ 867 * returned and the table is unchanged. */
1133 bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val, 868 bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val);
1134 upb_alloc *a); 869 bool upb_strtable_insert2(upb_strtable *t, const char *key, size_t len,
1135 bool upb_strtable_insert3(upb_strtable *t, const char *key, size_t len, 870 upb_value val);
1136 upb_value val, upb_alloc *a);
1137
1138 UPB_INLINE bool upb_inttable_insert(upb_inttable *t, uintptr_t key,
1139 upb_value val) {
1140 return upb_inttable_insert2(t, key, val, &upb_alloc_global);
1141 }
1142
1143 UPB_INLINE bool upb_strtable_insert2(upb_strtable *t, const char *key,
1144 size_t len, upb_value val) {
1145 return upb_strtable_insert3(t, key, len, val, &upb_alloc_global);
1146 }
1147 871
1148 /* For NULL-terminated strings. */ 872 /* For NULL-terminated strings. */
1149 UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key, 873 UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key,
1150 upb_value val) { 874 upb_value val) {
1151 return upb_strtable_insert2(t, key, strlen(key), val); 875 return upb_strtable_insert2(t, key, strlen(key), val);
1152 } 876 }
1153 877
1154 /* Looks up key in this table, returning "true" if the key was found. 878 /* Looks up key in this table, returning "true" if the key was found.
1155 * If v is non-NULL, copies the value for this key into *v. */ 879 * If v is non-NULL, copies the value for this key into *v. */
1156 bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v); 880 bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v);
1157 bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len, 881 bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len,
1158 upb_value *v); 882 upb_value *v);
1159 883
1160 /* For NULL-terminated strings. */ 884 /* For NULL-terminated strings. */
1161 UPB_INLINE bool upb_strtable_lookup(const upb_strtable *t, const char *key, 885 UPB_INLINE bool upb_strtable_lookup(const upb_strtable *t, const char *key,
1162 upb_value *v) { 886 upb_value *v) {
1163 return upb_strtable_lookup2(t, key, strlen(key), v); 887 return upb_strtable_lookup2(t, key, strlen(key), v);
1164 } 888 }
1165 889
1166 /* Removes an item from the table. Returns true if the remove was successful, 890 /* Removes an item from the table. Returns true if the remove was successful,
1167 * and stores the removed item in *val if non-NULL. */ 891 * and stores the removed item in *val if non-NULL. */
1168 bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val); 892 bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val);
1169 bool upb_strtable_remove3(upb_strtable *t, const char *key, size_t len, 893 bool upb_strtable_remove2(upb_strtable *t, const char *key, size_t len,
1170 upb_value *val, upb_alloc *alloc); 894 upb_value *val);
1171
1172 UPB_INLINE bool upb_strtable_remove2(upb_strtable *t, const char *key,
1173 size_t len, upb_value *val) {
1174 return upb_strtable_remove3(t, key, len, val, &upb_alloc_global);
1175 }
1176 895
1177 /* For NULL-terminated strings. */ 896 /* For NULL-terminated strings. */
1178 UPB_INLINE bool upb_strtable_remove(upb_strtable *t, const char *key, 897 UPB_INLINE bool upb_strtable_remove(upb_strtable *t, const char *key,
1179 upb_value *v) { 898 upb_value *v) {
1180 return upb_strtable_remove2(t, key, strlen(key), v); 899 return upb_strtable_remove2(t, key, strlen(key), v);
1181 } 900 }
1182 901
1183 /* Updates an existing entry in an inttable. If the entry does not exist, 902 /* Updates an existing entry in an inttable. If the entry does not exist,
1184 * returns false and does nothing. Unlike insert/remove, this does not 903 * returns false and does nothing. Unlike insert/remove, this does not
1185 * invalidate iterators. */ 904 * invalidate iterators. */
1186 bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val); 905 bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val);
1187 906
1188 /* Handy routines for treating an inttable like a stack. May not be mixed with 907 /* Handy routines for treating an inttable like a stack. May not be mixed with
1189 * other insert/remove calls. */ 908 * other insert/remove calls. */
1190 bool upb_inttable_push2(upb_inttable *t, upb_value val, upb_alloc *a); 909 bool upb_inttable_push(upb_inttable *t, upb_value val);
1191 upb_value upb_inttable_pop(upb_inttable *t); 910 upb_value upb_inttable_pop(upb_inttable *t);
1192 911
1193 UPB_INLINE bool upb_inttable_push(upb_inttable *t, upb_value val) {
1194 return upb_inttable_push2(t, val, &upb_alloc_global);
1195 }
1196
1197 /* Convenience routines for inttables with pointer keys. */ 912 /* Convenience routines for inttables with pointer keys. */
1198 bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val, 913 bool upb_inttable_insertptr(upb_inttable *t, const void *key, upb_value val);
1199 upb_alloc *a);
1200 bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val); 914 bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val);
1201 bool upb_inttable_lookupptr( 915 bool upb_inttable_lookupptr(
1202 const upb_inttable *t, const void *key, upb_value *val); 916 const upb_inttable *t, const void *key, upb_value *val);
1203 917
1204 UPB_INLINE bool upb_inttable_insertptr(upb_inttable *t, const void *key,
1205 upb_value val) {
1206 return upb_inttable_insertptr2(t, key, val, &upb_alloc_global);
1207 }
1208
1209 /* Optimizes the table for the current set of entries, for both memory use and 918 /* Optimizes the table for the current set of entries, for both memory use and
1210 * lookup time. Client should call this after all entries have been inserted; 919 * lookup time. Client should call this after all entries have been inserted;
1211 * inserting more entries is legal, but will likely require a table resize. */ 920 * inserting more entries is legal, but will likely require a table resize. */
1212 void upb_inttable_compact2(upb_inttable *t, upb_alloc *a); 921 void upb_inttable_compact(upb_inttable *t);
1213
1214 UPB_INLINE void upb_inttable_compact(upb_inttable *t) {
1215 upb_inttable_compact2(t, &upb_alloc_global);
1216 }
1217 922
1218 /* A special-case inlinable version of the lookup routine for 32-bit 923 /* A special-case inlinable version of the lookup routine for 32-bit
1219 * integers. */ 924 * integers. */
1220 UPB_INLINE bool upb_inttable_lookup32(const upb_inttable *t, uint32_t key, 925 UPB_INLINE bool upb_inttable_lookup32(const upb_inttable *t, uint32_t key,
1221 upb_value *v) { 926 upb_value *v) {
1222 *v = upb_value_int32(0); /* Silence compiler warnings. */ 927 *v = upb_value_int32(0); /* Silence compiler warnings. */
1223 if (key < t->array_size) { 928 if (key < t->array_size) {
1224 upb_tabval arrval = t->array[key]; 929 upb_tabval arrval = t->array[key];
1225 if (upb_arrhas(arrval)) { 930 if (upb_arrhas(arrval)) {
1226 _upb_value_setval(v, arrval.val, t->t.ctype); 931 _upb_value_setval(v, arrval.val, t->t.ctype);
1227 return true; 932 return true;
1228 } else { 933 } else {
1229 return false; 934 return false;
1230 } 935 }
1231 } else { 936 } else {
1232 const upb_tabent *e; 937 const upb_tabent *e;
1233 if (t->t.entries == NULL) return false; 938 if (t->t.entries == NULL) return false;
1234 for (e = upb_getentry(&t->t, upb_inthash(key)); true; e = e->next) { 939 for (e = upb_getentry(&t->t, upb_inthash(key)); true; e = e->next) {
1235 if ((uint32_t)e->key == key) { 940 if ((uint32_t)e->key == key) {
1236 _upb_value_setval(v, e->val.val, t->t.ctype); 941 _upb_value_setval(v, e->val.val, t->t.ctype);
1237 return true; 942 return true;
1238 } 943 }
1239 if (e->next == NULL) return false; 944 if (e->next == NULL) return false;
1240 } 945 }
1241 } 946 }
1242 } 947 }
1243 948
1244 /* Exposed for testing only. */ 949 /* Exposed for testing only. */
1245 bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_alloc *a); 950 bool upb_strtable_resize(upb_strtable *t, size_t size_lg2);
1246 951
1247 /* Iterators ******************************************************************/ 952 /* Iterators ******************************************************************/
1248 953
1249 /* Iterators for int and string tables. We are subject to some kind of unusual 954 /* Iterators for int and string tables. We are subject to some kind of unusual
1250 * design constraints: 955 * design constraints:
1251 * 956 *
1252 * For high-level languages: 957 * For high-level languages:
1253 * - we must be able to guarantee that we don't crash or corrupt memory even if 958 * - we must be able to guarantee that we don't crash or corrupt memory even if
1254 * the program accesses an invalidated iterator. 959 * the program accesses an invalidated iterator.
1255 * 960 *
(...skipping 24 matching lines...) Expand all
1280 */ 985 */
1281 986
1282 typedef struct { 987 typedef struct {
1283 const upb_strtable *t; 988 const upb_strtable *t;
1284 size_t index; 989 size_t index;
1285 } upb_strtable_iter; 990 } upb_strtable_iter;
1286 991
1287 void upb_strtable_begin(upb_strtable_iter *i, const upb_strtable *t); 992 void upb_strtable_begin(upb_strtable_iter *i, const upb_strtable *t);
1288 void upb_strtable_next(upb_strtable_iter *i); 993 void upb_strtable_next(upb_strtable_iter *i);
1289 bool upb_strtable_done(const upb_strtable_iter *i); 994 bool upb_strtable_done(const upb_strtable_iter *i);
1290 const char *upb_strtable_iter_key(const upb_strtable_iter *i); 995 const char *upb_strtable_iter_key(upb_strtable_iter *i);
1291 size_t upb_strtable_iter_keylength(const upb_strtable_iter *i); 996 size_t upb_strtable_iter_keylength(upb_strtable_iter *i);
1292 upb_value upb_strtable_iter_value(const upb_strtable_iter *i); 997 upb_value upb_strtable_iter_value(const upb_strtable_iter *i);
1293 void upb_strtable_iter_setdone(upb_strtable_iter *i); 998 void upb_strtable_iter_setdone(upb_strtable_iter *i);
1294 bool upb_strtable_iter_isequal(const upb_strtable_iter *i1, 999 bool upb_strtable_iter_isequal(const upb_strtable_iter *i1,
1295 const upb_strtable_iter *i2); 1000 const upb_strtable_iter *i2);
1296 1001
1297 1002
1298 /* upb_inttable_iter **********************************************************/ 1003 /* upb_inttable_iter **********************************************************/
1299 1004
1300 /* upb_inttable_iter i; 1005 /* upb_inttable_iter i;
1301 * upb_inttable_begin(&i, t); 1006 * upb_inttable_begin(&i, t);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 * the code that originally created the object. 1039 * the code that originally created the object.
1335 * 1040 *
1336 * Enabling this requires the application to define upb_lock()/upb_unlock() 1041 * Enabling this requires the application to define upb_lock()/upb_unlock()
1337 * functions that acquire/release a global mutex (or #define UPB_THREAD_UNSAFE). 1042 * functions that acquire/release a global mutex (or #define UPB_THREAD_UNSAFE).
1338 * For this reason we don't enable it by default, even in debug builds. 1043 * For this reason we don't enable it by default, even in debug builds.
1339 */ 1044 */
1340 1045
1341 /* #define UPB_DEBUG_REFS */ 1046 /* #define UPB_DEBUG_REFS */
1342 1047
1343 #ifdef __cplusplus 1048 #ifdef __cplusplus
1344 namespace upb { 1049 namespace upb { class RefCounted; }
1345 class RefCounted;
1346 template <class T> class reffed_ptr;
1347 }
1348 #endif 1050 #endif
1349 1051
1350 UPB_DECLARE_TYPE(upb::RefCounted, upb_refcounted) 1052 UPB_DECLARE_TYPE(upb::RefCounted, upb_refcounted)
1351 1053
1352 struct upb_refcounted_vtbl; 1054 struct upb_refcounted_vtbl;
1353 1055
1354 #ifdef __cplusplus 1056 #ifdef __cplusplus
1355 1057
1356 class upb::RefCounted { 1058 class upb::RefCounted {
1357 public: 1059 public:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 1107
1406 bool is_frozen; 1108 bool is_frozen;
1407 1109
1408 #ifdef UPB_DEBUG_REFS 1110 #ifdef UPB_DEBUG_REFS
1409 upb_inttable *refs; /* Maps owner -> trackedref for incoming refs. */ 1111 upb_inttable *refs; /* Maps owner -> trackedref for incoming refs. */
1410 upb_inttable *ref2s; /* Set of targets for outgoing ref2s. */ 1112 upb_inttable *ref2s; /* Set of targets for outgoing ref2s. */
1411 #endif 1113 #endif
1412 }; 1114 };
1413 1115
1414 #ifdef UPB_DEBUG_REFS 1116 #ifdef UPB_DEBUG_REFS
1415 extern upb_alloc upb_alloc_debugrefs; 1117 #define UPB_REFCOUNT_INIT(refs, ref2s) \
1416 #define UPB_REFCOUNT_INIT(vtbl, refs, ref2s) \ 1118 {&static_refcount, NULL, NULL, 0, true, refs, ref2s}
1417 {&static_refcount, NULL, vtbl, 0, true, refs, ref2s}
1418 #else 1119 #else
1419 #define UPB_REFCOUNT_INIT(vtbl, refs, ref2s) \ 1120 #define UPB_REFCOUNT_INIT(refs, ref2s) {&static_refcount, NULL, NULL, 0, true}
1420 {&static_refcount, NULL, vtbl, 0, true}
1421 #endif 1121 #endif
1422 1122
1423 UPB_BEGIN_EXTERN_C 1123 UPB_BEGIN_EXTERN_C
1424 1124
1425 /* It is better to use tracked refs when possible, for the extra debugging 1125 /* It is better to use tracked refs when possible, for the extra debugging
1426 * capability. But if this is not possible (because you don't have easy access 1126 * capability. But if this is not possible (because you don't have easy access
1427 * to a stable pointer value that is associated with the ref), you can pass 1127 * to a stable pointer value that is associated with the ref), you can pass
1428 * UPB_UNTRACKED_REF instead. */ 1128 * UPB_UNTRACKED_REF instead. */
1429 extern const void *UPB_UNTRACKED_REF; 1129 extern const void *UPB_UNTRACKED_REF;
1430 1130
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 } 1243 }
1544 inline void RefCounted::DonateRef(const void *from, const void *to) const { 1244 inline void RefCounted::DonateRef(const void *from, const void *to) const {
1545 upb_refcounted_donateref(this, from, to); 1245 upb_refcounted_donateref(this, from, to);
1546 } 1246 }
1547 inline void RefCounted::CheckRef(const void *owner) const { 1247 inline void RefCounted::CheckRef(const void *owner) const {
1548 upb_refcounted_checkref(this, owner); 1248 upb_refcounted_checkref(this, owner);
1549 } 1249 }
1550 } /* namespace upb */ 1250 } /* namespace upb */
1551 #endif 1251 #endif
1552 1252
1553
1554 /* upb::reffed_ptr ************************************************************/
1555
1556 #ifdef __cplusplus
1557
1558 #include <algorithm> /* For std::swap(). */
1559
1560 /* Provides RAII semantics for upb refcounted objects. Each reffed_ptr owns a
1561 * ref on whatever object it points to (if any). */
1562 template <class T> class upb::reffed_ptr {
1563 public:
1564 reffed_ptr() : ptr_(NULL) {}
1565
1566 /* If ref_donor is NULL, takes a new ref, otherwise adopts from ref_donor. */
1567 template <class U>
1568 reffed_ptr(U* val, const void* ref_donor = NULL)
1569 : ptr_(upb::upcast(val)) {
1570 if (ref_donor) {
1571 UPB_ASSERT(ptr_);
1572 ptr_->DonateRef(ref_donor, this);
1573 } else if (ptr_) {
1574 ptr_->Ref(this);
1575 }
1576 }
1577
1578 template <class U>
1579 reffed_ptr(const reffed_ptr<U>& other)
1580 : ptr_(upb::upcast(other.get())) {
1581 if (ptr_) ptr_->Ref(this);
1582 }
1583
1584 reffed_ptr(const reffed_ptr& other)
1585 : ptr_(upb::upcast(other.get())) {
1586 if (ptr_) ptr_->Ref(this);
1587 }
1588
1589 ~reffed_ptr() { if (ptr_) ptr_->Unref(this); }
1590
1591 template <class U>
1592 reffed_ptr& operator=(const reffed_ptr<U>& other) {
1593 reset(other.get());
1594 return *this;
1595 }
1596
1597 reffed_ptr& operator=(const reffed_ptr& other) {
1598 reset(other.get());
1599 return *this;
1600 }
1601
1602 /* TODO(haberman): add C++11 move construction/assignment for greater
1603 * efficiency. */
1604
1605 void swap(reffed_ptr& other) {
1606 if (ptr_ == other.ptr_) {
1607 return;
1608 }
1609
1610 if (ptr_) ptr_->DonateRef(this, &other);
1611 if (other.ptr_) other.ptr_->DonateRef(&other, this);
1612 std::swap(ptr_, other.ptr_);
1613 }
1614
1615 T& operator*() const {
1616 UPB_ASSERT(ptr_);
1617 return *ptr_;
1618 }
1619
1620 T* operator->() const {
1621 UPB_ASSERT(ptr_);
1622 return ptr_;
1623 }
1624
1625 T* get() const { return ptr_; }
1626
1627 /* If ref_donor is NULL, takes a new ref, otherwise adopts from ref_donor. */
1628 template <class U>
1629 void reset(U* ptr = NULL, const void* ref_donor = NULL) {
1630 reffed_ptr(ptr, ref_donor).swap(*this);
1631 }
1632
1633 template <class U>
1634 reffed_ptr<U> down_cast() {
1635 return reffed_ptr<U>(upb::down_cast<U*>(get()));
1636 }
1637
1638 template <class U>
1639 reffed_ptr<U> dyn_cast() {
1640 return reffed_ptr<U>(upb::dyn_cast<U*>(get()));
1641 }
1642
1643 /* Plain release() is unsafe; if we were the only owner, it would leak the
1644 * object. Instead we provide this: */
1645 T* ReleaseTo(const void* new_owner) {
1646 T* ret = NULL;
1647 ptr_->DonateRef(this, new_owner);
1648 std::swap(ret, ptr_);
1649 return ret;
1650 }
1651
1652 private:
1653 T* ptr_;
1654 };
1655
1656 #endif /* __cplusplus */
1657
1658 #endif /* UPB_REFCOUNT_H_ */ 1253 #endif /* UPB_REFCOUNT_H_ */
1659 1254
1660 #ifdef __cplusplus 1255 #ifdef __cplusplus
1661 #include <cstring> 1256 #include <cstring>
1662 #include <string> 1257 #include <string>
1663 #include <vector> 1258 #include <vector>
1664 1259
1665 namespace upb { 1260 namespace upb {
1666 class Def; 1261 class Def;
1667 class EnumDef; 1262 class EnumDef;
1668 class FieldDef; 1263 class FieldDef;
1669 class FileDef;
1670 class MessageDef; 1264 class MessageDef;
1671 class OneofDef; 1265 class OneofDef;
1672 } 1266 }
1673 #endif 1267 #endif
1674 1268
1675 UPB_DECLARE_DERIVED_TYPE(upb::Def, upb::RefCounted, upb_def, upb_refcounted) 1269 UPB_DECLARE_DERIVED_TYPE(upb::Def, upb::RefCounted, upb_def, upb_refcounted)
1676 UPB_DECLARE_DERIVED_TYPE(upb::OneofDef, upb::RefCounted, upb_oneofdef,
1677 upb_refcounted)
1678 UPB_DECLARE_DERIVED_TYPE(upb::FileDef, upb::RefCounted, upb_filedef,
1679 upb_refcounted)
1680 1270
1681 /* The maximum message depth that the type graph can have. This is a resource 1271 /* The maximum message depth that the type graph can have. This is a resource
1682 * limit for the C stack since we sometimes need to recursively traverse the 1272 * limit for the C stack since we sometimes need to recursively traverse the
1683 * graph. Cycles are ok; the traversal will stop when it detects a cycle, but 1273 * graph. Cycles are ok; the traversal will stop when it detects a cycle, but
1684 * we must hit the cycle before the maximum depth is reached. 1274 * we must hit the cycle before the maximum depth is reached.
1685 * 1275 *
1686 * If having a single static limit is too inflexible, we can add another variant 1276 * If having a single static limit is too inflexible, we can add another variant
1687 * of Def::Freeze that allows specifying this as a parameter. */ 1277 * of Def::Freeze that allows specifying this as a parameter. */
1688 #define UPB_MAX_MESSAGE_DEPTH 64 1278 #define UPB_MAX_MESSAGE_DEPTH 64
1689 1279
1690 1280
1691 /* upb::Def: base class for top-level defs ***********************************/ 1281 /* upb::Def: base class for defs *********************************************/
1692 1282
1693 /* All the different kind of defs that can be defined at the top-level and put 1283 /* All the different kind of defs we support. These correspond 1:1 with
1694 * in a SymbolTable or appear in a FileDef::defs() list. This excludes some 1284 * declarations in a .proto file. */
1695 * defs (like oneofs and files). It only includes fields because they can be
1696 * defined as extensions. */
1697 typedef enum { 1285 typedef enum {
1698 UPB_DEF_MSG, 1286 UPB_DEF_MSG,
1699 UPB_DEF_FIELD, 1287 UPB_DEF_FIELD,
1700 UPB_DEF_ENUM, 1288 UPB_DEF_ENUM,
1289 UPB_DEF_ONEOF,
1701 UPB_DEF_SERVICE, /* Not yet implemented. */ 1290 UPB_DEF_SERVICE, /* Not yet implemented. */
1702 UPB_DEF_ANY = -1 /* Wildcard for upb_symtab_get*() */ 1291 UPB_DEF_ANY = -1 /* Wildcard for upb_symtab_get*() */
1703 } upb_deftype_t; 1292 } upb_deftype_t;
1704 1293
1705 #ifdef __cplusplus 1294 #ifdef __cplusplus
1706 1295
1707 /* The base class of all defs. Its base is upb::RefCounted (use upb::upcast() 1296 /* The base class of all defs. Its base is upb::RefCounted (use upb::upcast()
1708 * to convert). */ 1297 * to convert). */
1709 class upb::Def { 1298 class upb::Def {
1710 public: 1299 public:
1711 typedef upb_deftype_t Type; 1300 typedef upb_deftype_t Type;
1712 1301
1713 Def* Dup(const void *owner) const; 1302 Def* Dup(const void *owner) const;
1714 1303
1715 /* upb::RefCounted methods like Ref()/Unref(). */ 1304 /* upb::RefCounted methods like Ref()/Unref(). */
1716 UPB_REFCOUNTED_CPPMETHODS 1305 UPB_REFCOUNTED_CPPMETHODS
1717 1306
1718 Type def_type() const; 1307 Type def_type() const;
1719 1308
1720 /* "fullname" is the def's fully-qualified name (eg. foo.bar.Message). */ 1309 /* "fullname" is the def's fully-qualified name (eg. foo.bar.Message). */
1721 const char *full_name() const; 1310 const char *full_name() const;
1722 1311
1723 /* The final part of a def's name (eg. Message). */
1724 const char *name() const;
1725
1726 /* The def must be mutable. Caller retains ownership of fullname. Defs are 1312 /* The def must be mutable. Caller retains ownership of fullname. Defs are
1727 * not required to have a name; if a def has no name when it is frozen, it 1313 * not required to have a name; if a def has no name when it is frozen, it
1728 * will remain an anonymous def. On failure, returns false and details in "s" 1314 * will remain an anonymous def. On failure, returns false and details in "s"
1729 * if non-NULL. */ 1315 * if non-NULL. */
1730 bool set_full_name(const char* fullname, upb::Status* s); 1316 bool set_full_name(const char* fullname, upb::Status* s);
1731 bool set_full_name(const std::string &fullname, upb::Status* s); 1317 bool set_full_name(const std::string &fullname, upb::Status* s);
1732 1318
1733 /* The file in which this def appears. It is not necessary to add a def to a
1734 * file (and consequently the accessor may return NULL). Set this by calling
1735 * file->Add(def). */
1736 FileDef* file() const;
1737
1738 /* Freezes the given defs; this validates all constraints and marks the defs 1319 /* Freezes the given defs; this validates all constraints and marks the defs
1739 * as frozen (read-only). "defs" may not contain any fielddefs, but fields 1320 * as frozen (read-only). "defs" may not contain any fielddefs, but fields
1740 * of any msgdefs will be frozen. 1321 * of any msgdefs will be frozen.
1741 * 1322 *
1742 * Symbolic references to sub-types and enum defaults must have already been 1323 * Symbolic references to sub-types and enum defaults must have already been
1743 * resolved. Any mutable defs reachable from any of "defs" must also be in 1324 * resolved. Any mutable defs reachable from any of "defs" must also be in
1744 * the list; more formally, "defs" must be a transitive closure of mutable 1325 * the list; more formally, "defs" must be a transitive closure of mutable
1745 * defs. 1326 * defs.
1746 * 1327 *
1747 * After this operation succeeds, the finalized defs must only be accessed 1328 * After this operation succeeds, the finalized defs must only be accessed
1748 * through a const pointer! */ 1329 * through a const pointer! */
1749 static bool Freeze(Def* const* defs, size_t n, Status* status); 1330 static bool Freeze(Def* const* defs, int n, Status* status);
1750 static bool Freeze(const std::vector<Def*>& defs, Status* status); 1331 static bool Freeze(const std::vector<Def*>& defs, Status* status);
1751 1332
1752 private: 1333 private:
1753 UPB_DISALLOW_POD_OPS(Def, upb::Def) 1334 UPB_DISALLOW_POD_OPS(Def, upb::Def)
1754 }; 1335 };
1755 1336
1756 #endif /* __cplusplus */ 1337 #endif /* __cplusplus */
1757 1338
1758 UPB_BEGIN_EXTERN_C 1339 UPB_BEGIN_EXTERN_C
1759 1340
1760 /* Native C API. */ 1341 /* Native C API. */
1761 upb_def *upb_def_dup(const upb_def *def, const void *owner); 1342 upb_def *upb_def_dup(const upb_def *def, const void *owner);
1762 1343
1763 /* Include upb_refcounted methods like upb_def_ref()/upb_def_unref(). */ 1344 /* Include upb_refcounted methods like upb_def_ref()/upb_def_unref(). */
1764 UPB_REFCOUNTED_CMETHODS(upb_def, upb_def_upcast) 1345 UPB_REFCOUNTED_CMETHODS(upb_def, upb_def_upcast)
1765 1346
1766 upb_deftype_t upb_def_type(const upb_def *d); 1347 upb_deftype_t upb_def_type(const upb_def *d);
1767 const char *upb_def_fullname(const upb_def *d); 1348 const char *upb_def_fullname(const upb_def *d);
1768 const char *upb_def_name(const upb_def *d);
1769 const upb_filedef *upb_def_file(const upb_def *d);
1770 bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s); 1349 bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s);
1771 bool upb_def_freeze(upb_def *const *defs, size_t n, upb_status *s); 1350 bool upb_def_freeze(upb_def *const *defs, int n, upb_status *s);
1772
1773 /* Temporary API: for internal use only. */
1774 bool _upb_def_validate(upb_def *const*defs, size_t n, upb_status *s);
1775 1351
1776 UPB_END_EXTERN_C 1352 UPB_END_EXTERN_C
1777 1353
1778 1354
1779 /* upb::Def casts *************************************************************/ 1355 /* upb::Def casts *************************************************************/
1780 1356
1781 #ifdef __cplusplus 1357 #ifdef __cplusplus
1782 #define UPB_CPP_CASTS(cname, cpptype) \ 1358 #define UPB_CPP_CASTS(cname, cpptype) \
1783 namespace upb { \ 1359 namespace upb { \
1784 template <> \ 1360 template <> \
(...skipping 28 matching lines...) Expand all
1813 1389
1814 /* Dynamic casts, for determining if a def is of a particular type at runtime. 1390 /* Dynamic casts, for determining if a def is of a particular type at runtime.
1815 * Downcasts, for when some wants to assert that a def is of a particular type. 1391 * Downcasts, for when some wants to assert that a def is of a particular type.
1816 * These are only checked if we are building debug. */ 1392 * These are only checked if we are building debug. */
1817 #define UPB_DEF_CASTS(lower, upper, cpptype) \ 1393 #define UPB_DEF_CASTS(lower, upper, cpptype) \
1818 UPB_INLINE const upb_##lower *upb_dyncast_##lower(const upb_def *def) { \ 1394 UPB_INLINE const upb_##lower *upb_dyncast_##lower(const upb_def *def) { \
1819 if (upb_def_type(def) != UPB_DEF_##upper) return NULL; \ 1395 if (upb_def_type(def) != UPB_DEF_##upper) return NULL; \
1820 return (upb_##lower *)def; \ 1396 return (upb_##lower *)def; \
1821 } \ 1397 } \
1822 UPB_INLINE const upb_##lower *upb_downcast_##lower(const upb_def *def) { \ 1398 UPB_INLINE const upb_##lower *upb_downcast_##lower(const upb_def *def) { \
1823 UPB_ASSERT(upb_def_type(def) == UPB_DEF_##upper); \ 1399 assert(upb_def_type(def) == UPB_DEF_##upper); \
1824 return (const upb_##lower *)def; \ 1400 return (const upb_##lower *)def; \
1825 } \ 1401 } \
1826 UPB_INLINE upb_##lower *upb_dyncast_##lower##_mutable(upb_def *def) { \ 1402 UPB_INLINE upb_##lower *upb_dyncast_##lower##_mutable(upb_def *def) { \
1827 return (upb_##lower *)upb_dyncast_##lower(def); \ 1403 return (upb_##lower *)upb_dyncast_##lower(def); \
1828 } \ 1404 } \
1829 UPB_INLINE upb_##lower *upb_downcast_##lower##_mutable(upb_def *def) { \ 1405 UPB_INLINE upb_##lower *upb_downcast_##lower##_mutable(upb_def *def) { \
1830 return (upb_##lower *)upb_downcast_##lower(def); \ 1406 return (upb_##lower *)upb_downcast_##lower(def); \
1831 } \ 1407 } \
1832 UPB_CPP_CASTS(lower, cpptype) 1408 UPB_CPP_CASTS(lower, cpptype)
1833 1409
1834 #define UPB_DEFINE_DEF(cppname, lower, upper, cppmethods, members) \ 1410 #define UPB_DEFINE_DEF(cppname, lower, upper, cppmethods, members) \
1835 UPB_DEFINE_CLASS2(cppname, upb::Def, upb::RefCounted, cppmethods, \ 1411 UPB_DEFINE_CLASS2(cppname, upb::Def, upb::RefCounted, cppmethods, \
1836 members) \ 1412 members) \
1837 UPB_DEF_CASTS(lower, upper, cppname) 1413 UPB_DEF_CASTS(lower, upper, cppname)
1838 1414
1839 #define UPB_DECLARE_DEF_TYPE(cppname, lower, upper) \ 1415 #define UPB_DECLARE_DEF_TYPE(cppname, lower, upper) \
1840 UPB_DECLARE_DERIVED_TYPE2(cppname, upb::Def, upb::RefCounted, \ 1416 UPB_DECLARE_DERIVED_TYPE2(cppname, upb::Def, upb::RefCounted, \
1841 upb_ ## lower, upb_def, upb_refcounted) \ 1417 upb_ ## lower, upb_def, upb_refcounted) \
1842 UPB_DEF_CASTS(lower, upper, cppname) 1418 UPB_DEF_CASTS(lower, upper, cppname)
1843 1419
1844 UPB_DECLARE_DEF_TYPE(upb::FieldDef, fielddef, FIELD) 1420 UPB_DECLARE_DEF_TYPE(upb::FieldDef, fielddef, FIELD)
1845 UPB_DECLARE_DEF_TYPE(upb::MessageDef, msgdef, MSG) 1421 UPB_DECLARE_DEF_TYPE(upb::MessageDef, msgdef, MSG)
1846 UPB_DECLARE_DEF_TYPE(upb::EnumDef, enumdef, ENUM) 1422 UPB_DECLARE_DEF_TYPE(upb::EnumDef, enumdef, ENUM)
1423 UPB_DECLARE_DEF_TYPE(upb::OneofDef, oneofdef, ONEOF)
1847 1424
1848 #undef UPB_DECLARE_DEF_TYPE 1425 #undef UPB_DECLARE_DEF_TYPE
1849 #undef UPB_DEF_CASTS 1426 #undef UPB_DEF_CASTS
1850 #undef UPB_CPP_CASTS 1427 #undef UPB_CPP_CASTS
1851 1428
1852 1429
1853 /* upb::FieldDef **************************************************************/ 1430 /* upb::FieldDef **************************************************************/
1854 1431
1855 /* The types a field can have. Note that this list is not identical to the 1432 /* The types a field can have. Note that this list is not identical to the
1856 * types defined in descriptor.proto, which gives INT32 and SINT32 separate 1433 * types defined in descriptor.proto, which gives INT32 and SINT32 separate
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 UPB_DESCRIPTOR_TYPE_MESSAGE = 11, 1476 UPB_DESCRIPTOR_TYPE_MESSAGE = 11,
1900 UPB_DESCRIPTOR_TYPE_BYTES = 12, 1477 UPB_DESCRIPTOR_TYPE_BYTES = 12,
1901 UPB_DESCRIPTOR_TYPE_UINT32 = 13, 1478 UPB_DESCRIPTOR_TYPE_UINT32 = 13,
1902 UPB_DESCRIPTOR_TYPE_ENUM = 14, 1479 UPB_DESCRIPTOR_TYPE_ENUM = 14,
1903 UPB_DESCRIPTOR_TYPE_SFIXED32 = 15, 1480 UPB_DESCRIPTOR_TYPE_SFIXED32 = 15,
1904 UPB_DESCRIPTOR_TYPE_SFIXED64 = 16, 1481 UPB_DESCRIPTOR_TYPE_SFIXED64 = 16,
1905 UPB_DESCRIPTOR_TYPE_SINT32 = 17, 1482 UPB_DESCRIPTOR_TYPE_SINT32 = 17,
1906 UPB_DESCRIPTOR_TYPE_SINT64 = 18 1483 UPB_DESCRIPTOR_TYPE_SINT64 = 18
1907 } upb_descriptortype_t; 1484 } upb_descriptortype_t;
1908 1485
1909 typedef enum {
1910 UPB_SYNTAX_PROTO2 = 2,
1911 UPB_SYNTAX_PROTO3 = 3
1912 } upb_syntax_t;
1913
1914 /* Maximum field number allowed for FieldDefs. This is an inherent limit of the 1486 /* Maximum field number allowed for FieldDefs. This is an inherent limit of the
1915 * protobuf wire format. */ 1487 * protobuf wire format. */
1916 #define UPB_MAX_FIELDNUMBER ((1 << 29) - 1) 1488 #define UPB_MAX_FIELDNUMBER ((1 << 29) - 1)
1917 1489
1918 #ifdef __cplusplus 1490 #ifdef __cplusplus
1919 1491
1920 /* A upb_fielddef describes a single field in a message. It is most often 1492 /* A upb_fielddef describes a single field in a message. It is most often
1921 * found as a part of a upb_msgdef, but can also stand alone to represent 1493 * found as a part of a upb_msgdef, but can also stand alone to represent
1922 * an extension. 1494 * an extension.
1923 * 1495 *
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 /* Functionality from upb::Def. */ 1530 /* Functionality from upb::Def. */
1959 const char* full_name() const; 1531 const char* full_name() const;
1960 1532
1961 bool type_is_set() const; /* set_[descriptor_]type() has been called? */ 1533 bool type_is_set() const; /* set_[descriptor_]type() has been called? */
1962 Type type() const; /* Requires that type_is_set() == true. */ 1534 Type type() const; /* Requires that type_is_set() == true. */
1963 Label label() const; /* Defaults to UPB_LABEL_OPTIONAL. */ 1535 Label label() const; /* Defaults to UPB_LABEL_OPTIONAL. */
1964 const char* name() const; /* NULL if uninitialized. */ 1536 const char* name() const; /* NULL if uninitialized. */
1965 uint32_t number() const; /* Returns 0 if uninitialized. */ 1537 uint32_t number() const; /* Returns 0 if uninitialized. */
1966 bool is_extension() const; 1538 bool is_extension() const;
1967 1539
1968 /* Copies the JSON name for this field into the given buffer. Returns the
1969 * actual size of the JSON name, including the NULL terminator. If the
1970 * return value is 0, the JSON name is unset. If the return value is
1971 * greater than len, the JSON name was truncated. The buffer is always
1972 * NULL-terminated if len > 0.
1973 *
1974 * The JSON name always defaults to a camelCased version of the regular
1975 * name. However if the regular name is unset, the JSON name will be unset
1976 * also.
1977 */
1978 size_t GetJsonName(char* buf, size_t len) const;
1979
1980 /* Convenience version of the above function which copies the JSON name
1981 * into the given string, returning false if the name is not set. */
1982 template <class T>
1983 bool GetJsonName(T* str) {
1984 str->resize(GetJsonName(NULL, 0));
1985 GetJsonName(&(*str)[0], str->size());
1986 return str->size() > 0;
1987 }
1988
1989 /* For UPB_TYPE_MESSAGE fields only where is_tag_delimited() == false, 1540 /* For UPB_TYPE_MESSAGE fields only where is_tag_delimited() == false,
1990 * indicates whether this field should have lazy parsing handlers that yield 1541 * indicates whether this field should have lazy parsing handlers that yield
1991 * the unparsed string for the submessage. 1542 * the unparsed string for the submessage.
1992 * 1543 *
1993 * TODO(haberman): I think we want to move this into a FieldOptions container 1544 * TODO(haberman): I think we want to move this into a FieldOptions container
1994 * when we add support for custom options (the FieldOptions struct will 1545 * when we add support for custom options (the FieldOptions struct will
1995 * contain both regular FieldOptions like "lazy" *and* custom options). */ 1546 * contain both regular FieldOptions like "lazy" *and* custom options). */
1996 bool lazy() const; 1547 bool lazy() const;
1997 1548
1998 /* For non-string, non-submessage fields, this indicates whether binary 1549 /* For non-string, non-submessage fields, this indicates whether binary
1999 * protobufs are encoded in packed or non-packed format. 1550 * protobufs are encoded in packed or non-packed format.
2000 * 1551 *
2001 * TODO(haberman): see note above about putting options like this into a 1552 * TODO(haberman): see note above about putting options like this into a
2002 * FieldOptions container. */ 1553 * FieldOptions container. */
2003 bool packed() const; 1554 bool packed() const;
2004 1555
2005 /* An integer that can be used as an index into an array of fields for 1556 /* An integer that can be used as an index into an array of fields for
2006 * whatever message this field belongs to. Guaranteed to be less than 1557 * whatever message this field belongs to. Guaranteed to be less than
2007 * f->containing_type()->field_count(). May only be accessed once the def has 1558 * f->containing_type()->field_count(). May only be accessed once the def has
2008 * been finalized. */ 1559 * been finalized. */
2009 uint32_t index() const; 1560 int index() const;
2010 1561
2011 /* The MessageDef to which this field belongs. 1562 /* The MessageDef to which this field belongs.
2012 * 1563 *
2013 * If this field has been added to a MessageDef, that message can be retrieved 1564 * If this field has been added to a MessageDef, that message can be retrieved
2014 * directly (this is always the case for frozen FieldDefs). 1565 * directly (this is always the case for frozen FieldDefs).
2015 * 1566 *
2016 * If the field has not yet been added to a MessageDef, you can set the name 1567 * If the field has not yet been added to a MessageDef, you can set the name
2017 * of the containing type symbolically instead. This is mostly useful for 1568 * of the containing type symbolically instead. This is mostly useful for
2018 * extensions, where the extension is declared separately from the message. */ 1569 * extensions, where the extension is declared separately from the message. */
2019 const MessageDef* containing_type() const; 1570 const MessageDef* containing_type() const;
(...skipping 11 matching lines...) Expand all
2031 * appropriately. */ 1582 * appropriately. */
2032 DescriptorType descriptor_type() const; 1583 DescriptorType descriptor_type() const;
2033 1584
2034 /* Convenient field type tests. */ 1585 /* Convenient field type tests. */
2035 bool IsSubMessage() const; 1586 bool IsSubMessage() const;
2036 bool IsString() const; 1587 bool IsString() const;
2037 bool IsSequence() const; 1588 bool IsSequence() const;
2038 bool IsPrimitive() const; 1589 bool IsPrimitive() const;
2039 bool IsMap() const; 1590 bool IsMap() const;
2040 1591
2041 /* Whether this field must be able to explicitly represent presence:
2042 *
2043 * * This is always false for repeated fields (an empty repeated field is
2044 * equivalent to a repeated field with zero entries).
2045 *
2046 * * This is always true for submessages.
2047 *
2048 * * For other fields, it depends on the message (see
2049 * MessageDef::SetPrimitivesHavePresence())
2050 */
2051 bool HasPresence() const;
2052
2053 /* How integers are encoded. Only meaningful for integer types. 1592 /* How integers are encoded. Only meaningful for integer types.
2054 * Defaults to UPB_INTFMT_VARIABLE, and is reset when "type" changes. */ 1593 * Defaults to UPB_INTFMT_VARIABLE, and is reset when "type" changes. */
2055 IntegerFormat integer_format() const; 1594 IntegerFormat integer_format() const;
2056 1595
2057 /* Whether a submessage field is tag-delimited or not (if false, then 1596 /* Whether a submessage field is tag-delimited or not (if false, then
2058 * length-delimited). May only be set when type() == UPB_TYPE_MESSAGE. */ 1597 * length-delimited). May only be set when type() == UPB_TYPE_MESSAGE. */
2059 bool is_tag_delimited() const; 1598 bool is_tag_delimited() const;
2060 1599
2061 /* Returns the non-string default value for this fielddef, which may either 1600 /* Returns the non-string default value for this fielddef, which may either
2062 * be something the client set explicitly or the "default default" (0 for 1601 * be something the client set explicitly or the "default default" (0 for
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 * MessageDef, and may not be set after that. 1683 * MessageDef, and may not be set after that.
2145 * 1684 *
2146 * "name" is the same as full_name()/set_full_name(), but since fielddefs 1685 * "name" is the same as full_name()/set_full_name(), but since fielddefs
2147 * most often use simple, non-qualified names, we provide this accessor 1686 * most often use simple, non-qualified names, we provide this accessor
2148 * also. Generally only extensions will want to think of this name as 1687 * also. Generally only extensions will want to think of this name as
2149 * fully-qualified. */ 1688 * fully-qualified. */
2150 bool set_number(uint32_t number, upb::Status* s); 1689 bool set_number(uint32_t number, upb::Status* s);
2151 bool set_name(const char* name, upb::Status* s); 1690 bool set_name(const char* name, upb::Status* s);
2152 bool set_name(const std::string& name, upb::Status* s); 1691 bool set_name(const std::string& name, upb::Status* s);
2153 1692
2154 /* Sets the JSON name to the given string. */
2155 /* TODO(haberman): implement. Right now only default json_name (camelCase)
2156 * is supported. */
2157 bool set_json_name(const char* json_name, upb::Status* s);
2158 bool set_json_name(const std::string& name, upb::Status* s);
2159
2160 /* Clears the JSON name. This will make it revert to its default, which is
2161 * a camelCased version of the regular field name. */
2162 void clear_json_name();
2163
2164 void set_integer_format(IntegerFormat format); 1693 void set_integer_format(IntegerFormat format);
2165 bool set_tag_delimited(bool tag_delimited, upb::Status* s); 1694 bool set_tag_delimited(bool tag_delimited, upb::Status* s);
2166 1695
2167 /* Sets default value for the field. The call must exactly match the type 1696 /* Sets default value for the field. The call must exactly match the type
2168 * of the field. Enum fields may use either setint32 or setstring to set 1697 * of the field. Enum fields may use either setint32 or setstring to set
2169 * the default numerically or symbolically, respectively, but symbolic 1698 * the default numerically or symbolically, respectively, but symbolic
2170 * defaults must be resolved before finalizing (see ResolveEnumDefault()). 1699 * defaults must be resolved before finalizing (see ResolveEnumDefault()).
2171 * 1700 *
2172 * Changing the type of a field will reset its default. */ 1701 * Changing the type of a field will reset its default. */
2173 void set_default_int64(int64_t val); 1702 void set_default_int64(int64_t val);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 1747
2219 bool upb_fielddef_typeisset(const upb_fielddef *f); 1748 bool upb_fielddef_typeisset(const upb_fielddef *f);
2220 upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f); 1749 upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f);
2221 upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f); 1750 upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f);
2222 upb_label_t upb_fielddef_label(const upb_fielddef *f); 1751 upb_label_t upb_fielddef_label(const upb_fielddef *f);
2223 uint32_t upb_fielddef_number(const upb_fielddef *f); 1752 uint32_t upb_fielddef_number(const upb_fielddef *f);
2224 const char *upb_fielddef_name(const upb_fielddef *f); 1753 const char *upb_fielddef_name(const upb_fielddef *f);
2225 bool upb_fielddef_isextension(const upb_fielddef *f); 1754 bool upb_fielddef_isextension(const upb_fielddef *f);
2226 bool upb_fielddef_lazy(const upb_fielddef *f); 1755 bool upb_fielddef_lazy(const upb_fielddef *f);
2227 bool upb_fielddef_packed(const upb_fielddef *f); 1756 bool upb_fielddef_packed(const upb_fielddef *f);
2228 size_t upb_fielddef_getjsonname(const upb_fielddef *f, char *buf, size_t len);
2229 const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f); 1757 const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f);
2230 const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f); 1758 const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f);
2231 upb_msgdef *upb_fielddef_containingtype_mutable(upb_fielddef *f); 1759 upb_msgdef *upb_fielddef_containingtype_mutable(upb_fielddef *f);
2232 const char *upb_fielddef_containingtypename(upb_fielddef *f); 1760 const char *upb_fielddef_containingtypename(upb_fielddef *f);
2233 upb_intfmt_t upb_fielddef_intfmt(const upb_fielddef *f); 1761 upb_intfmt_t upb_fielddef_intfmt(const upb_fielddef *f);
2234 uint32_t upb_fielddef_index(const upb_fielddef *f); 1762 uint32_t upb_fielddef_index(const upb_fielddef *f);
2235 bool upb_fielddef_istagdelim(const upb_fielddef *f); 1763 bool upb_fielddef_istagdelim(const upb_fielddef *f);
2236 bool upb_fielddef_issubmsg(const upb_fielddef *f); 1764 bool upb_fielddef_issubmsg(const upb_fielddef *f);
2237 bool upb_fielddef_isstring(const upb_fielddef *f); 1765 bool upb_fielddef_isstring(const upb_fielddef *f);
2238 bool upb_fielddef_isseq(const upb_fielddef *f); 1766 bool upb_fielddef_isseq(const upb_fielddef *f);
2239 bool upb_fielddef_isprimitive(const upb_fielddef *f); 1767 bool upb_fielddef_isprimitive(const upb_fielddef *f);
2240 bool upb_fielddef_ismap(const upb_fielddef *f); 1768 bool upb_fielddef_ismap(const upb_fielddef *f);
2241 bool upb_fielddef_haspresence(const upb_fielddef *f);
2242 int64_t upb_fielddef_defaultint64(const upb_fielddef *f); 1769 int64_t upb_fielddef_defaultint64(const upb_fielddef *f);
2243 int32_t upb_fielddef_defaultint32(const upb_fielddef *f); 1770 int32_t upb_fielddef_defaultint32(const upb_fielddef *f);
2244 uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f); 1771 uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f);
2245 uint32_t upb_fielddef_defaultuint32(const upb_fielddef *f); 1772 uint32_t upb_fielddef_defaultuint32(const upb_fielddef *f);
2246 bool upb_fielddef_defaultbool(const upb_fielddef *f); 1773 bool upb_fielddef_defaultbool(const upb_fielddef *f);
2247 float upb_fielddef_defaultfloat(const upb_fielddef *f); 1774 float upb_fielddef_defaultfloat(const upb_fielddef *f);
2248 double upb_fielddef_defaultdouble(const upb_fielddef *f); 1775 double upb_fielddef_defaultdouble(const upb_fielddef *f);
2249 const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len); 1776 const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len);
2250 bool upb_fielddef_enumhasdefaultint32(const upb_fielddef *f); 1777 bool upb_fielddef_enumhasdefaultint32(const upb_fielddef *f);
2251 bool upb_fielddef_enumhasdefaultstr(const upb_fielddef *f); 1778 bool upb_fielddef_enumhasdefaultstr(const upb_fielddef *f);
2252 bool upb_fielddef_hassubdef(const upb_fielddef *f); 1779 bool upb_fielddef_hassubdef(const upb_fielddef *f);
2253 const upb_def *upb_fielddef_subdef(const upb_fielddef *f); 1780 const upb_def *upb_fielddef_subdef(const upb_fielddef *f);
2254 const upb_msgdef *upb_fielddef_msgsubdef(const upb_fielddef *f); 1781 const upb_msgdef *upb_fielddef_msgsubdef(const upb_fielddef *f);
2255 const upb_enumdef *upb_fielddef_enumsubdef(const upb_fielddef *f); 1782 const upb_enumdef *upb_fielddef_enumsubdef(const upb_fielddef *f);
2256 const char *upb_fielddef_subdefname(const upb_fielddef *f); 1783 const char *upb_fielddef_subdefname(const upb_fielddef *f);
2257 1784
2258 void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type); 1785 void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type);
2259 void upb_fielddef_setdescriptortype(upb_fielddef *f, int type); 1786 void upb_fielddef_setdescriptortype(upb_fielddef *f, int type);
2260 void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label); 1787 void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label);
2261 bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s); 1788 bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s);
2262 bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s); 1789 bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s);
2263 bool upb_fielddef_setjsonname(upb_fielddef *f, const char *name, upb_status *s);
2264 bool upb_fielddef_clearjsonname(upb_fielddef *f);
2265 bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name, 1790 bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name,
2266 upb_status *s); 1791 upb_status *s);
2267 void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension); 1792 void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension);
2268 void upb_fielddef_setlazy(upb_fielddef *f, bool lazy); 1793 void upb_fielddef_setlazy(upb_fielddef *f, bool lazy);
2269 void upb_fielddef_setpacked(upb_fielddef *f, bool packed); 1794 void upb_fielddef_setpacked(upb_fielddef *f, bool packed);
2270 void upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt); 1795 void upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt);
2271 void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim); 1796 void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim);
2272 void upb_fielddef_setdefaultint64(upb_fielddef *f, int64_t val); 1797 void upb_fielddef_setdefaultint64(upb_fielddef *f, int64_t val);
2273 void upb_fielddef_setdefaultint32(upb_fielddef *f, int32_t val); 1798 void upb_fielddef_setdefaultint32(upb_fielddef *f, int32_t val);
2274 void upb_fielddef_setdefaultuint64(upb_fielddef *f, uint64_t val); 1799 void upb_fielddef_setdefaultuint64(upb_fielddef *f, uint64_t val);
(...skipping 20 matching lines...) Expand all
2295 bool upb_fielddef_checkintfmt(int32_t fmt); 1820 bool upb_fielddef_checkintfmt(int32_t fmt);
2296 1821
2297 UPB_END_EXTERN_C 1822 UPB_END_EXTERN_C
2298 1823
2299 1824
2300 /* upb::MessageDef ************************************************************/ 1825 /* upb::MessageDef ************************************************************/
2301 1826
2302 typedef upb_inttable_iter upb_msg_field_iter; 1827 typedef upb_inttable_iter upb_msg_field_iter;
2303 typedef upb_strtable_iter upb_msg_oneof_iter; 1828 typedef upb_strtable_iter upb_msg_oneof_iter;
2304 1829
2305 /* Well-known field tag numbers for map-entry messages. */
2306 #define UPB_MAPENTRY_KEY 1
2307 #define UPB_MAPENTRY_VALUE 2
2308
2309 #ifdef __cplusplus 1830 #ifdef __cplusplus
2310 1831
2311 /* Structure that describes a single .proto message type. 1832 /* Structure that describes a single .proto message type.
2312 * 1833 *
2313 * Its base class is upb::Def (use upb::upcast() to convert). */ 1834 * Its base class is upb::Def (use upb::upcast() to convert). */
2314 class upb::MessageDef { 1835 class upb::MessageDef {
2315 public: 1836 public:
2316 /* Returns NULL if memory allocation failed. */ 1837 /* Returns NULL if memory allocation failed. */
2317 static reffed_ptr<MessageDef> New(); 1838 static reffed_ptr<MessageDef> New();
2318 1839
2319 /* upb::RefCounted methods like Ref()/Unref(). */ 1840 /* upb::RefCounted methods like Ref()/Unref(). */
2320 UPB_REFCOUNTED_CPPMETHODS 1841 UPB_REFCOUNTED_CPPMETHODS
2321 1842
2322 /* Functionality from upb::Def. */ 1843 /* Functionality from upb::Def. */
2323 const char* full_name() const; 1844 const char* full_name() const;
2324 const char* name() const;
2325 bool set_full_name(const char* fullname, Status* s); 1845 bool set_full_name(const char* fullname, Status* s);
2326 bool set_full_name(const std::string& fullname, Status* s); 1846 bool set_full_name(const std::string& fullname, Status* s);
2327 1847
2328 /* Call to freeze this MessageDef. 1848 /* Call to freeze this MessageDef.
2329 * WARNING: this will fail if this message has any unfrozen submessages! 1849 * WARNING: this will fail if this message has any unfrozen submessages!
2330 * Messages with cycles must be frozen as a batch using upb::Def::Freeze(). */ 1850 * Messages with cycles must be frozen as a batch using upb::Def::Freeze(). */
2331 bool Freeze(Status* s); 1851 bool Freeze(Status* s);
2332 1852
2333 /* The number of fields that belong to the MessageDef. */ 1853 /* The number of fields that belong to the MessageDef. */
2334 int field_count() const; 1854 int field_count() const;
(...skipping 22 matching lines...) Expand all
2357 /* Adds a oneof (upb_oneofdef object) to a msgdef. Requires that the msgdef, 1877 /* Adds a oneof (upb_oneofdef object) to a msgdef. Requires that the msgdef,
2358 * oneof, and any fielddefs are mutable, that the fielddefs contained in the 1878 * oneof, and any fielddefs are mutable, that the fielddefs contained in the
2359 * oneof do not have any name or number conflicts with existing fields in the 1879 * oneof do not have any name or number conflicts with existing fields in the
2360 * msgdef, and that the oneof's name is unique among all oneofs in the msgdef. 1880 * msgdef, and that the oneof's name is unique among all oneofs in the msgdef.
2361 * If the oneof is added successfully, all of its fields will be added 1881 * If the oneof is added successfully, all of its fields will be added
2362 * directly to the msgdef as well. In error cases, false is returned and the 1882 * directly to the msgdef as well. In error cases, false is returned and the
2363 * msgdef is unchanged. */ 1883 * msgdef is unchanged. */
2364 bool AddOneof(OneofDef* o, Status* s); 1884 bool AddOneof(OneofDef* o, Status* s);
2365 bool AddOneof(const reffed_ptr<OneofDef>& o, Status* s); 1885 bool AddOneof(const reffed_ptr<OneofDef>& o, Status* s);
2366 1886
2367 upb_syntax_t syntax() const;
2368
2369 /* Returns false if we don't support this syntax value. */
2370 bool set_syntax(upb_syntax_t syntax);
2371
2372 /* Set this to false to indicate that primitive fields should not have
2373 * explicit presence information associated with them. This will affect all
2374 * fields added to this message. Defaults to true. */
2375 void SetPrimitivesHavePresence(bool have_presence);
2376
2377 /* These return NULL if the field is not found. */ 1887 /* These return NULL if the field is not found. */
2378 FieldDef* FindFieldByNumber(uint32_t number); 1888 FieldDef* FindFieldByNumber(uint32_t number);
2379 FieldDef* FindFieldByName(const char *name, size_t len); 1889 FieldDef* FindFieldByName(const char *name, size_t len);
2380 const FieldDef* FindFieldByNumber(uint32_t number) const; 1890 const FieldDef* FindFieldByNumber(uint32_t number) const;
2381 const FieldDef* FindFieldByName(const char* name, size_t len) const; 1891 const FieldDef* FindFieldByName(const char* name, size_t len) const;
2382 1892
2383 1893
2384 FieldDef* FindFieldByName(const char *name) { 1894 FieldDef* FindFieldByName(const char *name) {
2385 return FindFieldByName(name, strlen(name)); 1895 return FindFieldByName(name, strlen(name));
2386 } 1896 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 UPB_BEGIN_EXTERN_C 2062 UPB_BEGIN_EXTERN_C
2553 2063
2554 /* Returns NULL if memory allocation failed. */ 2064 /* Returns NULL if memory allocation failed. */
2555 upb_msgdef *upb_msgdef_new(const void *owner); 2065 upb_msgdef *upb_msgdef_new(const void *owner);
2556 2066
2557 /* Include upb_refcounted methods like upb_msgdef_ref(). */ 2067 /* Include upb_refcounted methods like upb_msgdef_ref(). */
2558 UPB_REFCOUNTED_CMETHODS(upb_msgdef, upb_msgdef_upcast2) 2068 UPB_REFCOUNTED_CMETHODS(upb_msgdef, upb_msgdef_upcast2)
2559 2069
2560 bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status); 2070 bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status);
2561 2071
2072 const char *upb_msgdef_fullname(const upb_msgdef *m);
2073 bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname, upb_status *s);
2074
2562 upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner); 2075 upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner);
2563 const char *upb_msgdef_fullname(const upb_msgdef *m);
2564 const char *upb_msgdef_name(const upb_msgdef *m);
2565 int upb_msgdef_numoneofs(const upb_msgdef *m);
2566 upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m);
2567
2568 bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor, 2076 bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor,
2569 upb_status *s); 2077 upb_status *s);
2570 bool upb_msgdef_addoneof(upb_msgdef *m, upb_oneofdef *o, const void *ref_donor, 2078 bool upb_msgdef_addoneof(upb_msgdef *m, upb_oneofdef *o, const void *ref_donor,
2571 upb_status *s); 2079 upb_status *s);
2572 bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname, upb_status *s);
2573 void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry);
2574 bool upb_msgdef_mapentry(const upb_msgdef *m);
2575 bool upb_msgdef_setsyntax(upb_msgdef *m, upb_syntax_t syntax);
2576 2080
2577 /* Field lookup in a couple of different variations: 2081 /* Field lookup in a couple of different variations:
2578 * - itof = int to field 2082 * - itof = int to field
2579 * - ntof = name to field 2083 * - ntof = name to field
2580 * - ntofz = name to field, null-terminated string. */ 2084 * - ntofz = name to field, null-terminated string. */
2581 const upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i); 2085 const upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i);
2582 const upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name, 2086 const upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name,
2583 size_t len); 2087 size_t len);
2584 int upb_msgdef_numfields(const upb_msgdef *m); 2088 int upb_msgdef_numfields(const upb_msgdef *m);
2585 2089
(...skipping 21 matching lines...) Expand all
2607 UPB_INLINE const upb_oneofdef *upb_msgdef_ntooz(const upb_msgdef *m, 2111 UPB_INLINE const upb_oneofdef *upb_msgdef_ntooz(const upb_msgdef *m,
2608 const char *name) { 2112 const char *name) {
2609 return upb_msgdef_ntoo(m, name, strlen(name)); 2113 return upb_msgdef_ntoo(m, name, strlen(name));
2610 } 2114 }
2611 2115
2612 UPB_INLINE upb_oneofdef *upb_msgdef_ntoo_mutable(upb_msgdef *m, 2116 UPB_INLINE upb_oneofdef *upb_msgdef_ntoo_mutable(upb_msgdef *m,
2613 const char *name, size_t len) { 2117 const char *name, size_t len) {
2614 return (upb_oneofdef *)upb_msgdef_ntoo(m, name, len); 2118 return (upb_oneofdef *)upb_msgdef_ntoo(m, name, len);
2615 } 2119 }
2616 2120
2617 /* Lookup of either field or oneof by name. Returns whether either was found. 2121 void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry);
2618 * If the return is true, then the found def will be set, and the non-found 2122 bool upb_msgdef_mapentry(const upb_msgdef *m);
2619 * one set to NULL. */
2620 bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len,
2621 const upb_fielddef **f, const upb_oneofdef **o);
2622 2123
2623 UPB_INLINE bool upb_msgdef_lookupnamez(const upb_msgdef *m, const char *name, 2124 /* Well-known field tag numbers for map-entry messages. */
2624 const upb_fielddef **f, 2125 #define UPB_MAPENTRY_KEY 1
2625 const upb_oneofdef **o) { 2126 #define UPB_MAPENTRY_VALUE 2
2626 return upb_msgdef_lookupname(m, name, strlen(name), f, o);
2627 }
2628 2127
2629 /* Iteration over fields and oneofs. For example: 2128 const upb_oneofdef *upb_msgdef_findoneof(const upb_msgdef *m,
2630 * 2129 const char *name);
2631 * upb_msg_field_iter i; 2130 int upb_msgdef_numoneofs(const upb_msgdef *m);
2131
2132 /* upb_msg_field_iter i;
2632 * for(upb_msg_field_begin(&i, m); 2133 * for(upb_msg_field_begin(&i, m);
2633 * !upb_msg_field_done(&i); 2134 * !upb_msg_field_done(&i);
2634 * upb_msg_field_next(&i)) { 2135 * upb_msg_field_next(&i)) {
2635 * upb_fielddef *f = upb_msg_iter_field(&i); 2136 * upb_fielddef *f = upb_msg_iter_field(&i);
2636 * // ... 2137 * // ...
2637 * } 2138 * }
2638 * 2139 *
2639 * For C we don't have separate iterators for const and non-const. 2140 * For C we don't have separate iterators for const and non-const.
2640 * It is the caller's responsibility to cast the upb_fielddef* to 2141 * It is the caller's responsibility to cast the upb_fielddef* to
2641 * const if the upb_msgdef* is const. */ 2142 * const if the upb_msgdef* is const. */
(...skipping 25 matching lines...) Expand all
2667 class upb::EnumDef { 2168 class upb::EnumDef {
2668 public: 2169 public:
2669 /* Returns NULL if memory allocation failed. */ 2170 /* Returns NULL if memory allocation failed. */
2670 static reffed_ptr<EnumDef> New(); 2171 static reffed_ptr<EnumDef> New();
2671 2172
2672 /* upb::RefCounted methods like Ref()/Unref(). */ 2173 /* upb::RefCounted methods like Ref()/Unref(). */
2673 UPB_REFCOUNTED_CPPMETHODS 2174 UPB_REFCOUNTED_CPPMETHODS
2674 2175
2675 /* Functionality from upb::Def. */ 2176 /* Functionality from upb::Def. */
2676 const char* full_name() const; 2177 const char* full_name() const;
2677 const char* name() const;
2678 bool set_full_name(const char* fullname, Status* s); 2178 bool set_full_name(const char* fullname, Status* s);
2679 bool set_full_name(const std::string& fullname, Status* s); 2179 bool set_full_name(const std::string& fullname, Status* s);
2680 2180
2681 /* Call to freeze this EnumDef. */ 2181 /* Call to freeze this EnumDef. */
2682 bool Freeze(Status* s); 2182 bool Freeze(Status* s);
2683 2183
2684 /* The value that is used as the default when no field default is specified. 2184 /* The value that is used as the default when no field default is specified.
2685 * If not set explicitly, the first value that was added will be used. 2185 * If not set explicitly, the first value that was added will be used.
2686 * The default value must be a member of the enum. 2186 * The default value must be a member of the enum.
2687 * Requires that value_count() > 0. */ 2187 * Requires that value_count() > 0. */
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2742 upb_enumdef *upb_enumdef_new(const void *owner); 2242 upb_enumdef *upb_enumdef_new(const void *owner);
2743 upb_enumdef *upb_enumdef_dup(const upb_enumdef *e, const void *owner); 2243 upb_enumdef *upb_enumdef_dup(const upb_enumdef *e, const void *owner);
2744 2244
2745 /* Include upb_refcounted methods like upb_enumdef_ref(). */ 2245 /* Include upb_refcounted methods like upb_enumdef_ref(). */
2746 UPB_REFCOUNTED_CMETHODS(upb_enumdef, upb_enumdef_upcast2) 2246 UPB_REFCOUNTED_CMETHODS(upb_enumdef, upb_enumdef_upcast2)
2747 2247
2748 bool upb_enumdef_freeze(upb_enumdef *e, upb_status *status); 2248 bool upb_enumdef_freeze(upb_enumdef *e, upb_status *status);
2749 2249
2750 /* From upb_def. */ 2250 /* From upb_def. */
2751 const char *upb_enumdef_fullname(const upb_enumdef *e); 2251 const char *upb_enumdef_fullname(const upb_enumdef *e);
2752 const char *upb_enumdef_name(const upb_enumdef *e);
2753 bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname, 2252 bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname,
2754 upb_status *s); 2253 upb_status *s);
2755 2254
2756 int32_t upb_enumdef_default(const upb_enumdef *e); 2255 int32_t upb_enumdef_default(const upb_enumdef *e);
2757 bool upb_enumdef_setdefault(upb_enumdef *e, int32_t val, upb_status *s); 2256 bool upb_enumdef_setdefault(upb_enumdef *e, int32_t val, upb_status *s);
2758 int upb_enumdef_numvals(const upb_enumdef *e); 2257 int upb_enumdef_numvals(const upb_enumdef *e);
2759 bool upb_enumdef_addval(upb_enumdef *e, const char *name, int32_t num, 2258 bool upb_enumdef_addval(upb_enumdef *e, const char *name, int32_t num,
2760 upb_status *status); 2259 upb_status *status);
2761 2260
2762 /* Enum lookups: 2261 /* Enum lookups:
(...skipping 21 matching lines...) Expand all
2784 int32_t upb_enum_iter_number(upb_enum_iter *iter); 2283 int32_t upb_enum_iter_number(upb_enum_iter *iter);
2785 2284
2786 UPB_END_EXTERN_C 2285 UPB_END_EXTERN_C
2787 2286
2788 /* upb::OneofDef **************************************************************/ 2287 /* upb::OneofDef **************************************************************/
2789 2288
2790 typedef upb_inttable_iter upb_oneof_iter; 2289 typedef upb_inttable_iter upb_oneof_iter;
2791 2290
2792 #ifdef __cplusplus 2291 #ifdef __cplusplus
2793 2292
2794 /* Class that represents a oneof. */ 2293 /* Class that represents a oneof. Its base class is upb::Def (convert with
2294 * upb::upcast()). */
2795 class upb::OneofDef { 2295 class upb::OneofDef {
2796 public: 2296 public:
2797 /* Returns NULL if memory allocation failed. */ 2297 /* Returns NULL if memory allocation failed. */
2798 static reffed_ptr<OneofDef> New(); 2298 static reffed_ptr<OneofDef> New();
2799 2299
2800 /* upb::RefCounted methods like Ref()/Unref(). */ 2300 /* upb::RefCounted methods like Ref()/Unref(). */
2801 UPB_REFCOUNTED_CPPMETHODS 2301 UPB_REFCOUNTED_CPPMETHODS
2802 2302
2303 /* Functionality from upb::Def. */
2304 const char* full_name() const;
2305
2803 /* Returns the MessageDef that owns this OneofDef. */ 2306 /* Returns the MessageDef that owns this OneofDef. */
2804 const MessageDef* containing_type() const; 2307 const MessageDef* containing_type() const;
2805 2308
2806 /* Returns the name of this oneof. This is the name used to look up the oneof 2309 /* Returns the name of this oneof. This is the name used to look up the oneof
2807 * by name once added to a message def. */ 2310 * by name once added to a message def. */
2808 const char* name() const; 2311 const char* name() const;
2809 bool set_name(const char* name, Status* s); 2312 bool set_name(const char* name, Status* s);
2810 bool set_name(const std::string& name, Status* s);
2811 2313
2812 /* Returns the number of fields currently defined in the oneof. */ 2314 /* Returns the number of fields currently defined in the oneof. */
2813 int field_count() const; 2315 int field_count() const;
2814 2316
2815 /* Adds a field to the oneof. The field must not have been added to any other 2317 /* Adds a field to the oneof. The field must not have been added to any other
2816 * oneof or msgdef. If the oneof is not yet part of a msgdef, then when the 2318 * oneof or msgdef. If the oneof is not yet part of a msgdef, then when the
2817 * oneof is eventually added to a msgdef, all fields added to the oneof will 2319 * oneof is eventually added to a msgdef, all fields added to the oneof will
2818 * also be added to the msgdef at that time. If the oneof is already part of a 2320 * also be added to the msgdef at that time. If the oneof is already part of a
2819 * msgdef, the field must either be a part of that msgdef already, or must not 2321 * msgdef, the field must either be a part of that msgdef already, or must not
2820 * be a part of any msgdef; in the latter case, the field is added to the 2322 * be a part of any msgdef; in the latter case, the field is added to the
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2894 2396
2895 #endif /* __cplusplus */ 2397 #endif /* __cplusplus */
2896 2398
2897 UPB_BEGIN_EXTERN_C 2399 UPB_BEGIN_EXTERN_C
2898 2400
2899 /* Native C API. */ 2401 /* Native C API. */
2900 upb_oneofdef *upb_oneofdef_new(const void *owner); 2402 upb_oneofdef *upb_oneofdef_new(const void *owner);
2901 upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner); 2403 upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner);
2902 2404
2903 /* Include upb_refcounted methods like upb_oneofdef_ref(). */ 2405 /* Include upb_refcounted methods like upb_oneofdef_ref(). */
2904 UPB_REFCOUNTED_CMETHODS(upb_oneofdef, upb_oneofdef_upcast) 2406 UPB_REFCOUNTED_CMETHODS(upb_oneofdef, upb_oneofdef_upcast2)
2905 2407
2906 const char *upb_oneofdef_name(const upb_oneofdef *o); 2408 const char *upb_oneofdef_name(const upb_oneofdef *o);
2907 bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s); 2409 bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s);
2908 2410
2909 const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o); 2411 const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o);
2910 int upb_oneofdef_numfields(const upb_oneofdef *o); 2412 int upb_oneofdef_numfields(const upb_oneofdef *o);
2911 bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f, 2413 bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f,
2912 const void *ref_donor, 2414 const void *ref_donor,
2913 upb_status *s); 2415 upb_status *s);
2914 2416
(...skipping 15 matching lines...) Expand all
2930 * } 2432 * }
2931 */ 2433 */
2932 void upb_oneof_begin(upb_oneof_iter *iter, const upb_oneofdef *o); 2434 void upb_oneof_begin(upb_oneof_iter *iter, const upb_oneofdef *o);
2933 void upb_oneof_next(upb_oneof_iter *iter); 2435 void upb_oneof_next(upb_oneof_iter *iter);
2934 bool upb_oneof_done(upb_oneof_iter *iter); 2436 bool upb_oneof_done(upb_oneof_iter *iter);
2935 upb_fielddef *upb_oneof_iter_field(const upb_oneof_iter *iter); 2437 upb_fielddef *upb_oneof_iter_field(const upb_oneof_iter *iter);
2936 void upb_oneof_iter_setdone(upb_oneof_iter *iter); 2438 void upb_oneof_iter_setdone(upb_oneof_iter *iter);
2937 2439
2938 UPB_END_EXTERN_C 2440 UPB_END_EXTERN_C
2939 2441
2940
2941 /* upb::FileDef ***************************************************************/
2942
2943 #ifdef __cplusplus
2944
2945 /* Class that represents a .proto file with some things defined in it.
2946 *
2947 * Many users won't care about FileDefs, but they are necessary if you want to
2948 * read the values of file-level options. */
2949 class upb::FileDef {
2950 public:
2951 /* Returns NULL if memory allocation failed. */
2952 static reffed_ptr<FileDef> New();
2953
2954 /* upb::RefCounted methods like Ref()/Unref(). */
2955 UPB_REFCOUNTED_CPPMETHODS
2956
2957 /* Get/set name of the file (eg. "foo/bar.proto"). */
2958 const char* name() const;
2959 bool set_name(const char* name, Status* s);
2960 bool set_name(const std::string& name, Status* s);
2961
2962 /* Package name for definitions inside the file (eg. "foo.bar"). */
2963 const char* package() const;
2964 bool set_package(const char* package, Status* s);
2965
2966 /* Syntax for the file. Defaults to proto2. */
2967 upb_syntax_t syntax() const;
2968 void set_syntax(upb_syntax_t syntax);
2969
2970 /* Get the list of defs from the file. These are returned in the order that
2971 * they were added to the FileDef. */
2972 int def_count() const;
2973 const Def* def(int index) const;
2974 Def* def(int index);
2975
2976 /* Get the list of dependencies from the file. These are returned in the
2977 * order that they were added to the FileDef. */
2978 int dependency_count() const;
2979 const FileDef* dependency(int index) const;
2980
2981 /* Adds defs to this file. The def must not already belong to another
2982 * file.
2983 *
2984 * Note: this does *not* ensure that this def's name is unique in this file!
2985 * Use a SymbolTable if you want to check this property. Especially since
2986 * properly checking uniqueness would require a check across *all* files
2987 * (including dependencies). */
2988 bool AddDef(Def* def, Status* s);
2989 bool AddMessage(MessageDef* m, Status* s);
2990 bool AddEnum(EnumDef* e, Status* s);
2991 bool AddExtension(FieldDef* f, Status* s);
2992
2993 /* Adds a dependency of this file. */
2994 bool AddDependency(const FileDef* file);
2995
2996 /* Freezes this FileDef and all messages/enums under it. All subdefs must be
2997 * resolved and all messages/enums must validate. Returns true if this
2998 * succeeded.
2999 *
3000 * TODO(haberman): should we care whether the file's dependencies are frozen
3001 * already? */
3002 bool Freeze(Status* s);
3003
3004 private:
3005 UPB_DISALLOW_POD_OPS(FileDef, upb::FileDef)
3006 };
3007
3008 #endif
3009
3010 UPB_BEGIN_EXTERN_C
3011
3012 upb_filedef *upb_filedef_new(const void *owner);
3013
3014 /* Include upb_refcounted methods like upb_msgdef_ref(). */
3015 UPB_REFCOUNTED_CMETHODS(upb_filedef, upb_filedef_upcast)
3016
3017 const char *upb_filedef_name(const upb_filedef *f);
3018 const char *upb_filedef_package(const upb_filedef *f);
3019 upb_syntax_t upb_filedef_syntax(const upb_filedef *f);
3020 size_t upb_filedef_defcount(const upb_filedef *f);
3021 size_t upb_filedef_depcount(const upb_filedef *f);
3022 const upb_def *upb_filedef_def(const upb_filedef *f, size_t i);
3023 const upb_filedef *upb_filedef_dep(const upb_filedef *f, size_t i);
3024
3025 bool upb_filedef_freeze(upb_filedef *f, upb_status *s);
3026 bool upb_filedef_setname(upb_filedef *f, const char *name, upb_status *s);
3027 bool upb_filedef_setpackage(upb_filedef *f, const char *package, upb_status *s);
3028 bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax, upb_status *s);
3029
3030 bool upb_filedef_adddef(upb_filedef *f, upb_def *def, const void *ref_donor,
3031 upb_status *s);
3032 bool upb_filedef_adddep(upb_filedef *f, const upb_filedef *dep);
3033
3034 UPB_INLINE bool upb_filedef_addmsg(upb_filedef *f, upb_msgdef *m,
3035 const void *ref_donor, upb_status *s) {
3036 return upb_filedef_adddef(f, upb_msgdef_upcast_mutable(m), ref_donor, s);
3037 }
3038
3039 UPB_INLINE bool upb_filedef_addenum(upb_filedef *f, upb_enumdef *e,
3040 const void *ref_donor, upb_status *s) {
3041 return upb_filedef_adddef(f, upb_enumdef_upcast_mutable(e), ref_donor, s);
3042 }
3043
3044 UPB_INLINE bool upb_filedef_addext(upb_filedef *file, upb_fielddef *f,
3045 const void *ref_donor, upb_status *s) {
3046 return upb_filedef_adddef(file, upb_fielddef_upcast_mutable(f), ref_donor, s);
3047 }
3048 UPB_INLINE upb_def *upb_filedef_mutabledef(upb_filedef *f, int i) {
3049 return (upb_def*)upb_filedef_def(f, i);
3050 }
3051
3052 UPB_END_EXTERN_C
3053
3054 #ifdef __cplusplus 2442 #ifdef __cplusplus
3055 2443
3056 UPB_INLINE const char* upb_safecstr(const std::string& str) { 2444 UPB_INLINE const char* upb_safecstr(const std::string& str) {
3057 UPB_ASSERT(str.size() == std::strlen(str.c_str())); 2445 assert(str.size() == std::strlen(str.c_str()));
3058 return str.c_str(); 2446 return str.c_str();
3059 } 2447 }
3060 2448
3061 /* Inline C++ wrappers. */ 2449 /* Inline C++ wrappers. */
3062 namespace upb { 2450 namespace upb {
3063 2451
3064 inline Def* Def::Dup(const void* owner) const { 2452 inline Def* Def::Dup(const void* owner) const {
3065 return upb_def_dup(this, owner); 2453 return upb_def_dup(this, owner);
3066 } 2454 }
3067 inline Def::Type Def::def_type() const { return upb_def_type(this); } 2455 inline Def::Type Def::def_type() const { return upb_def_type(this); }
3068 inline const char* Def::full_name() const { return upb_def_fullname(this); } 2456 inline const char* Def::full_name() const { return upb_def_fullname(this); }
3069 inline const char* Def::name() const { return upb_def_name(this); }
3070 inline bool Def::set_full_name(const char* fullname, Status* s) { 2457 inline bool Def::set_full_name(const char* fullname, Status* s) {
3071 return upb_def_setfullname(this, fullname, s); 2458 return upb_def_setfullname(this, fullname, s);
3072 } 2459 }
3073 inline bool Def::set_full_name(const std::string& fullname, Status* s) { 2460 inline bool Def::set_full_name(const std::string& fullname, Status* s) {
3074 return upb_def_setfullname(this, upb_safecstr(fullname), s); 2461 return upb_def_setfullname(this, upb_safecstr(fullname), s);
3075 } 2462 }
3076 inline bool Def::Freeze(Def* const* defs, size_t n, Status* status) { 2463 inline bool Def::Freeze(Def* const* defs, int n, Status* status) {
3077 return upb_def_freeze(defs, n, status); 2464 return upb_def_freeze(defs, n, status);
3078 } 2465 }
3079 inline bool Def::Freeze(const std::vector<Def*>& defs, Status* status) { 2466 inline bool Def::Freeze(const std::vector<Def*>& defs, Status* status) {
3080 return upb_def_freeze((Def* const*)&defs[0], defs.size(), status); 2467 return upb_def_freeze((Def* const*)&defs[0], defs.size(), status);
3081 } 2468 }
3082 2469
3083 inline bool FieldDef::CheckType(int32_t val) { 2470 inline bool FieldDef::CheckType(int32_t val) {
3084 return upb_fielddef_checktype(val); 2471 return upb_fielddef_checktype(val);
3085 } 2472 }
3086 inline bool FieldDef::CheckLabel(int32_t val) { 2473 inline bool FieldDef::CheckLabel(int32_t val) {
3087 return upb_fielddef_checklabel(val); 2474 return upb_fielddef_checklabel(val);
3088 } 2475 }
3089 inline bool FieldDef::CheckDescriptorType(int32_t val) { 2476 inline bool FieldDef::CheckDescriptorType(int32_t val) {
3090 return upb_fielddef_checkdescriptortype(val); 2477 return upb_fielddef_checkdescriptortype(val);
3091 } 2478 }
3092 inline bool FieldDef::CheckIntegerFormat(int32_t val) { 2479 inline bool FieldDef::CheckIntegerFormat(int32_t val) {
3093 return upb_fielddef_checkintfmt(val); 2480 return upb_fielddef_checkintfmt(val);
3094 } 2481 }
3095 inline FieldDef::Type FieldDef::ConvertType(int32_t val) { 2482 inline FieldDef::Type FieldDef::ConvertType(int32_t val) {
3096 UPB_ASSERT(CheckType(val)); 2483 assert(CheckType(val));
3097 return static_cast<FieldDef::Type>(val); 2484 return static_cast<FieldDef::Type>(val);
3098 } 2485 }
3099 inline FieldDef::Label FieldDef::ConvertLabel(int32_t val) { 2486 inline FieldDef::Label FieldDef::ConvertLabel(int32_t val) {
3100 UPB_ASSERT(CheckLabel(val)); 2487 assert(CheckLabel(val));
3101 return static_cast<FieldDef::Label>(val); 2488 return static_cast<FieldDef::Label>(val);
3102 } 2489 }
3103 inline FieldDef::DescriptorType FieldDef::ConvertDescriptorType(int32_t val) { 2490 inline FieldDef::DescriptorType FieldDef::ConvertDescriptorType(int32_t val) {
3104 UPB_ASSERT(CheckDescriptorType(val)); 2491 assert(CheckDescriptorType(val));
3105 return static_cast<FieldDef::DescriptorType>(val); 2492 return static_cast<FieldDef::DescriptorType>(val);
3106 } 2493 }
3107 inline FieldDef::IntegerFormat FieldDef::ConvertIntegerFormat(int32_t val) { 2494 inline FieldDef::IntegerFormat FieldDef::ConvertIntegerFormat(int32_t val) {
3108 UPB_ASSERT(CheckIntegerFormat(val)); 2495 assert(CheckIntegerFormat(val));
3109 return static_cast<FieldDef::IntegerFormat>(val); 2496 return static_cast<FieldDef::IntegerFormat>(val);
3110 } 2497 }
3111 2498
3112 inline reffed_ptr<FieldDef> FieldDef::New() { 2499 inline reffed_ptr<FieldDef> FieldDef::New() {
3113 upb_fielddef *f = upb_fielddef_new(&f); 2500 upb_fielddef *f = upb_fielddef_new(&f);
3114 return reffed_ptr<FieldDef>(f, &f); 2501 return reffed_ptr<FieldDef>(f, &f);
3115 } 2502 }
3116 inline FieldDef* FieldDef::Dup(const void* owner) const { 2503 inline FieldDef* FieldDef::Dup(const void* owner) const {
3117 return upb_fielddef_dup(this, owner); 2504 return upb_fielddef_dup(this, owner);
3118 } 2505 }
(...skipping 14 matching lines...) Expand all
3133 return upb_fielddef_descriptortype(this); 2520 return upb_fielddef_descriptortype(this);
3134 } 2521 }
3135 inline FieldDef::Label FieldDef::label() const { 2522 inline FieldDef::Label FieldDef::label() const {
3136 return upb_fielddef_label(this); 2523 return upb_fielddef_label(this);
3137 } 2524 }
3138 inline uint32_t FieldDef::number() const { return upb_fielddef_number(this); } 2525 inline uint32_t FieldDef::number() const { return upb_fielddef_number(this); }
3139 inline const char* FieldDef::name() const { return upb_fielddef_name(this); } 2526 inline const char* FieldDef::name() const { return upb_fielddef_name(this); }
3140 inline bool FieldDef::is_extension() const { 2527 inline bool FieldDef::is_extension() const {
3141 return upb_fielddef_isextension(this); 2528 return upb_fielddef_isextension(this);
3142 } 2529 }
3143 inline size_t FieldDef::GetJsonName(char* buf, size_t len) const {
3144 return upb_fielddef_getjsonname(this, buf, len);
3145 }
3146 inline bool FieldDef::lazy() const { 2530 inline bool FieldDef::lazy() const {
3147 return upb_fielddef_lazy(this); 2531 return upb_fielddef_lazy(this);
3148 } 2532 }
3149 inline void FieldDef::set_lazy(bool lazy) { 2533 inline void FieldDef::set_lazy(bool lazy) {
3150 upb_fielddef_setlazy(this, lazy); 2534 upb_fielddef_setlazy(this, lazy);
3151 } 2535 }
3152 inline bool FieldDef::packed() const { 2536 inline bool FieldDef::packed() const {
3153 return upb_fielddef_packed(this); 2537 return upb_fielddef_packed(this);
3154 } 2538 }
3155 inline uint32_t FieldDef::index() const {
3156 return upb_fielddef_index(this);
3157 }
3158 inline void FieldDef::set_packed(bool packed) { 2539 inline void FieldDef::set_packed(bool packed) {
3159 upb_fielddef_setpacked(this, packed); 2540 upb_fielddef_setpacked(this, packed);
3160 } 2541 }
3161 inline const MessageDef* FieldDef::containing_type() const { 2542 inline const MessageDef* FieldDef::containing_type() const {
3162 return upb_fielddef_containingtype(this); 2543 return upb_fielddef_containingtype(this);
3163 } 2544 }
3164 inline const OneofDef* FieldDef::containing_oneof() const { 2545 inline const OneofDef* FieldDef::containing_oneof() const {
3165 return upb_fielddef_containingoneof(this); 2546 return upb_fielddef_containingoneof(this);
3166 } 2547 }
3167 inline const char* FieldDef::containing_type_name() { 2548 inline const char* FieldDef::containing_type_name() {
3168 return upb_fielddef_containingtypename(this); 2549 return upb_fielddef_containingtypename(this);
3169 } 2550 }
3170 inline bool FieldDef::set_number(uint32_t number, Status* s) { 2551 inline bool FieldDef::set_number(uint32_t number, Status* s) {
3171 return upb_fielddef_setnumber(this, number, s); 2552 return upb_fielddef_setnumber(this, number, s);
3172 } 2553 }
3173 inline bool FieldDef::set_name(const char *name, Status* s) { 2554 inline bool FieldDef::set_name(const char *name, Status* s) {
3174 return upb_fielddef_setname(this, name, s); 2555 return upb_fielddef_setname(this, name, s);
3175 } 2556 }
3176 inline bool FieldDef::set_name(const std::string& name, Status* s) { 2557 inline bool FieldDef::set_name(const std::string& name, Status* s) {
3177 return upb_fielddef_setname(this, upb_safecstr(name), s); 2558 return upb_fielddef_setname(this, upb_safecstr(name), s);
3178 } 2559 }
3179 inline bool FieldDef::set_json_name(const char *name, Status* s) {
3180 return upb_fielddef_setjsonname(this, name, s);
3181 }
3182 inline bool FieldDef::set_json_name(const std::string& name, Status* s) {
3183 return upb_fielddef_setjsonname(this, upb_safecstr(name), s);
3184 }
3185 inline void FieldDef::clear_json_name() {
3186 upb_fielddef_clearjsonname(this);
3187 }
3188 inline bool FieldDef::set_containing_type_name(const char *name, Status* s) { 2560 inline bool FieldDef::set_containing_type_name(const char *name, Status* s) {
3189 return upb_fielddef_setcontainingtypename(this, name, s); 2561 return upb_fielddef_setcontainingtypename(this, name, s);
3190 } 2562 }
3191 inline bool FieldDef::set_containing_type_name(const std::string &name, 2563 inline bool FieldDef::set_containing_type_name(const std::string &name,
3192 Status *s) { 2564 Status *s) {
3193 return upb_fielddef_setcontainingtypename(this, upb_safecstr(name), s); 2565 return upb_fielddef_setcontainingtypename(this, upb_safecstr(name), s);
3194 } 2566 }
3195 inline void FieldDef::set_type(upb_fieldtype_t type) { 2567 inline void FieldDef::set_type(upb_fieldtype_t type) {
3196 upb_fielddef_settype(this, type); 2568 upb_fielddef_settype(this, type);
3197 } 2569 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
3292 return upb_fielddef_setsubdefname(this, upb_safecstr(name), s); 2664 return upb_fielddef_setsubdefname(this, upb_safecstr(name), s);
3293 } 2665 }
3294 2666
3295 inline reffed_ptr<MessageDef> MessageDef::New() { 2667 inline reffed_ptr<MessageDef> MessageDef::New() {
3296 upb_msgdef *m = upb_msgdef_new(&m); 2668 upb_msgdef *m = upb_msgdef_new(&m);
3297 return reffed_ptr<MessageDef>(m, &m); 2669 return reffed_ptr<MessageDef>(m, &m);
3298 } 2670 }
3299 inline const char *MessageDef::full_name() const { 2671 inline const char *MessageDef::full_name() const {
3300 return upb_msgdef_fullname(this); 2672 return upb_msgdef_fullname(this);
3301 } 2673 }
3302 inline const char *MessageDef::name() const {
3303 return upb_msgdef_name(this);
3304 }
3305 inline upb_syntax_t MessageDef::syntax() const {
3306 return upb_msgdef_syntax(this);
3307 }
3308 inline bool MessageDef::set_full_name(const char* fullname, Status* s) { 2674 inline bool MessageDef::set_full_name(const char* fullname, Status* s) {
3309 return upb_msgdef_setfullname(this, fullname, s); 2675 return upb_msgdef_setfullname(this, fullname, s);
3310 } 2676 }
3311 inline bool MessageDef::set_full_name(const std::string& fullname, Status* s) { 2677 inline bool MessageDef::set_full_name(const std::string& fullname, Status* s) {
3312 return upb_msgdef_setfullname(this, upb_safecstr(fullname), s); 2678 return upb_msgdef_setfullname(this, upb_safecstr(fullname), s);
3313 } 2679 }
3314 inline bool MessageDef::set_syntax(upb_syntax_t syntax) {
3315 return upb_msgdef_setsyntax(this, syntax);
3316 }
3317 inline bool MessageDef::Freeze(Status* status) { 2680 inline bool MessageDef::Freeze(Status* status) {
3318 return upb_msgdef_freeze(this, status); 2681 return upb_msgdef_freeze(this, status);
3319 } 2682 }
3320 inline int MessageDef::field_count() const { 2683 inline int MessageDef::field_count() const {
3321 return upb_msgdef_numfields(this); 2684 return upb_msgdef_numfields(this);
3322 } 2685 }
3323 inline int MessageDef::oneof_count() const { 2686 inline int MessageDef::oneof_count() const {
3324 return upb_msgdef_numoneofs(this); 2687 return upb_msgdef_numoneofs(this);
3325 } 2688 }
3326 inline bool MessageDef::AddField(upb_fielddef* f, Status* s) { 2689 inline bool MessageDef::AddField(upb_fielddef* f, Status* s) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
3488 return !(*this == other); 2851 return !(*this == other);
3489 } 2852 }
3490 2853
3491 inline reffed_ptr<EnumDef> EnumDef::New() { 2854 inline reffed_ptr<EnumDef> EnumDef::New() {
3492 upb_enumdef *e = upb_enumdef_new(&e); 2855 upb_enumdef *e = upb_enumdef_new(&e);
3493 return reffed_ptr<EnumDef>(e, &e); 2856 return reffed_ptr<EnumDef>(e, &e);
3494 } 2857 }
3495 inline const char* EnumDef::full_name() const { 2858 inline const char* EnumDef::full_name() const {
3496 return upb_enumdef_fullname(this); 2859 return upb_enumdef_fullname(this);
3497 } 2860 }
3498 inline const char* EnumDef::name() const {
3499 return upb_enumdef_name(this);
3500 }
3501 inline bool EnumDef::set_full_name(const char* fullname, Status* s) { 2861 inline bool EnumDef::set_full_name(const char* fullname, Status* s) {
3502 return upb_enumdef_setfullname(this, fullname, s); 2862 return upb_enumdef_setfullname(this, fullname, s);
3503 } 2863 }
3504 inline bool EnumDef::set_full_name(const std::string& fullname, Status* s) { 2864 inline bool EnumDef::set_full_name(const std::string& fullname, Status* s) {
3505 return upb_enumdef_setfullname(this, upb_safecstr(fullname), s); 2865 return upb_enumdef_setfullname(this, upb_safecstr(fullname), s);
3506 } 2866 }
3507 inline bool EnumDef::Freeze(Status* status) { 2867 inline bool EnumDef::Freeze(Status* status) {
3508 return upb_enumdef_freeze(this, status); 2868 return upb_enumdef_freeze(this, status);
3509 } 2869 }
3510 inline int32_t EnumDef::default_value() const { 2870 inline int32_t EnumDef::default_value() const {
(...skipping 29 matching lines...) Expand all
3540 inline const char* EnumDef::Iterator::name() { 2900 inline const char* EnumDef::Iterator::name() {
3541 return upb_enum_iter_name(&iter_); 2901 return upb_enum_iter_name(&iter_);
3542 } 2902 }
3543 inline bool EnumDef::Iterator::Done() { return upb_enum_done(&iter_); } 2903 inline bool EnumDef::Iterator::Done() { return upb_enum_done(&iter_); }
3544 inline void EnumDef::Iterator::Next() { return upb_enum_next(&iter_); } 2904 inline void EnumDef::Iterator::Next() { return upb_enum_next(&iter_); }
3545 2905
3546 inline reffed_ptr<OneofDef> OneofDef::New() { 2906 inline reffed_ptr<OneofDef> OneofDef::New() {
3547 upb_oneofdef *o = upb_oneofdef_new(&o); 2907 upb_oneofdef *o = upb_oneofdef_new(&o);
3548 return reffed_ptr<OneofDef>(o, &o); 2908 return reffed_ptr<OneofDef>(o, &o);
3549 } 2909 }
2910 inline const char* OneofDef::full_name() const {
2911 return upb_oneofdef_name(this);
2912 }
3550 2913
3551 inline const MessageDef* OneofDef::containing_type() const { 2914 inline const MessageDef* OneofDef::containing_type() const {
3552 return upb_oneofdef_containingtype(this); 2915 return upb_oneofdef_containingtype(this);
3553 } 2916 }
3554 inline const char* OneofDef::name() const { 2917 inline const char* OneofDef::name() const {
3555 return upb_oneofdef_name(this); 2918 return upb_oneofdef_name(this);
3556 } 2919 }
3557 inline bool OneofDef::set_name(const char* name, Status* s) { 2920 inline bool OneofDef::set_name(const char* name, Status* s) {
3558 return upb_oneofdef_setname(this, name, s); 2921 return upb_oneofdef_setname(this, name, s);
3559 } 2922 }
3560 inline bool OneofDef::set_name(const std::string& name, Status* s) {
3561 return upb_oneofdef_setname(this, upb_safecstr(name), s);
3562 }
3563 inline int OneofDef::field_count() const { 2923 inline int OneofDef::field_count() const {
3564 return upb_oneofdef_numfields(this); 2924 return upb_oneofdef_numfields(this);
3565 } 2925 }
3566 inline bool OneofDef::AddField(FieldDef* field, Status* s) { 2926 inline bool OneofDef::AddField(FieldDef* field, Status* s) {
3567 return upb_oneofdef_addfield(this, field, NULL, s); 2927 return upb_oneofdef_addfield(this, field, NULL, s);
3568 } 2928 }
3569 inline bool OneofDef::AddField(const reffed_ptr<FieldDef>& field, Status* s) { 2929 inline bool OneofDef::AddField(const reffed_ptr<FieldDef>& field, Status* s) {
3570 return upb_oneofdef_addfield(this, field.get(), NULL, s); 2930 return upb_oneofdef_addfield(this, field.get(), NULL, s);
3571 } 2931 }
3572 inline const FieldDef* OneofDef::FindFieldByName(const char* name, 2932 inline const FieldDef* OneofDef::FindFieldByName(const char* name,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3621 } 2981 }
3622 inline bool OneofDef::const_iterator::operator==( 2982 inline bool OneofDef::const_iterator::operator==(
3623 const const_iterator &other) const { 2983 const const_iterator &other) const {
3624 return upb_inttable_iter_isequal(&iter_, &other.iter_); 2984 return upb_inttable_iter_isequal(&iter_, &other.iter_);
3625 } 2985 }
3626 inline bool OneofDef::const_iterator::operator!=( 2986 inline bool OneofDef::const_iterator::operator!=(
3627 const const_iterator &other) const { 2987 const const_iterator &other) const {
3628 return !(*this == other); 2988 return !(*this == other);
3629 } 2989 }
3630 2990
3631 inline reffed_ptr<FileDef> FileDef::New() {
3632 upb_filedef *f = upb_filedef_new(&f);
3633 return reffed_ptr<FileDef>(f, &f);
3634 }
3635
3636 inline const char* FileDef::name() const {
3637 return upb_filedef_name(this);
3638 }
3639 inline bool FileDef::set_name(const char* name, Status* s) {
3640 return upb_filedef_setname(this, name, s);
3641 }
3642 inline bool FileDef::set_name(const std::string& name, Status* s) {
3643 return upb_filedef_setname(this, upb_safecstr(name), s);
3644 }
3645 inline const char* FileDef::package() const {
3646 return upb_filedef_package(this);
3647 }
3648 inline bool FileDef::set_package(const char* package, Status* s) {
3649 return upb_filedef_setpackage(this, package, s);
3650 }
3651 inline int FileDef::def_count() const {
3652 return upb_filedef_defcount(this);
3653 }
3654 inline const Def* FileDef::def(int index) const {
3655 return upb_filedef_def(this, index);
3656 }
3657 inline Def* FileDef::def(int index) {
3658 return const_cast<Def*>(upb_filedef_def(this, index));
3659 }
3660 inline int FileDef::dependency_count() const {
3661 return upb_filedef_depcount(this);
3662 }
3663 inline const FileDef* FileDef::dependency(int index) const {
3664 return upb_filedef_dep(this, index);
3665 }
3666 inline bool FileDef::AddDef(Def* def, Status* s) {
3667 return upb_filedef_adddef(this, def, NULL, s);
3668 }
3669 inline bool FileDef::AddMessage(MessageDef* m, Status* s) {
3670 return upb_filedef_addmsg(this, m, NULL, s);
3671 }
3672 inline bool FileDef::AddEnum(EnumDef* e, Status* s) {
3673 return upb_filedef_addenum(this, e, NULL, s);
3674 }
3675 inline bool FileDef::AddExtension(FieldDef* f, Status* s) {
3676 return upb_filedef_addext(this, f, NULL, s);
3677 }
3678 inline bool FileDef::AddDependency(const FileDef* file) {
3679 return upb_filedef_adddep(this, file);
3680 }
3681
3682 } /* namespace upb */ 2991 } /* namespace upb */
3683 #endif 2992 #endif
3684 2993
3685 #endif /* UPB_DEF_H_ */ 2994 #endif /* UPB_DEF_H_ */
3686 /* 2995 /*
3687 ** This file contains definitions of structs that should be considered private 2996 ** This file contains definitions of structs that should be considered private
3688 ** and NOT stable across versions of upb. 2997 ** and NOT stable across versions of upb.
3689 ** 2998 **
3690 ** The only reason they are declared here and not in .c files is to allow upb 2999 ** The only reason they are declared here and not in .c files is to allow upb
3691 ** and the application (if desired) to embed statically-initialized instances 3000 ** and the application (if desired) to embed statically-initialized instances
(...skipping 18 matching lines...) Expand all
3710 3019
3711 /* upb_refcounted *************************************************************/ 3020 /* upb_refcounted *************************************************************/
3712 3021
3713 3022
3714 /* upb_def ********************************************************************/ 3023 /* upb_def ********************************************************************/
3715 3024
3716 struct upb_def { 3025 struct upb_def {
3717 upb_refcounted base; 3026 upb_refcounted base;
3718 3027
3719 const char *fullname; 3028 const char *fullname;
3720 const upb_filedef* file;
3721 char type; /* A upb_deftype_t (char to save space) */ 3029 char type; /* A upb_deftype_t (char to save space) */
3722 3030
3723 /* Used as a flag during the def's mutable stage. Must be false unless 3031 /* Used as a flag during the def's mutable stage. Must be false unless
3724 * it is currently being used by a function on the stack. This allows 3032 * it is currently being used by a function on the stack. This allows
3725 * us to easily determine which defs were passed into the function's 3033 * us to easily determine which defs were passed into the function's
3726 * current invocation. */ 3034 * current invocation. */
3727 bool came_from_user; 3035 bool came_from_user;
3728 }; 3036 };
3729 3037
3730 #define UPB_DEF_INIT(name, type, vtbl, refs, ref2s) \ 3038 #define UPB_DEF_INIT(name, type, refs, ref2s) \
3731 { UPB_REFCOUNT_INIT(vtbl, refs, ref2s), name, NULL, type, false } 3039 { UPB_REFCOUNT_INIT(refs, ref2s), name, type, false }
3732 3040
3733 3041
3734 /* upb_fielddef ***************************************************************/ 3042 /* upb_fielddef ***************************************************************/
3735 3043
3736 struct upb_fielddef { 3044 struct upb_fielddef {
3737 upb_def base; 3045 upb_def base;
3738 3046
3739 union { 3047 union {
3740 int64_t sint; 3048 int64_t sint;
3741 uint64_t uint; 3049 uint64_t uint;
(...skipping 19 matching lines...) Expand all
3761 bool packed_; 3069 bool packed_;
3762 upb_intfmt_t intfmt; 3070 upb_intfmt_t intfmt;
3763 bool tagdelim; 3071 bool tagdelim;
3764 upb_fieldtype_t type_; 3072 upb_fieldtype_t type_;
3765 upb_label_t label_; 3073 upb_label_t label_;
3766 uint32_t number_; 3074 uint32_t number_;
3767 uint32_t selector_base; /* Used to index into a upb::Handlers table. */ 3075 uint32_t selector_base; /* Used to index into a upb::Handlers table. */
3768 uint32_t index_; 3076 uint32_t index_;
3769 }; 3077 };
3770 3078
3771 extern const struct upb_refcounted_vtbl upb_fielddef_vtbl;
3772
3773 #define UPB_FIELDDEF_INIT(label, type, intfmt, tagdelim, is_extension, lazy, \ 3079 #define UPB_FIELDDEF_INIT(label, type, intfmt, tagdelim, is_extension, lazy, \
3774 packed, name, num, msgdef, subdef, selector_base, \ 3080 packed, name, num, msgdef, subdef, selector_base, \
3775 index, defaultval, refs, ref2s) \ 3081 index, defaultval, refs, ref2s) \
3776 { \ 3082 { \
3777 UPB_DEF_INIT(name, UPB_DEF_FIELD, &upb_fielddef_vtbl, refs, ref2s), \ 3083 UPB_DEF_INIT(name, UPB_DEF_FIELD, refs, ref2s), defaultval, {msgdef}, \
3778 defaultval, {msgdef}, {subdef}, NULL, false, false, \ 3084 {subdef}, NULL, false, false, \
3779 type == UPB_TYPE_STRING || type == UPB_TYPE_BYTES, true, is_extension, \ 3085 type == UPB_TYPE_STRING || type == UPB_TYPE_BYTES, true, is_extension, \
3780 lazy, packed, intfmt, tagdelim, type, label, num, selector_base, index \ 3086 lazy, packed, intfmt, tagdelim, type, label, num, selector_base, index \
3781 } 3087 }
3782 3088
3783 3089
3784 /* upb_msgdef *****************************************************************/ 3090 /* upb_msgdef *****************************************************************/
3785 3091
3786 struct upb_msgdef { 3092 struct upb_msgdef {
3787 upb_def base; 3093 upb_def base;
3788 3094
3789 size_t selector_count; 3095 size_t selector_count;
3790 uint32_t submsg_field_count; 3096 uint32_t submsg_field_count;
3791 3097
3792 /* Tables for looking up fields by number and name. */ 3098 /* Tables for looking up fields by number and name. */
3793 upb_inttable itof; /* int to field */ 3099 upb_inttable itof; /* int to field */
3794 upb_strtable ntof; /* name to field/oneof */ 3100 upb_strtable ntof; /* name to field */
3795 3101
3796 /* Is this a map-entry message? */ 3102 /* Tables for looking up oneofs by name. */
3103 upb_strtable ntoo; /* name to oneof */
3104
3105 /* Is this a map-entry message?
3106 * TODO: set this flag properly for static descriptors; regenerate
3107 * descriptor.upb.c. */
3797 bool map_entry; 3108 bool map_entry;
3798 3109
3799 /* Whether this message has proto2 or proto3 semantics. */
3800 upb_syntax_t syntax;
3801
3802 /* TODO(haberman): proper extension ranges (there can be multiple). */ 3110 /* TODO(haberman): proper extension ranges (there can be multiple). */
3803 }; 3111 };
3804 3112
3805 extern const struct upb_refcounted_vtbl upb_msgdef_vtbl;
3806
3807 /* TODO: also support static initialization of the oneofs table. This will be 3113 /* TODO: also support static initialization of the oneofs table. This will be
3808 * needed if we compile in descriptors that contain oneofs. */ 3114 * needed if we compile in descriptors that contain oneofs. */
3809 #define UPB_MSGDEF_INIT(name, selector_count, submsg_field_count, itof, ntof, \ 3115 #define UPB_MSGDEF_INIT(name, selector_count, submsg_field_count, itof, ntof, \
3810 map_entry, syntax, refs, ref2s) \ 3116 refs, ref2s) \
3811 { \ 3117 { \
3812 UPB_DEF_INIT(name, UPB_DEF_MSG, &upb_fielddef_vtbl, refs, ref2s), \ 3118 UPB_DEF_INIT(name, UPB_DEF_MSG, refs, ref2s), selector_count, \
3813 selector_count, submsg_field_count, itof, ntof, map_entry, syntax \ 3119 submsg_field_count, itof, ntof, \
3120 UPB_EMPTY_STRTABLE_INIT(UPB_CTYPE_PTR), false \
3814 } 3121 }
3815 3122
3816 3123
3817 /* upb_enumdef ****************************************************************/ 3124 /* upb_enumdef ****************************************************************/
3818 3125
3819 struct upb_enumdef { 3126 struct upb_enumdef {
3820 upb_def base; 3127 upb_def base;
3821 3128
3822 upb_strtable ntoi; 3129 upb_strtable ntoi;
3823 upb_inttable iton; 3130 upb_inttable iton;
3824 int32_t defaultval; 3131 int32_t defaultval;
3825 }; 3132 };
3826 3133
3827 extern const struct upb_refcounted_vtbl upb_enumdef_vtbl;
3828
3829 #define UPB_ENUMDEF_INIT(name, ntoi, iton, defaultval, refs, ref2s) \ 3134 #define UPB_ENUMDEF_INIT(name, ntoi, iton, defaultval, refs, ref2s) \
3830 { UPB_DEF_INIT(name, UPB_DEF_ENUM, &upb_enumdef_vtbl, refs, ref2s), ntoi, \ 3135 { UPB_DEF_INIT(name, UPB_DEF_ENUM, refs, ref2s), ntoi, iton, defaultval }
3831 iton, defaultval }
3832 3136
3833 3137
3834 /* upb_oneofdef ***************************************************************/ 3138 /* upb_oneofdef ***************************************************************/
3835 3139
3836 struct upb_oneofdef { 3140 struct upb_oneofdef {
3837 upb_refcounted base; 3141 upb_def base;
3838 3142
3839 const char *name;
3840 upb_strtable ntof; 3143 upb_strtable ntof;
3841 upb_inttable itof; 3144 upb_inttable itof;
3842 const upb_msgdef *parent; 3145 const upb_msgdef *parent;
3843 }; 3146 };
3844 3147
3845 extern const struct upb_refcounted_vtbl upb_oneofdef_vtbl;
3846
3847 #define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \ 3148 #define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \
3848 { UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), name, ntof, itof } 3149 { UPB_DEF_INIT(name, UPB_DEF_ENUM, refs, ref2s), ntof, itof }
3849 3150
3850 3151
3851 /* upb_symtab *****************************************************************/ 3152 /* upb_symtab *****************************************************************/
3852 3153
3853 struct upb_symtab { 3154 struct upb_symtab {
3854 upb_refcounted base; 3155 upb_refcounted base;
3855 3156
3856 upb_strtable symtab; 3157 upb_strtable symtab;
3857 }; 3158 };
3858 3159
3859 struct upb_filedef { 3160 #define UPB_SYMTAB_INIT(symtab, refs, ref2s) \
3860 upb_refcounted base; 3161 { UPB_REFCOUNT_INIT(refs, ref2s), symtab }
3861 3162
3862 const char *name;
3863 const char *package;
3864 upb_syntax_t syntax;
3865
3866 upb_inttable defs;
3867 upb_inttable deps;
3868 };
3869
3870 extern const struct upb_refcounted_vtbl upb_filedef_vtbl;
3871 3163
3872 #endif /* UPB_STATICINIT_H_ */ 3164 #endif /* UPB_STATICINIT_H_ */
3873 /* 3165 /*
3874 ** upb::Handlers (upb_handlers) 3166 ** upb::Handlers (upb_handlers)
3875 ** 3167 **
3876 ** A upb_handlers is like a virtual table for a upb_msgdef. Each field of the 3168 ** A upb_handlers is like a virtual table for a upb_msgdef. Each field of the
3877 ** message can have associated functions that will be called when we are 3169 ** message can have associated functions that will be called when we are
3878 ** parsing or visiting a stream of data. This is similar to how handlers work 3170 ** parsing or visiting a stream of data. This is similar to how handlers work
3879 ** in SAX (the Simple API for XML). 3171 ** in SAX (the Simple API for XML).
3880 ** 3172 **
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
4474 typedef T FuncPtr; 3766 typedef T FuncPtr;
4475 3767
4476 /* Intentionally implicit. */ 3768 /* Intentionally implicit. */
4477 template <class F> Handler(F func); 3769 template <class F> Handler(F func);
4478 ~Handler(); 3770 ~Handler();
4479 3771
4480 private: 3772 private:
4481 void AddCleanup(Handlers* h) const { 3773 void AddCleanup(Handlers* h) const {
4482 if (cleanup_func_) { 3774 if (cleanup_func_) {
4483 bool ok = h->AddCleanup(cleanup_data_, cleanup_func_); 3775 bool ok = h->AddCleanup(cleanup_data_, cleanup_func_);
4484 UPB_ASSERT(ok); 3776 UPB_ASSERT_VAR(ok, ok);
4485 } 3777 }
4486 } 3778 }
4487 3779
4488 UPB_DISALLOW_COPY_AND_ASSIGN(Handler) 3780 UPB_DISALLOW_COPY_AND_ASSIGN(Handler)
4489 friend class Handlers; 3781 friend class Handlers;
4490 FuncPtr handler_; 3782 FuncPtr handler_;
4491 mutable HandlerAttributes attr_; 3783 mutable HandlerAttributes attr_;
4492 mutable bool registered_; 3784 mutable bool registered_;
4493 void *cleanup_data_; 3785 void *cleanup_data_;
4494 upb_handlerfree *cleanup_func_; 3786 upb_handlerfree *cleanup_func_;
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
5494 /* utype/ltype are upper/lower-case, ctype is canonical C type, vtype is 4786 /* utype/ltype are upper/lower-case, ctype is canonical C type, vtype is
5495 * variant C type. */ 4787 * variant C type. */
5496 #define TYPE_METHODS(utype, ltype, ctype, vtype) \ 4788 #define TYPE_METHODS(utype, ltype, ctype, vtype) \
5497 template <> struct CanonicalType<vtype> { \ 4789 template <> struct CanonicalType<vtype> { \
5498 typedef ctype Type; \ 4790 typedef ctype Type; \
5499 }; \ 4791 }; \
5500 template <> \ 4792 template <> \
5501 inline bool Handlers::SetValueHandler<vtype>( \ 4793 inline bool Handlers::SetValueHandler<vtype>( \
5502 const FieldDef *f, \ 4794 const FieldDef *f, \
5503 const Handlers::utype ## Handler& handler) { \ 4795 const Handlers::utype ## Handler& handler) { \
5504 UPB_ASSERT(!handler.registered_); \ 4796 assert(!handler.registered_); \
5505 handler.AddCleanup(this); \ 4797 handler.AddCleanup(this); \
5506 handler.registered_ = true; \ 4798 handler.registered_ = true; \
5507 return upb_handlers_set##ltype(this, f, handler.handler_, &handler.attr_); \ 4799 return upb_handlers_set##ltype(this, f, handler.handler_, &handler.attr_); \
5508 } \ 4800 } \
5509 4801
5510 TYPE_METHODS(Double, double, double, double) 4802 TYPE_METHODS(Double, double, double, double)
5511 TYPE_METHODS(Float, float, float, float) 4803 TYPE_METHODS(Float, float, float, float)
5512 TYPE_METHODS(UInt64, uint64, uint64_t, UPB_UINT64_T) 4804 TYPE_METHODS(UInt64, uint64, uint64_t, UPB_UINT64_T)
5513 TYPE_METHODS(UInt32, uint32, uint32_t, UPB_UINT32_T) 4805 TYPE_METHODS(UInt32, uint32, uint32_t, UPB_UINT32_T)
5514 TYPE_METHODS(Int64, int64, int64_t, UPB_INT64_T) 4806 TYPE_METHODS(Int64, int64, int64_t, UPB_INT64_T)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
5606 * This is all nonsense for non START* handlers, but it doesn't matter because 4898 * This is all nonsense for non START* handlers, but it doesn't matter because
5607 * in that case the value will be ignored. */ 4899 * in that case the value will be ignored. */
5608 typedef typename FirstUnlessVoidOrBool<typename F::FuncInfo::Return, 4900 typedef typename FirstUnlessVoidOrBool<typename F::FuncInfo::Return,
5609 typename F::FuncInfo::Closure>::value 4901 typename F::FuncInfo::Closure>::value
5610 EffectiveReturn; 4902 EffectiveReturn;
5611 attr_.SetReturnClosureType(UniquePtrForType<EffectiveReturn>()); 4903 attr_.SetReturnClosureType(UniquePtrForType<EffectiveReturn>());
5612 } 4904 }
5613 4905
5614 template <class T> 4906 template <class T>
5615 inline Handler<T>::~Handler() { 4907 inline Handler<T>::~Handler() {
5616 UPB_ASSERT(registered_); 4908 assert(registered_);
5617 } 4909 }
5618 4910
5619 inline HandlerAttributes::HandlerAttributes() { upb_handlerattr_init(this); } 4911 inline HandlerAttributes::HandlerAttributes() { upb_handlerattr_init(this); }
5620 inline HandlerAttributes::~HandlerAttributes() { upb_handlerattr_uninit(this); } 4912 inline HandlerAttributes::~HandlerAttributes() { upb_handlerattr_uninit(this); }
5621 inline bool HandlerAttributes::SetHandlerData(const void *hd) { 4913 inline bool HandlerAttributes::SetHandlerData(const void *hd) {
5622 return upb_handlerattr_sethandlerdata(this, hd); 4914 return upb_handlerattr_sethandlerdata(this, hd);
5623 } 4915 }
5624 inline const void* HandlerAttributes::handler_data() const { 4916 inline const void* HandlerAttributes::handler_data() const {
5625 return upb_handlerattr_handlerdata(this); 4917 return upb_handlerattr_handlerdata(this);
5626 } 4918 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
5692 return upb_handlers_freeze((Handlers* const*)&h[0], h.size(), status); 4984 return upb_handlers_freeze((Handlers* const*)&h[0], h.size(), status);
5693 } 4985 }
5694 inline const MessageDef *Handlers::message_def() const { 4986 inline const MessageDef *Handlers::message_def() const {
5695 return upb_handlers_msgdef(this); 4987 return upb_handlers_msgdef(this);
5696 } 4988 }
5697 inline bool Handlers::AddCleanup(void *p, upb_handlerfree *func) { 4989 inline bool Handlers::AddCleanup(void *p, upb_handlerfree *func) {
5698 return upb_handlers_addcleanup(this, p, func); 4990 return upb_handlers_addcleanup(this, p, func);
5699 } 4991 }
5700 inline bool Handlers::SetStartMessageHandler( 4992 inline bool Handlers::SetStartMessageHandler(
5701 const Handlers::StartMessageHandler &handler) { 4993 const Handlers::StartMessageHandler &handler) {
5702 UPB_ASSERT(!handler.registered_); 4994 assert(!handler.registered_);
5703 handler.registered_ = true; 4995 handler.registered_ = true;
5704 handler.AddCleanup(this); 4996 handler.AddCleanup(this);
5705 return upb_handlers_setstartmsg(this, handler.handler_, &handler.attr_); 4997 return upb_handlers_setstartmsg(this, handler.handler_, &handler.attr_);
5706 } 4998 }
5707 inline bool Handlers::SetEndMessageHandler( 4999 inline bool Handlers::SetEndMessageHandler(
5708 const Handlers::EndMessageHandler &handler) { 5000 const Handlers::EndMessageHandler &handler) {
5709 UPB_ASSERT(!handler.registered_); 5001 assert(!handler.registered_);
5710 handler.registered_ = true; 5002 handler.registered_ = true;
5711 handler.AddCleanup(this); 5003 handler.AddCleanup(this);
5712 return upb_handlers_setendmsg(this, handler.handler_, &handler.attr_); 5004 return upb_handlers_setendmsg(this, handler.handler_, &handler.attr_);
5713 } 5005 }
5714 inline bool Handlers::SetStartStringHandler(const FieldDef *f, 5006 inline bool Handlers::SetStartStringHandler(const FieldDef *f,
5715 const StartStringHandler &handler) { 5007 const StartStringHandler &handler) {
5716 UPB_ASSERT(!handler.registered_); 5008 assert(!handler.registered_);
5717 handler.registered_ = true; 5009 handler.registered_ = true;
5718 handler.AddCleanup(this); 5010 handler.AddCleanup(this);
5719 return upb_handlers_setstartstr(this, f, handler.handler_, &handler.attr_); 5011 return upb_handlers_setstartstr(this, f, handler.handler_, &handler.attr_);
5720 } 5012 }
5721 inline bool Handlers::SetEndStringHandler(const FieldDef *f, 5013 inline bool Handlers::SetEndStringHandler(const FieldDef *f,
5722 const EndFieldHandler &handler) { 5014 const EndFieldHandler &handler) {
5723 UPB_ASSERT(!handler.registered_); 5015 assert(!handler.registered_);
5724 handler.registered_ = true; 5016 handler.registered_ = true;
5725 handler.AddCleanup(this); 5017 handler.AddCleanup(this);
5726 return upb_handlers_setendstr(this, f, handler.handler_, &handler.attr_); 5018 return upb_handlers_setendstr(this, f, handler.handler_, &handler.attr_);
5727 } 5019 }
5728 inline bool Handlers::SetStringHandler(const FieldDef *f, 5020 inline bool Handlers::SetStringHandler(const FieldDef *f,
5729 const StringHandler& handler) { 5021 const StringHandler& handler) {
5730 UPB_ASSERT(!handler.registered_); 5022 assert(!handler.registered_);
5731 handler.registered_ = true; 5023 handler.registered_ = true;
5732 handler.AddCleanup(this); 5024 handler.AddCleanup(this);
5733 return upb_handlers_setstring(this, f, handler.handler_, &handler.attr_); 5025 return upb_handlers_setstring(this, f, handler.handler_, &handler.attr_);
5734 } 5026 }
5735 inline bool Handlers::SetStartSequenceHandler( 5027 inline bool Handlers::SetStartSequenceHandler(
5736 const FieldDef *f, const StartFieldHandler &handler) { 5028 const FieldDef *f, const StartFieldHandler &handler) {
5737 UPB_ASSERT(!handler.registered_); 5029 assert(!handler.registered_);
5738 handler.registered_ = true; 5030 handler.registered_ = true;
5739 handler.AddCleanup(this); 5031 handler.AddCleanup(this);
5740 return upb_handlers_setstartseq(this, f, handler.handler_, &handler.attr_); 5032 return upb_handlers_setstartseq(this, f, handler.handler_, &handler.attr_);
5741 } 5033 }
5742 inline bool Handlers::SetStartSubMessageHandler( 5034 inline bool Handlers::SetStartSubMessageHandler(
5743 const FieldDef *f, const StartFieldHandler &handler) { 5035 const FieldDef *f, const StartFieldHandler &handler) {
5744 UPB_ASSERT(!handler.registered_); 5036 assert(!handler.registered_);
5745 handler.registered_ = true; 5037 handler.registered_ = true;
5746 handler.AddCleanup(this); 5038 handler.AddCleanup(this);
5747 return upb_handlers_setstartsubmsg(this, f, handler.handler_, &handler.attr_); 5039 return upb_handlers_setstartsubmsg(this, f, handler.handler_, &handler.attr_);
5748 } 5040 }
5749 inline bool Handlers::SetEndSubMessageHandler(const FieldDef *f, 5041 inline bool Handlers::SetEndSubMessageHandler(const FieldDef *f,
5750 const EndFieldHandler &handler) { 5042 const EndFieldHandler &handler) {
5751 UPB_ASSERT(!handler.registered_); 5043 assert(!handler.registered_);
5752 handler.registered_ = true; 5044 handler.registered_ = true;
5753 handler.AddCleanup(this); 5045 handler.AddCleanup(this);
5754 return upb_handlers_setendsubmsg(this, f, handler.handler_, &handler.attr_); 5046 return upb_handlers_setendsubmsg(this, f, handler.handler_, &handler.attr_);
5755 } 5047 }
5756 inline bool Handlers::SetEndSequenceHandler(const FieldDef *f, 5048 inline bool Handlers::SetEndSequenceHandler(const FieldDef *f,
5757 const EndFieldHandler &handler) { 5049 const EndFieldHandler &handler) {
5758 UPB_ASSERT(!handler.registered_); 5050 assert(!handler.registered_);
5759 handler.registered_ = true; 5051 handler.registered_ = true;
5760 handler.AddCleanup(this); 5052 handler.AddCleanup(this);
5761 return upb_handlers_setendseq(this, f, handler.handler_, &handler.attr_); 5053 return upb_handlers_setendseq(this, f, handler.handler_, &handler.attr_);
5762 } 5054 }
5763 inline bool Handlers::SetSubHandlers(const FieldDef *f, const Handlers *sub) { 5055 inline bool Handlers::SetSubHandlers(const FieldDef *f, const Handlers *sub) {
5764 return upb_handlers_setsubhandlers(this, f, sub); 5056 return upb_handlers_setsubhandlers(this, f, sub);
5765 } 5057 }
5766 inline const Handlers *Handlers::GetSubHandlers(const FieldDef *f) const { 5058 inline const Handlers *Handlers::GetSubHandlers(const FieldDef *f) const {
5767 return upb_handlers_getsubhandlers(this, f); 5059 return upb_handlers_getsubhandlers(this, f);
5768 } 5060 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
5803 #undef UPB_UINT32ALT_T 5095 #undef UPB_UINT32ALT_T
5804 #undef UPB_INT64_T 5096 #undef UPB_INT64_T
5805 #undef UPB_UINT64_T 5097 #undef UPB_UINT64_T
5806 #undef UPB_INT64ALT_T 5098 #undef UPB_INT64ALT_T
5807 #undef UPB_UINT64ALT_T 5099 #undef UPB_UINT64ALT_T
5808 5100
5809 #endif /* UPB_HANDLERS_INL_H_ */ 5101 #endif /* UPB_HANDLERS_INL_H_ */
5810 5102
5811 #endif /* UPB_HANDLERS_H */ 5103 #endif /* UPB_HANDLERS_H */
5812 /* 5104 /*
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 /*
5813 ** upb::Sink (upb_sink) 5366 ** upb::Sink (upb_sink)
5814 ** upb::BytesSink (upb_bytessink) 5367 ** upb::BytesSink (upb_bytessink)
5815 ** 5368 **
5816 ** A upb_sink is an object that binds a upb_handlers object to some runtime 5369 ** A upb_sink is an object that binds a upb_handlers object to some runtime
5817 ** state. It is the object that can actually receive data via the upb_handlers 5370 ** state. It is the object that can actually receive data via the upb_handlers
5818 ** interface. 5371 ** interface.
5819 ** 5372 **
5820 ** Unlike upb_def and upb_handlers, upb_sink is never frozen, immutable, or 5373 ** Unlike upb_def and upb_handlers, upb_sink is never frozen, immutable, or
5821 ** thread-safe. You can create as many of them as you want, but each one may 5374 ** thread-safe. You can create as many of them as you want, but each one may
5822 ** only be used in a single thread at a time. 5375 ** only be used in a single thread at a time.
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
6506 * leave the defs themselves partially resolved. Does this matter? If so we 6059 * leave the defs themselves partially resolved. Does this matter? If so we
6507 * could do a prepass that ensures that all symbols are resolvable and bail 6060 * could do a prepass that ensures that all symbols are resolvable and bail
6508 * if not, so we don't mutate anything until we know the operation will 6061 * if not, so we don't mutate anything until we know the operation will
6509 * succeed. 6062 * succeed.
6510 * 6063 *
6511 * TODO(haberman): since the defs must be mutable, refining a frozen def 6064 * TODO(haberman): since the defs must be mutable, refining a frozen def
6512 * requires making mutable copies of the entire tree. This is wasteful if 6065 * requires making mutable copies of the entire tree. This is wasteful if
6513 * only a few messages are changing. We may want to add a way of adding a 6066 * only a few messages are changing. We may want to add a way of adding a
6514 * tree of frozen defs to the symtab (perhaps an alternate constructor where 6067 * tree of frozen defs to the symtab (perhaps an alternate constructor where
6515 * you pass the root of the tree?) */ 6068 * you pass the root of the tree?) */
6516 bool Add(Def*const* defs, size_t n, void* ref_donor, Status* status); 6069 bool Add(Def*const* defs, int n, void* ref_donor, upb_status* status);
6517 6070
6518 bool Add(const std::vector<Def*>& defs, void *owner, Status* status) { 6071 bool Add(const std::vector<Def*>& defs, void *owner, Status* status) {
6519 return Add((Def*const*)&defs[0], defs.size(), owner, status); 6072 return Add((Def*const*)&defs[0], defs.size(), owner, status);
6520 } 6073 }
6521 6074
6522 /* Resolves all subdefs for messages in this file and attempts to freeze the
6523 * file. If this succeeds, adds all the symbols to this SymbolTable
6524 * (replacing any existing ones with the same names). */
6525 bool AddFile(FileDef* file, Status* s);
6526
6527 private: 6075 private:
6528 UPB_DISALLOW_POD_OPS(SymbolTable, upb::SymbolTable) 6076 UPB_DISALLOW_POD_OPS(SymbolTable, upb::SymbolTable)
6529 }; 6077 };
6530 6078
6531 #endif /* __cplusplus */ 6079 #endif /* __cplusplus */
6532 6080
6533 UPB_BEGIN_EXTERN_C 6081 UPB_BEGIN_EXTERN_C
6534 6082
6535 /* Native C API. */ 6083 /* Native C API. */
6536 6084
6537 /* Include refcounted methods like upb_symtab_ref(). */ 6085 /* Include refcounted methods like upb_symtab_ref(). */
6538 UPB_REFCOUNTED_CMETHODS(upb_symtab, upb_symtab_upcast) 6086 UPB_REFCOUNTED_CMETHODS(upb_symtab, upb_symtab_upcast)
6539 6087
6540 upb_symtab *upb_symtab_new(const void *owner); 6088 upb_symtab *upb_symtab_new(const void *owner);
6541 void upb_symtab_freeze(upb_symtab *s); 6089 void upb_symtab_freeze(upb_symtab *s);
6542 const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base, 6090 const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
6543 const char *sym); 6091 const char *sym);
6544 const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym); 6092 const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym);
6545 const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym); 6093 const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
6546 const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym); 6094 const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
6547 bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, 6095 bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, int n, void *ref_donor,
6548 void *ref_donor, upb_status *status); 6096 upb_status *status);
6549 bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status* status);
6550 6097
6551 /* upb_symtab_iter i; 6098 /* upb_symtab_iter i;
6552 * for(upb_symtab_begin(&i, s, type); !upb_symtab_done(&i); 6099 * for(upb_symtab_begin(&i, s, type); !upb_symtab_done(&i);
6553 * upb_symtab_next(&i)) { 6100 * upb_symtab_next(&i)) {
6554 * const upb_def *def = upb_symtab_iter_def(&i); 6101 * const upb_def *def = upb_symtab_iter_def(&i);
6555 * // ... 6102 * // ...
6556 * } 6103 * }
6557 * 6104 *
6558 * For C we don't have separate iterators for const and non-const. 6105 * For C we don't have separate iterators for const and non-const.
6559 * It is the caller's responsibility to cast the upb_fielddef* to 6106 * It is the caller's responsibility to cast the upb_fielddef* to
(...skipping 21 matching lines...) Expand all
6581 const char *sym) const { 6128 const char *sym) const {
6582 return upb_symtab_resolve(this, base, sym); 6129 return upb_symtab_resolve(this, base, sym);
6583 } 6130 }
6584 inline const Def* SymbolTable::Lookup(const char *sym) const { 6131 inline const Def* SymbolTable::Lookup(const char *sym) const {
6585 return upb_symtab_lookup(this, sym); 6132 return upb_symtab_lookup(this, sym);
6586 } 6133 }
6587 inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const { 6134 inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const {
6588 return upb_symtab_lookupmsg(this, sym); 6135 return upb_symtab_lookupmsg(this, sym);
6589 } 6136 }
6590 inline bool SymbolTable::Add( 6137 inline bool SymbolTable::Add(
6591 Def*const* defs, size_t n, void* ref_donor, Status* status) { 6138 Def*const* defs, int n, void* ref_donor, upb_status* status) {
6592 return upb_symtab_add(this, (upb_def*const*)defs, n, ref_donor, status); 6139 return upb_symtab_add(this, (upb_def*const*)defs, n, ref_donor, status);
6593 } 6140 }
6594 inline bool SymbolTable::AddFile(FileDef* file, Status* s) {
6595 return upb_symtab_addfile(this, file, s);
6596 }
6597 } /* namespace upb */ 6141 } /* namespace upb */
6598 #endif 6142 #endif
6599 6143
6600 #endif /* UPB_SYMTAB_H_ */ 6144 #endif /* UPB_SYMTAB_H_ */
6601 /* 6145 /*
6602 ** upb::descriptor::Reader (upb_descreader) 6146 ** upb::descriptor::Reader (upb_descreader)
6603 ** 6147 **
6604 ** Provides a way of building upb::Defs from data in descriptor.proto format. 6148 ** Provides a way of building upb::Defs from data in descriptor.proto format.
6605 */ 6149 */
6606 6150
(...skipping 23 matching lines...) Expand all
6630 * TODO: generate the handlers statically (like we do with the 6174 * TODO: generate the handlers statically (like we do with the
6631 * descriptor.proto defs) so that there is no need to pass this parameter (or 6175 * descriptor.proto defs) so that there is no need to pass this parameter (or
6632 * to build/memory-manage the handlers at runtime at all). Unfortunately this 6176 * to build/memory-manage the handlers at runtime at all). Unfortunately this
6633 * is a bit tricky to implement for Handlers, but necessary to simplify this 6177 * is a bit tricky to implement for Handlers, but necessary to simplify this
6634 * interface. */ 6178 * interface. */
6635 static Reader* Create(Environment* env, const Handlers* handlers); 6179 static Reader* Create(Environment* env, const Handlers* handlers);
6636 6180
6637 /* The reader's input; this is where descriptor.proto data should be sent. */ 6181 /* The reader's input; this is where descriptor.proto data should be sent. */
6638 Sink* input(); 6182 Sink* input();
6639 6183
6640 /* Use to get the FileDefs that have been parsed. */ 6184 /* Returns an array of all defs that have been parsed, and transfers ownership
6641 size_t file_count() const; 6185 * of them to "owner". The number of defs is stored in *n. Ownership of the
6642 FileDef* file(size_t i) const; 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);
6643 6192
6644 /* Builds and returns handlers for the reader, owned by "owner." */ 6193 /* Builds and returns handlers for the reader, owned by "owner." */
6645 static Handlers* NewHandlers(const void* owner); 6194 static Handlers* NewHandlers(const void* owner);
6646 6195
6647 private: 6196 private:
6648 UPB_DISALLOW_POD_OPS(Reader, upb::descriptor::Reader) 6197 UPB_DISALLOW_POD_OPS(Reader, upb::descriptor::Reader)
6649 }; 6198 };
6650 6199
6651 #endif 6200 #endif
6652 6201
6653 UPB_BEGIN_EXTERN_C 6202 UPB_BEGIN_EXTERN_C
6654 6203
6655 /* C API. */ 6204 /* C API. */
6656 upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h); 6205 upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h);
6657 upb_sink *upb_descreader_input(upb_descreader *r); 6206 upb_sink *upb_descreader_input(upb_descreader *r);
6658 size_t upb_descreader_filecount(const upb_descreader *r); 6207 upb_def **upb_descreader_getdefs(upb_descreader *r, void *owner, int *n);
6659 upb_filedef *upb_descreader_file(const upb_descreader *r, size_t i);
6660 const upb_handlers *upb_descreader_newhandlers(const void *owner); 6208 const upb_handlers *upb_descreader_newhandlers(const void *owner);
6661 6209
6662 UPB_END_EXTERN_C 6210 UPB_END_EXTERN_C
6663 6211
6664 #ifdef __cplusplus 6212 #ifdef __cplusplus
6665 /* C++ implementation details. ************************************************/ 6213 /* C++ implementation details. ************************************************/
6666 namespace upb { 6214 namespace upb {
6667 namespace descriptor { 6215 namespace descriptor {
6668 inline Reader* Reader::Create(Environment* e, const Handlers *h) { 6216 inline Reader* Reader::Create(Environment* e, const Handlers *h) {
6669 return upb_descreader_create(e, h); 6217 return upb_descreader_create(e, h);
6670 } 6218 }
6671 inline Sink* Reader::input() { return upb_descreader_input(this); } 6219 inline Sink* Reader::input() { return upb_descreader_input(this); }
6672 inline size_t Reader::file_count() const { 6220 inline upb::Def** Reader::GetDefs(void* owner, int* n) {
6673 return upb_descreader_filecount(this); 6221 return upb_descreader_getdefs(this, owner, n);
6674 }
6675 inline FileDef* Reader::file(size_t i) const {
6676 return upb_descreader_file(this, i);
6677 } 6222 }
6678 } /* namespace descriptor */ 6223 } /* namespace descriptor */
6679 } /* namespace upb */ 6224 } /* namespace upb */
6680 #endif 6225 #endif
6681 6226
6682 #endif /* UPB_DESCRIPTOR_H */ 6227 #endif /* UPB_DESCRIPTOR_H */
6683 /* This file contains accessors for a set of compiled-in defs. 6228 /* This file contains accessors for a set of compiled-in defs.
6684 * Note that unlike Google's protobuf, it does *not* define 6229 * Note that unlike Google's protobuf, it does *not* define
6685 * generated classes or any other kind of data structure for 6230 * generated classes or any other kind of data structure for
6686 * actually storing protobufs. It only contains *defs* which 6231 * actually storing protobufs. It only contains *defs* which
6687 * let you reflect over a protobuf *schema*. 6232 * let you reflect over a protobuf *schema*.
6688 */ 6233 */
6689 /* This file was generated by upbc (the upb compiler) from the input 6234 /* This file was generated by upbc (the upb compiler).
6690 * file:
6691 *
6692 * upb/descriptor/descriptor.proto
6693 *
6694 * Do not edit -- your changes will be discarded when the file is 6235 * Do not edit -- your changes will be discarded when the file is
6695 * regenerated. */ 6236 * regenerated. */
6696 6237
6697 #ifndef UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_ 6238 #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_UPB_H_
6698 #define UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_ 6239 #define GOOGLE_PROTOBUF_DESCRIPTOR_UPB_H_
6699 6240
6700 6241
6242 #ifdef __cplusplus
6701 UPB_BEGIN_EXTERN_C 6243 UPB_BEGIN_EXTERN_C
6244 #endif
6702 6245
6703 /* Enums */ 6246 /* Enums */
6704 6247
6705 typedef enum { 6248 typedef enum {
6706 google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1, 6249 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_OPTIONAL = 1,
6707 google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2, 6250 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_REQUIRED = 2,
6708 google_protobuf_FieldDescriptorProto_LABEL_REPEATED = 3 6251 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_REPEATED = 3
6709 } google_protobuf_FieldDescriptorProto_Label; 6252 } google_protobuf_FieldDescriptorProto_Label;
6710 6253
6711 typedef enum { 6254 typedef enum {
6712 google_protobuf_FieldDescriptorProto_TYPE_DOUBLE = 1, 6255 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_DOUBLE = 1,
6713 google_protobuf_FieldDescriptorProto_TYPE_FLOAT = 2, 6256 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_FLOAT = 2,
6714 google_protobuf_FieldDescriptorProto_TYPE_INT64 = 3, 6257 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT64 = 3,
6715 google_protobuf_FieldDescriptorProto_TYPE_UINT64 = 4, 6258 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_UINT64 = 4,
6716 google_protobuf_FieldDescriptorProto_TYPE_INT32 = 5, 6259 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT32 = 5,
6717 google_protobuf_FieldDescriptorProto_TYPE_FIXED64 = 6, 6260 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_FIXED64 = 6,
6718 google_protobuf_FieldDescriptorProto_TYPE_FIXED32 = 7, 6261 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_FIXED32 = 7,
6719 google_protobuf_FieldDescriptorProto_TYPE_BOOL = 8, 6262 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_BOOL = 8,
6720 google_protobuf_FieldDescriptorProto_TYPE_STRING = 9, 6263 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_STRING = 9,
6721 google_protobuf_FieldDescriptorProto_TYPE_GROUP = 10, 6264 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_GROUP = 10,
6722 google_protobuf_FieldDescriptorProto_TYPE_MESSAGE = 11, 6265 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_MESSAGE = 11,
6723 google_protobuf_FieldDescriptorProto_TYPE_BYTES = 12, 6266 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_BYTES = 12,
6724 google_protobuf_FieldDescriptorProto_TYPE_UINT32 = 13, 6267 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_UINT32 = 13,
6725 google_protobuf_FieldDescriptorProto_TYPE_ENUM = 14, 6268 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_ENUM = 14,
6726 google_protobuf_FieldDescriptorProto_TYPE_SFIXED32 = 15, 6269 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SFIXED32 = 15,
6727 google_protobuf_FieldDescriptorProto_TYPE_SFIXED64 = 16, 6270 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SFIXED64 = 16,
6728 google_protobuf_FieldDescriptorProto_TYPE_SINT32 = 17, 6271 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SINT32 = 17,
6729 google_protobuf_FieldDescriptorProto_TYPE_SINT64 = 18 6272 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SINT64 = 18
6730 } google_protobuf_FieldDescriptorProto_Type; 6273 } google_protobuf_FieldDescriptorProto_Type;
6731 6274
6732 typedef enum { 6275 typedef enum {
6733 google_protobuf_FieldOptions_STRING = 0, 6276 GOOGLE_PROTOBUF_FIELDOPTIONS_STRING = 0,
6734 google_protobuf_FieldOptions_CORD = 1, 6277 GOOGLE_PROTOBUF_FIELDOPTIONS_CORD = 1,
6735 google_protobuf_FieldOptions_STRING_PIECE = 2 6278 GOOGLE_PROTOBUF_FIELDOPTIONS_STRING_PIECE = 2
6736 } google_protobuf_FieldOptions_CType; 6279 } google_protobuf_FieldOptions_CType;
6737 6280
6738 typedef enum { 6281 typedef enum {
6739 google_protobuf_FieldOptions_JS_NORMAL = 0, 6282 GOOGLE_PROTOBUF_FILEOPTIONS_SPEED = 1,
6740 google_protobuf_FieldOptions_JS_STRING = 1, 6283 GOOGLE_PROTOBUF_FILEOPTIONS_CODE_SIZE = 2,
6741 google_protobuf_FieldOptions_JS_NUMBER = 2 6284 GOOGLE_PROTOBUF_FILEOPTIONS_LITE_RUNTIME = 3
6742 } google_protobuf_FieldOptions_JSType;
6743
6744 typedef enum {
6745 google_protobuf_FileOptions_SPEED = 1,
6746 google_protobuf_FileOptions_CODE_SIZE = 2,
6747 google_protobuf_FileOptions_LITE_RUNTIME = 3
6748 } google_protobuf_FileOptions_OptimizeMode; 6285 } google_protobuf_FileOptions_OptimizeMode;
6749 6286
6750 /* MessageDefs: call these functions to get a ref to a msgdef. */ 6287 /* Selectors */
6751 const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_get(const void *owner) ; 6288
6752 const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_get(con st void *owner); 6289 /* google.protobuf.DescriptorProto */
6753 const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_get(cons t void *owner); 6290 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSUBMSG 2
6754 const upb_msgdef *upbdefs_google_protobuf_EnumDescriptorProto_get(const void *ow ner); 6291 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSUBMSG 3
6755 const upb_msgdef *upbdefs_google_protobuf_EnumOptions_get(const void *owner); 6292 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSUBMSG 4
6756 const upb_msgdef *upbdefs_google_protobuf_EnumValueDescriptorProto_get(const voi d *owner); 6293 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSUBMSG 5
6757 const upb_msgdef *upbdefs_google_protobuf_EnumValueOptions_get(const void *owner ); 6294 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSUBMSG 6
6758 const upb_msgdef *upbdefs_google_protobuf_FieldDescriptorProto_get(const void *o wner); 6295 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_STARTSUBMSG 7
6759 const upb_msgdef *upbdefs_google_protobuf_FieldOptions_get(const void *owner); 6296 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSEQ 8
6760 const upb_msgdef *upbdefs_google_protobuf_FileDescriptorProto_get(const void *ow ner); 6297 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSEQ 9
6761 const upb_msgdef *upbdefs_google_protobuf_FileDescriptorSet_get(const void *owne r); 6298 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSUBMSG 10
6762 const upb_msgdef *upbdefs_google_protobuf_FileOptions_get(const void *owner); 6299 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSEQ 11
6763 const upb_msgdef *upbdefs_google_protobuf_MessageOptions_get(const void *owner); 6300 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSEQ 12
6764 const upb_msgdef *upbdefs_google_protobuf_MethodDescriptorProto_get(const void * owner); 6301 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSUBMSG 13
6765 const upb_msgdef *upbdefs_google_protobuf_MethodOptions_get(const void *owner); 6302 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 14
6766 const upb_msgdef *upbdefs_google_protobuf_OneofDescriptorProto_get(const void *o wner); 6303 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 15
6767 const upb_msgdef *upbdefs_google_protobuf_ServiceDescriptorProto_get(const void *owner); 6304 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 16
6768 const upb_msgdef *upbdefs_google_protobuf_ServiceOptions_get(const void *owner); 6305 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSEQ 17
6769 const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_get(const void *owner); 6306 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSEQ 18
6770 const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_Location_get(const void *owner); 6307 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSUBMSG 19
6771 const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_get(const void *ow ner); 6308 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSEQ 20
6772 const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_NamePart_get(const void *owner); 6309 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSEQ 21
6773 6310 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSUBMSG 22
6774 /* EnumDefs: call these functions to get a ref to an enumdef. */ 6311 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_ENDSUBMSG 23
6775 const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Label_get(const void *owner); 6312 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STRING 24
6776 const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Type_get(const v oid *owner); 6313 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STARTSTR 25
6777 const upb_enumdef *upbdefs_google_protobuf_FieldOptions_CType_get(const void *ow ner); 6314 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_ENDSTR 26
6778 const upb_enumdef *upbdefs_google_protobuf_FieldOptions_JSType_get(const void *o wner); 6315
6779 const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode_get(const vo id *owner); 6316 /* google.protobuf.DescriptorProto.ExtensionRange */
6780 6317 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_START_INT32 2
6781 /* Functions to test whether this message is of a certain type. */ 6318 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_END_INT32 3
6782 UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_is(const upb_msgdef *m) { 6319
6783 return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto") == 0; 6320 /* google.protobuf.EnumDescriptorProto */
6784 } 6321 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSUBMSG 2
6785 UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(const upb_msgdef *m) { 6322 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 3
6786 return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto.Extensi onRange") == 0; 6323 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSEQ 4
6787 } 6324 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_ENDSEQ 5
6788 UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(const u pb_msgdef *m) { 6325 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_ENDSUBMSG 6
6789 return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto.Reserve dRange") == 0; 6326 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 7
6790 } 6327 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_STRING 8
6791 UPB_INLINE bool upbdefs_google_protobuf_EnumDescriptorProto_is(const upb_msgdef *m) { 6328 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_STARTSTR 9
6792 return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumDescriptorProto") = = 0; 6329 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_ENDSTR 10
6793 } 6330
6794 UPB_INLINE bool upbdefs_google_protobuf_EnumOptions_is(const upb_msgdef *m) { 6331 /* google.protobuf.EnumOptions */
6795 return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumOptions") == 0; 6332 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6796 } 6333 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6797 UPB_INLINE bool upbdefs_google_protobuf_EnumValueDescriptorProto_is(const upb_ms gdef *m) { 6334 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6798 return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumValueDescriptorProt o") == 0; 6335 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6799 } 6336 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_ALLOW_ALIAS_BOOL 6
6800 UPB_INLINE bool upbdefs_google_protobuf_EnumValueOptions_is(const upb_msgdef *m) { 6337
6801 return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumValueOptions") == 0 ; 6338 /* google.protobuf.EnumValueDescriptorProto */
6802 } 6339 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
6803 UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_is(const upb_msgdef *m) { 6340 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 3
6804 return strcmp(upb_msgdef_fullname(m), "google.protobuf.FieldDescriptorProto") == 0; 6341 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_STRING 4
6805 } 6342 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_STARTSTR 5
6806 UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_is(const upb_msgdef *m) { 6343 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_ENDSTR 6
6807 return strcmp(upb_msgdef_fullname(m), "google.protobuf.FieldOptions") == 0; 6344 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NUMBER_INT32 7
6808 } 6345
6809 UPB_INLINE bool upbdefs_google_protobuf_FileDescriptorProto_is(const upb_msgdef *m) { 6346 /* google.protobuf.EnumValueOptions */
6810 return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileDescriptorProto") = = 0; 6347 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6811 } 6348 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6812 UPB_INLINE bool upbdefs_google_protobuf_FileDescriptorSet_is(const upb_msgdef *m ) { 6349 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6813 return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileDescriptorSet") == 0; 6350 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6814 } 6351
6815 UPB_INLINE bool upbdefs_google_protobuf_FileOptions_is(const upb_msgdef *m) { 6352 /* google.protobuf.FieldDescriptorProto */
6816 return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileOptions") == 0; 6353 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
6817 } 6354 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 3
6818 UPB_INLINE bool upbdefs_google_protobuf_MessageOptions_is(const upb_msgdef *m) { 6355 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_STRING 4
6819 return strcmp(upb_msgdef_fullname(m), "google.protobuf.MessageOptions") == 0; 6356 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_STARTSTR 5
6820 } 6357 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_ENDSTR 6
6821 UPB_INLINE bool upbdefs_google_protobuf_MethodDescriptorProto_is(const upb_msgde f *m) { 6358 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_STRING 7
6822 return strcmp(upb_msgdef_fullname(m), "google.protobuf.MethodDescriptorProto") == 0; 6359 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_STARTSTR 8
6823 } 6360 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_ENDSTR 9
6824 UPB_INLINE bool upbdefs_google_protobuf_MethodOptions_is(const upb_msgdef *m) { 6361 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NUMBER_INT32 10
6825 return strcmp(upb_msgdef_fullname(m), "google.protobuf.MethodOptions") == 0; 6362 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_INT32 11
6826 } 6363 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT32 12
6827 UPB_INLINE bool upbdefs_google_protobuf_OneofDescriptorProto_is(const upb_msgdef *m) { 6364 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_STRING 13
6828 return strcmp(upb_msgdef_fullname(m), "google.protobuf.OneofDescriptorProto") == 0; 6365 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_STARTSTR 14
6829 } 6366 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_ENDSTR 15
6830 UPB_INLINE bool upbdefs_google_protobuf_ServiceDescriptorProto_is(const upb_msgd ef *m) { 6367 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STRING 16
6831 return strcmp(upb_msgdef_fullname(m), "google.protobuf.ServiceDescriptorProto" ) == 0; 6368 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STARTSTR 17
6832 } 6369 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_ENDSTR 18
6833 UPB_INLINE bool upbdefs_google_protobuf_ServiceOptions_is(const upb_msgdef *m) { 6370
6834 return strcmp(upb_msgdef_fullname(m), "google.protobuf.ServiceOptions") == 0; 6371 /* google.protobuf.FieldOptions */
6835 } 6372 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6836 UPB_INLINE bool upbdefs_google_protobuf_SourceCodeInfo_is(const upb_msgdef *m) { 6373 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6837 return strcmp(upb_msgdef_fullname(m), "google.protobuf.SourceCodeInfo") == 0; 6374 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6838 } 6375 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6839 UPB_INLINE bool upbdefs_google_protobuf_SourceCodeInfo_Location_is(const upb_msg def *m) { 6376 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_CTYPE_INT32 6
6840 return strcmp(upb_msgdef_fullname(m), "google.protobuf.SourceCodeInfo.Location ") == 0; 6377 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_PACKED_BOOL 7
6841 } 6378 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_DEPRECATED_BOOL 8
6842 UPB_INLINE bool upbdefs_google_protobuf_UninterpretedOption_is(const upb_msgdef *m) { 6379 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_LAZY_BOOL 9
6843 return strcmp(upb_msgdef_fullname(m), "google.protobuf.UninterpretedOption") = = 0; 6380 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_STRING 10
6844 } 6381 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_STARTSTR 11
6845 UPB_INLINE bool upbdefs_google_protobuf_UninterpretedOption_NamePart_is(const up b_msgdef *m) { 6382 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_ENDSTR 12
6846 return strcmp(upb_msgdef_fullname(m), "google.protobuf.UninterpretedOption.Nam ePart") == 0; 6383 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_WEAK_BOOL 13
6847 } 6384
6848 6385 /* google.protobuf.FileDescriptorProto */
6849 /* Functions to test whether this enum is of a certain type. */ 6386 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSUBMSG 2
6850 UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_Label_is(const upb_ enumdef *e) { 6387 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_STARTSUBMSG 3
6851 return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldDescriptorProto.L abel") == 0; 6388 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_STARTSUBMSG 4
6852 } 6389 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_STARTSUBMSG 5
6853 UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_Type_is(const upb_e numdef *e) { 6390 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 6
6854 return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldDescriptorProto.T ype") == 0; 6391 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SOURCE_CODE_INFO_STARTSUBMSG 7
6855 } 6392 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSEQ 8
6856 UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_CType_is(const upb_enumdef *e) { 6393 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_ENDSEQ 9
6857 return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldOptions.CType") = = 0; 6394 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_ENDSUBMSG 10
6858 } 6395 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 11
6859 UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_JSType_is(const upb_enumdef *e) { 6396 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 12
6860 return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldOptions.JSType") == 0; 6397 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 13
6861 } 6398 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_STARTSEQ 14
6862 UPB_INLINE bool upbdefs_google_protobuf_FileOptions_OptimizeMode_is(const upb_en umdef *e) { 6399 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_ENDSEQ 15
6863 return strcmp(upb_enumdef_fullname(e), "google.protobuf.FileOptions.OptimizeMo de") == 0; 6400 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_ENDSUBMSG 16
6864 } 6401 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_STARTSEQ 17
6865 6402 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_ENDSEQ 18
6866 6403 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_ENDSUBMSG 19
6867 /* Functions to get a fielddef from a msgdef reference. */ 6404 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 20
6868 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_Extension Range_f_end(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Descriptor Proto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 2); } 6405 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SOURCE_CODE_INFO_ENDSUBMSG 21
6869 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_Extension Range_f_start(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Descript orProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 1); } 6406 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_STRING 22
6870 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedR ange_f_end(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorP roto_ReservedRange_is(m)); return upb_msgdef_itof(m, 2); } 6407 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_STARTSTR 23
6871 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedR ange_f_start(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Descripto rProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 1); } 6408 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_ENDSTR 24
6872 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_ty pe(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is( m)); return upb_msgdef_itof(m, 4); } 6409 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_STRING 25
6873 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extensi on(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is( m)); return upb_msgdef_itof(m, 6); } 6410 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_STARTSTR 26
6874 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extensi on_range(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorPro to_is(m)); return upb_msgdef_itof(m, 5); } 6411 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_ENDSTR 27
6875 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(c onst upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } 6412 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STARTSEQ 28
6876 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(co nst upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } 6413 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_ENDSEQ 29
6877 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_ type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_i s(m)); return upb_msgdef_itof(m, 3); } 6414 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STRING 30
6878 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_d ecl(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is (m)); return upb_msgdef_itof(m, 8); } 6415 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STARTSTR 31
6879 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options (const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m) ); return upb_msgdef_itof(m, 7); } 6416 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_ENDSTR 32
6880 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserve d_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto _is(m)); return upb_msgdef_itof(m, 10); } 6417 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PUBLIC_DEPENDENCY_STARTSEQ 33
6881 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserve d_range(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProt o_is(m)); return upb_msgdef_itof(m, 9); } 6418 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PUBLIC_DEPENDENCY_ENDSEQ 34
6882 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_nam e(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_ is(m)); return upb_msgdef_itof(m, 1); } 6419 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PUBLIC_DEPENDENCY_INT32 35
6883 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_opt ions(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorPro to_is(m)); return upb_msgdef_itof(m, 3); } 6420 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_STARTSEQ 36
6884 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_val ue(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto _is(m)); return upb_msgdef_itof(m, 2); } 6421 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_ENDSEQ 37
6885 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias (const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); r eturn upb_msgdef_itof(m, 2); } 6422 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_INT32 38
6886 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated( const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); re turn upb_msgdef_itof(m, 3); } 6423
6887 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpret ed_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_ is(m)); return upb_msgdef_itof(m, 999); } 6424 /* google.protobuf.FileDescriptorSet */
6888 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_ f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescri ptorProto_is(m)); return upb_msgdef_itof(m, 1); } 6425 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSUBMSG 2
6889 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_ f_number(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDesc riptorProto_is(m)); return upb_msgdef_itof(m, 2); } 6426 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSEQ 3
6890 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_ f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDes criptorProto_is(m)); return upb_msgdef_itof(m, 3); } 6427 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_ENDSEQ 4
6891 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprec ated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_ is(m)); return upb_msgdef_itof(m, 1); } 6428 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_ENDSUBMSG 5
6892 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninte rpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumVal ueOptions_is(m)); return upb_msgdef_itof(m, 999); } 6429
6893 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_de fault_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescr iptorProto_is(m)); return upb_msgdef_itof(m, 7); } 6430 /* google.protobuf.FileOptions */
6894 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_ex tendee(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptor Proto_is(m)); return upb_msgdef_itof(m, 2); } 6431 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6895 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_js on_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescripto rProto_is(m)); return upb_msgdef_itof(m, 10); } 6432 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6896 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_la bel(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorPro to_is(m)); return upb_msgdef_itof(m, 4); } 6433 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6897 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_na me(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProt o_is(m)); return upb_msgdef_itof(m, 1); } 6434 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6898 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_nu mber(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorPr oto_is(m)); return upb_msgdef_itof(m, 3); } 6435 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_STRING 6
6899 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_on eof_index(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescrip torProto_is(m)); return upb_msgdef_itof(m, 9); } 6436 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_STARTSTR 7
6900 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_op tions(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorP roto_is(m)); return upb_msgdef_itof(m, 8); } 6437 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_ENDSTR 8
6901 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_ty pe(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProt o_is(m)); return upb_msgdef_itof(m, 5); } 6438 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_STRING 9
6902 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_ty pe_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescripto rProto_is(m)); return upb_msgdef_itof(m, 6); } 6439 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_STARTSTR 10
6903 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(cons t upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); retur n upb_msgdef_itof(m, 1); } 6440 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_ENDSTR 11
6904 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated (const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 3); } 6441 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_OPTIMIZE_FOR_INT32 12
6905 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(con st upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); retu rn upb_msgdef_itof(m, 6); } 6442 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_MULTIPLE_FILES_BOOL 13
6906 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 5); } 6443 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_GO_PACKAGE_STRING 14
6907 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(con st upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); retu rn upb_msgdef_itof(m, 2); } 6444 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_GO_PACKAGE_STARTSTR 15
6908 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpre ted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOption s_is(m)); return upb_msgdef_itof(m, 999); } 6445 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_GO_PACKAGE_ENDSTR 16
6909 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 10); } 6446 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_CC_GENERIC_SERVICES_BOOL 17
6910 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dep endency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptor Proto_is(m)); return upb_msgdef_itof(m, 3); } 6447 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERIC_SERVICES_BOOL 18
6911 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enu m_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorP roto_is(m)); return upb_msgdef_itof(m, 5); } 6448 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_PY_GENERIC_SERVICES_BOOL 19
6912 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_ext ension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorP roto_is(m)); return upb_msgdef_itof(m, 7); } 6449 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERATE_EQUALS_AND_HASH_BOOL 20
6913 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_mes sage_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescript orProto_is(m)); return upb_msgdef_itof(m, 4); } 6450
6914 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_nam e(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_ is(m)); return upb_msgdef_itof(m, 1); } 6451 /* google.protobuf.MessageOptions */
6915 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_opt ions(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorPro to_is(m)); return upb_msgdef_itof(m, 8); } 6452 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6916 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_pac kage(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorPro to_is(m)); return upb_msgdef_itof(m, 2); } 6453 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6917 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_pub lic_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDes criptorProto_is(m)); return upb_msgdef_itof(m, 10); } 6454 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6918 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_ser vice(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorPro to_is(m)); return upb_msgdef_itof(m, 6); } 6455 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6919 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_sou rce_code_info(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDesc riptorProto_is(m)); return upb_msgdef_itof(m, 9); } 6456 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_MESSAGE_SET_WIRE_FORMAT_BOOL 6
6920 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syn tax(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProt o_is(m)); return upb_msgdef_itof(m, 12); } 6457 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_NO_STANDARD_DESCRIPTOR_ACCESSOR_BOOL 7
6921 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_wea k_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescr iptorProto_is(m)); return upb_msgdef_itof(m, 11); } 6458
6922 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file( const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorSet_is(m )); return upb_msgdef_itof(m, 1); } 6459 /* google.protobuf.MethodDescriptorProto */
6923 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_a renas(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m )); return upb_msgdef_itof(m, 31); } 6460 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
6924 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_ services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_i s(m)); return upb_msgdef_itof(m, 16); } 6461 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 3
6925 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_name space(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m )); return upb_msgdef_itof(m, 37); } 6462 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_STRING 4
6926 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated( const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); re turn upb_msgdef_itof(m, 23); } 6463 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_STARTSTR 5
6927 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package( const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); re turn upb_msgdef_itof(m, 11); } 6464 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_ENDSTR 6
6928 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_genera te_equals_and_hash(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Fil eOptions_is(m)); return upb_msgdef_itof(m, 20); } 6465 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_STRING 7
6929 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generi c_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions _is(m)); return upb_msgdef_itof(m, 17); } 6466 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_STARTSTR 8
6930 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multip le_files(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_i s(m)); return upb_msgdef_itof(m, 10); } 6467 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_ENDSTR 9
6931 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_ classname(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_ is(m)); return upb_msgdef_itof(m, 8); } 6468 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STRING 10
6932 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_packag e(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 1); } 6469 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STARTSTR 11
6933 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string _check_utf8(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOption s_is(m)); return upb_msgdef_itof(m, 27); } 6470 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_ENDSTR 12
6934 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_us e_deprecated_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_F ileOptions_is(m)); return upb_msgdef_itof(m, 38); } 6471
6935 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_ prefix(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is( m)); return upb_msgdef_itof(m, 36); } 6472 /* google.protobuf.MethodOptions */
6936 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_fo r(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); } 6473 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6937 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_ services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_i s(m)); return upb_msgdef_itof(m, 18); } 6474 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6938 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpret ed_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_ is(m)); return upb_msgdef_itof(m, 999); } 6475 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6939 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecat ed(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m )); return upb_msgdef_itof(m, 3); } 6476 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6940 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entr y(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m) ); return upb_msgdef_itof(m, 7); } 6477
6941 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_ set_wire_format(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Messag eOptions_is(m)); return upb_msgdef_itof(m, 1); } 6478 /* google.protobuf.ServiceDescriptorProto */
6942 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_stand ard_descriptor_accessor(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobu f_MessageOptions_is(m)); return upb_msgdef_itof(m, 2); } 6479 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSUBMSG 2
6943 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterp reted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOp tions_is(m)); return upb_msgdef_itof(m, 999); } 6480 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 3
6944 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_c lient_streaming(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Method DescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } 6481 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSEQ 4
6945 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_i nput_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescri ptorProto_is(m)); return upb_msgdef_itof(m, 2); } 6482 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_ENDSEQ 5
6946 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_n ame(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorPr oto_is(m)); return upb_msgdef_itof(m, 1); } 6483 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_ENDSUBMSG 6
6947 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_o ptions(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescripto rProto_is(m)); return upb_msgdef_itof(m, 4); } 6484 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 7
6948 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_o utput_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescr iptorProto_is(m)); return upb_msgdef_itof(m, 3); } 6485 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_STRING 8
6949 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_s erver_streaming(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Method DescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } 6486 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_STARTSTR 9
6950 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecate d(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)) ; return upb_msgdef_itof(m, 33); } 6487 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_ENDSTR 10
6951 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpr eted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodOpti ons_is(m)); return upb_msgdef_itof(m, 999); } 6488
6952 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_na me(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_OneofDescriptorProt o_is(m)); return upb_msgdef_itof(m, 1); } 6489 /* google.protobuf.ServiceOptions */
6953 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_ method(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescript orProto_is(m)); return upb_msgdef_itof(m, 2); } 6490 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
6954 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_ name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptor Proto_is(m)); return upb_msgdef_itof(m, 1); } 6491 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
6955 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_ options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescrip torProto_is(m)); return upb_msgdef_itof(m, 3); } 6492 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
6956 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecat ed(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m )); return upb_msgdef_itof(m, 33); } 6493 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
6957 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterp reted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceOp tions_is(m)); return upb_msgdef_itof(m, 999); } 6494
6958 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f _leading_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Sour ceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 3); } 6495 /* google.protobuf.SourceCodeInfo */
6959 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f _leading_detached_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_prot obuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 6); } 6496 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSUBMSG 2
6960 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f _path(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_L ocation_is(m)); return upb_msgdef_itof(m, 1); } 6497 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSEQ 3
6961 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f _span(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_L ocation_is(m)); return upb_msgdef_itof(m, 2); } 6498 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_ENDSEQ 4
6962 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f _trailing_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Sou rceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 4); } 6499 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_ENDSUBMSG 5
6963 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location (const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_is(m)) ; return upb_msgdef_itof(m, 1); } 6500
6964 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NameP art_f_is_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Uni nterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 2); } 6501 /* google.protobuf.SourceCodeInfo.Location */
6965 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NameP art_f_name_part(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Uninte rpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 1); } 6502 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_STARTSEQ 2
6966 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_agg regate_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Uninterpr etedOption_is(m)); return upb_msgdef_itof(m, 8); } 6503 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_ENDSEQ 3
6967 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_dou ble_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Uninterprete dOption_is(m)); return upb_msgdef_itof(m, 6); } 6504 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_INT32 4
6968 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_ide ntifier_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Uninterp retedOption_is(m)); return upb_msgdef_itof(m, 3); } 6505 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_STARTSEQ 5
6969 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_nam e(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_ is(m)); return upb_msgdef_itof(m, 2); } 6506 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_ENDSEQ 6
6970 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_neg ative_int_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Uninte rpretedOption_is(m)); return upb_msgdef_itof(m, 5); } 6507 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_INT32 7
6971 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_pos itive_int_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Uninte rpretedOption_is(m)); return upb_msgdef_itof(m, 4); } 6508 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_COMMENTS_STRING 8
6972 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_str ing_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_Uninterprete dOption_is(m)); return upb_msgdef_itof(m, 7); } 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 1 2
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_s ymtab *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_ExtensionRa nge(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 u pb_symtab *s) {
6553 const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.EnumDescriptorP roto");
6554 assert(m);
6555 return m;
6556 }
6557 UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_EnumOptions(const upb_symta b *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(co nst upb_symtab *s) {
6563 const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.EnumValueDescri ptorProto");
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.EnumValueOption s");
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.FieldDescriptor Proto");
6574 assert(m);
6575 return m;
6576 }
6577 UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_FieldOptions(const upb_symt ab *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 u pb_symtab *s) {
6583 const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.FileDescriptorP roto");
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.FileDescriptorS et");
6589 assert(m);
6590 return m;
6591 }
6592 UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_FileOptions(const upb_symta b *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_sy mtab *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.MethodDescripto rProto");
6604 assert(m);
6605 return m;
6606 }
6607 UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_MethodOptions(const upb_sym tab *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(cons t upb_symtab *s) {
6613 const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.ServiceDescript orProto");
6614 assert(m);
6615 return m;
6616 }
6617 UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_ServiceOptions(const upb_sy mtab *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_sy mtab *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(con st 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 u pb_symtab *s) {
6633 const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.UninterpretedOp tion");
6634 assert(m);
6635 return m;
6636 }
6637 UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_NamePar t(const upb_symtab *s) {
6638 const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.UninterpretedOp tion.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.FieldDescript orProto.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.FieldDescript orProto.Type");
6652 assert(e);
6653 return e;
6654 }
6655 UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FieldOptions_CType(const u pb_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(c onst upb_symtab *s) {
6661 const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FileOptions.O ptimizeMode");
6662 assert(e);
6663 return e;
6664 }
6665
6666 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_Extension Range_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_Extension Range_start(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobu f_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_Descripto rProto(s), 4); }
6669 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_extension (const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Descripto rProto(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_Des criptorProto(s), 5); }
6671 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_field(con st upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorPro to(s), 2); }
6672 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_name(cons t upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProt o(s), 1); }
6673 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_nested_ty pe(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Descrip torProto(s), 3); }
6674 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_options(c onst upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorP roto(s), 7); }
6675 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_name( const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescri ptorProto(s), 1); }
6676 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_optio ns(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDes criptorProto(s), 3); }
6677 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_value (const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescr iptorProto(s), 2); }
6678 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_allow_alias(c onst 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_En umOptions(s), 999); }
6680 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_ name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumV alueDescriptorProto(s), 1); }
6681 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_ number(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Enu mValueDescriptorProto(s), 2); }
6682 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_ options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_En umValueDescriptorProto(s), 3); }
6683 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_uninterp reted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protob uf_EnumValueOptions(s), 999); }
6684 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_defa ult_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_exte ndee(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Field DescriptorProto(s), 2); }
6686 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_labe l(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDes criptorProto(s), 4); }
6687 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_name (const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDesc riptorProto(s), 1); }
6688 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_numb er(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDe scriptorProto(s), 3); }
6689 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_opti ons(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldD escriptorProto(s), 8); }
6690 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_type (const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDesc riptorProto(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_Fiel dDescriptorProto(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(c onst upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOption s(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_F ieldOptions(s), 9); }
6695 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_lazy(const u pb_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_uninterprete d_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_F ieldOptions(s), 999); }
6698 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_weak(const u pb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 10); }
6699 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_depen dency(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_File DescriptorProto(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_FileD escriptorProto(s), 5); }
6701 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_exten sion(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileD escriptorProto(s), 7); }
6702 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_messa ge_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Fi leDescriptorProto(s), 4); }
6703 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_name( const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescri ptorProto(s), 1); }
6704 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_optio ns(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDes criptorProto(s), 8); }
6705 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_packa ge(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDes criptorProto(s), 2); }
6706 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_publi c_dependency(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protob uf_FileDescriptorProto(s), 10); }
6707 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_servi ce(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDes criptorProto(s), 6); }
6708 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_sourc e_code_info(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobu f_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(co nst upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescript orSet(s), 1); }
6711 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_cc_generic_se rvices(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Fil eOptions(s), 16); }
6712 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_go_package(co nst 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_pr otobuf_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_F ileOptions(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_Fil eOptions(s), 10); }
6716 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_outer_cl assname(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Fi leOptions(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_FileOption s(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_FileOption s(s), 9); }
6719 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_py_generic_se rvices(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Fil eOptions(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_Fi leOptions(s), 999); }
6721 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_message_se t_wire_format(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_proto buf_MessageOptions(s), 1); }
6722 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_no_standar d_descriptor_accessor(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_goog le_protobuf_MessageOptions(s), 2); }
6723 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_uninterpre ted_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_inp ut_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Me thodDescriptorProto(s), 2); }
6725 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_nam e(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDe scriptorProto(s), 1); }
6726 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_opt ions(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Metho dDescriptorProto(s), 4); }
6727 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_out put_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_M ethodDescriptorProto(s), 3); }
6728 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_uninterpret ed_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_me thod(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Servi ceDescriptorProto(s), 2); }
6730 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_na me(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Service DescriptorProto(s), 1); }
6731 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_op tions(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Serv iceDescriptorProto(s), 3); }
6732 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_uninterpre ted_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_l eading_comments(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_pro tobuf_SourceCodeInfo_Location(s), 3); }
6734 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_p ath(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Source CodeInfo_Location(s), 1); }
6735 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_s pan(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Source CodeInfo_Location(s), 2); }
6736 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_t railing_comments(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_pr otobuf_SourceCodeInfo_Location(s), 4); }
6737 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_location(c onst upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeI nfo(s), 1); }
6738 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NameP art_is_extension(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_pr otobuf_UninterpretedOption_NamePart(s), 2); }
6739 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NameP art_name_part(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_proto buf_UninterpretedOption_NamePart(s), 1); }
6740 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_aggre gate_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_doubl e_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Un interpretedOption(s), 6); }
6742 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_ident ifier_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobu f_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_Uninterpre tedOption(s), 2); }
6744 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_negat ive_int_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_proto buf_UninterpretedOption(s), 5); }
6745 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_posit ive_int_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_proto buf_UninterpretedOption(s), 4); }
6746 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_strin g_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_Un interpretedOption(s), 7); }
6973 6747
6974 UPB_END_EXTERN_C 6748 UPB_END_EXTERN_C
6975 6749
6976 #ifdef __cplusplus 6750 #ifdef __cplusplus
6977 6751
6978 namespace upbdefs { 6752 namespace upbdefs {
6979 namespace google { 6753 namespace google {
6980 namespace protobuf { 6754 namespace protobuf {
6981 6755 namespace descriptor {
6982 class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6756 inline upb::reffed_ptr<const upb::SymbolTable> SymbolTable() {
6983 public: 6757 const upb::SymbolTable* s = upbdefs_google_protobuf_descriptor(&s);
6984 DescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) 6758 return upb::reffed_ptr<const upb::SymbolTable>(s, &s);
6985 : reffed_ptr(m, ref_donor) { 6759 }
6986 UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); 6760 } /* namespace descriptor */
6987 } 6761 } /* namespace protobuf */
6988 6762 } /* namespace google */
6989 static DescriptorProto get() { 6763
6990 const ::upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_get(&m) ; 6764 #define RETURN_REFFED(type, func) \
6991 return DescriptorProto(m, &m); 6765 const type* obj = func(upbdefs::google::protobuf::descriptor::SymbolTable(). get()); \
6992 } 6766 return upb::reffed_ptr<const type>(obj);
6993 6767
6994 class ExtensionRange : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6768 namespace google {
6995 public: 6769 namespace protobuf {
6996 ExtensionRange(const ::upb::MessageDef* m, const void *ref_donor = NULL) 6770 namespace DescriptorProto {
6997 : reffed_ptr(m, ref_donor) { 6771 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_DescriptorProto) }
6998 UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); 6772 inline upb::reffed_ptr<const upb::FieldDef> enum_type() { RETURN_REFFED(upb::Fie ldDef, upbdefs_google_protobuf_DescriptorProto_enum_type) }
6999 } 6773 inline upb::reffed_ptr<const upb::FieldDef> extension() { RETURN_REFFED(upb::Fie ldDef, upbdefs_google_protobuf_DescriptorProto_extension) }
7000 6774 inline upb::reffed_ptr<const upb::FieldDef> extension_range() { RETURN_REFFED(up b::FieldDef, upbdefs_google_protobuf_DescriptorProto_extension_range) }
7001 static ExtensionRange get() { 6775 inline upb::reffed_ptr<const upb::FieldDef> field() { RETURN_REFFED(upb::FieldDe f, upbdefs_google_protobuf_DescriptorProto_field) }
7002 const ::upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_Exten sionRange_get(&m); 6776 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_DescriptorProto_name) }
7003 return ExtensionRange(m, &m); 6777 inline upb::reffed_ptr<const upb::FieldDef> nested_type() { RETURN_REFFED(upb::F ieldDef, upbdefs_google_protobuf_DescriptorProto_nested_type) }
7004 } 6778 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field Def, upbdefs_google_protobuf_DescriptorProto_options) }
7005 }; 6779 } /* namespace DescriptorProto */
7006 6780 } /* namespace protobuf */
7007 class ReservedRange : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6781 } /* namespace google */
7008 public: 6782
7009 ReservedRange(const ::upb::MessageDef* m, const void *ref_donor = NULL) 6783 namespace google {
7010 : reffed_ptr(m, ref_donor) { 6784 namespace protobuf {
7011 UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); 6785 namespace DescriptorProto {
7012 } 6786 namespace ExtensionRange {
7013 6787 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_DescriptorProto_ExtensionRange) }
7014 static ReservedRange get() { 6788 inline upb::reffed_ptr<const upb::FieldDef> end() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_ExtensionRange_end) }
7015 const ::upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_Reser vedRange_get(&m); 6789 inline upb::reffed_ptr<const upb::FieldDef> start() { RETURN_REFFED(upb::FieldDe f, upbdefs_google_protobuf_DescriptorProto_ExtensionRange_start) }
7016 return ReservedRange(m, &m); 6790 } /* namespace ExtensionRange */
7017 } 6791 } /* namespace DescriptorProto */
7018 }; 6792 } /* namespace protobuf */
7019 }; 6793 } /* namespace google */
7020 6794
7021 class EnumDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6795 namespace google {
7022 public: 6796 namespace protobuf {
7023 EnumDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) 6797 namespace EnumDescriptorProto {
7024 : reffed_ptr(m, ref_donor) { 6798 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_EnumDescriptorProto) }
7025 UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); 6799 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_EnumDescriptorProto_name) }
7026 } 6800 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field Def, upbdefs_google_protobuf_EnumDescriptorProto_options) }
7027 6801 inline upb::reffed_ptr<const upb::FieldDef> value() { RETURN_REFFED(upb::FieldDe f, upbdefs_google_protobuf_EnumDescriptorProto_value) }
7028 static EnumDescriptorProto get() { 6802 } /* namespace EnumDescriptorProto */
7029 const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumDescriptorProto_get (&m); 6803 } /* namespace protobuf */
7030 return EnumDescriptorProto(m, &m); 6804 } /* namespace google */
7031 } 6805
7032 }; 6806 namespace google {
7033 6807 namespace protobuf {
7034 class EnumOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6808 namespace EnumOptions {
7035 public: 6809 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_EnumOptions) }
7036 EnumOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) 6810 inline upb::reffed_ptr<const upb::FieldDef> allow_alias() { RETURN_REFFED(upb::F ieldDef, upbdefs_google_protobuf_EnumOptions_allow_alias) }
7037 : reffed_ptr(m, ref_donor) { 6811 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF ED(upb::FieldDef, upbdefs_google_protobuf_EnumOptions_uninterpreted_option) }
7038 UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); 6812 } /* namespace EnumOptions */
7039 } 6813 } /* namespace protobuf */
7040 6814 } /* namespace google */
7041 static EnumOptions get() { 6815
7042 const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumOptions_get(&m); 6816 namespace google {
7043 return EnumOptions(m, &m); 6817 namespace protobuf {
7044 } 6818 namespace EnumValueDescriptorProto {
7045 }; 6819 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_EnumValueDescriptorProto) }
7046 6820 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_EnumValueDescriptorProto_name) }
7047 class EnumValueDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDe f> { 6821 inline upb::reffed_ptr<const upb::FieldDef> number() { RETURN_REFFED(upb::FieldD ef, upbdefs_google_protobuf_EnumValueDescriptorProto_number) }
7048 public: 6822 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field Def, upbdefs_google_protobuf_EnumValueDescriptorProto_options) }
7049 EnumValueDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = N ULL) 6823 } /* namespace EnumValueDescriptorProto */
7050 : reffed_ptr(m, ref_donor) { 6824 } /* namespace protobuf */
7051 UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); 6825 } /* namespace google */
7052 } 6826
7053 6827 namespace google {
7054 static EnumValueDescriptorProto get() { 6828 namespace protobuf {
7055 const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumValueDescriptorProt o_get(&m); 6829 namespace EnumValueOptions {
7056 return EnumValueDescriptorProto(m, &m); 6830 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_EnumValueOptions) }
7057 } 6831 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF ED(upb::FieldDef, upbdefs_google_protobuf_EnumValueOptions_uninterpreted_option) }
7058 }; 6832 } /* namespace EnumValueOptions */
7059 6833 } /* namespace protobuf */
7060 class EnumValueOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6834 } /* namespace google */
7061 public: 6835
7062 EnumValueOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) 6836 namespace google {
7063 : reffed_ptr(m, ref_donor) { 6837 namespace protobuf {
7064 UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m)); 6838 namespace FieldDescriptorProto {
7065 } 6839 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_FieldDescriptorProto) }
7066 6840 inline upb::reffed_ptr<const upb::FieldDef> default_value() { RETURN_REFFED(upb: :FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_default_value) }
7067 static EnumValueOptions get() { 6841 inline upb::reffed_ptr<const upb::FieldDef> extendee() { RETURN_REFFED(upb::Fiel dDef, upbdefs_google_protobuf_FieldDescriptorProto_extendee) }
7068 const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumValueOptions_get(&m ); 6842 inline upb::reffed_ptr<const upb::FieldDef> label() { RETURN_REFFED(upb::FieldDe f, upbdefs_google_protobuf_FieldDescriptorProto_label) }
7069 return EnumValueOptions(m, &m); 6843 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_FieldDescriptorProto_name) }
7070 } 6844 inline upb::reffed_ptr<const upb::FieldDef> number() { RETURN_REFFED(upb::FieldD ef, upbdefs_google_protobuf_FieldDescriptorProto_number) }
7071 }; 6845 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field Def, upbdefs_google_protobuf_FieldDescriptorProto_options) }
7072 6846 inline upb::reffed_ptr<const upb::FieldDef> type() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_FieldDescriptorProto_type) }
7073 class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6847 inline upb::reffed_ptr<const upb::FieldDef> type_name() { RETURN_REFFED(upb::Fie ldDef, upbdefs_google_protobuf_FieldDescriptorProto_type_name) }
7074 public: 6848 inline upb::reffed_ptr<const upb::EnumDef> Label() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldDescriptorProto_Label) }
7075 FieldDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) 6849 inline upb::reffed_ptr<const upb::EnumDef> Type() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldDescriptorProto_Type) }
7076 : reffed_ptr(m, ref_donor) { 6850 } /* namespace FieldDescriptorProto */
7077 UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); 6851 } /* namespace protobuf */
7078 } 6852 } /* namespace google */
7079 6853
7080 static FieldDescriptorProto get() { 6854 namespace google {
7081 const ::upb::MessageDef* m = upbdefs_google_protobuf_FieldDescriptorProto_ge t(&m); 6855 namespace protobuf {
7082 return FieldDescriptorProto(m, &m); 6856 namespace FieldOptions {
7083 } 6857 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_FieldOptions) }
7084 6858 inline upb::reffed_ptr<const upb::FieldDef> ctype() { RETURN_REFFED(upb::FieldDe f, upbdefs_google_protobuf_FieldOptions_ctype) }
7085 class Label : public ::upb::reffed_ptr<const ::upb::EnumDef> { 6859 inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::Fi eldDef, upbdefs_google_protobuf_FieldOptions_deprecated) }
7086 public: 6860 inline upb::reffed_ptr<const upb::FieldDef> experimental_map_key() { RETURN_REFF ED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_experimental_map_key) }
7087 Label(const ::upb::EnumDef* e, const void *ref_donor = NULL) 6861 inline upb::reffed_ptr<const upb::FieldDef> lazy() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_FieldOptions_lazy) }
7088 : reffed_ptr(e, ref_donor) { 6862 inline upb::reffed_ptr<const upb::FieldDef> packed() { RETURN_REFFED(upb::FieldD ef, upbdefs_google_protobuf_FieldOptions_packed) }
7089 UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_Label_is(e)); 6863 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF ED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_uninterpreted_option) }
7090 } 6864 inline upb::reffed_ptr<const upb::FieldDef> weak() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_FieldOptions_weak) }
7091 static Label get() { 6865 inline upb::reffed_ptr<const upb::EnumDef> CType() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldOptions_CType) }
7092 const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Lab el_get(&e); 6866 } /* namespace FieldOptions */
7093 return Label(e, &e); 6867 } /* namespace protobuf */
7094 } 6868 } /* namespace google */
7095 }; 6869
7096 6870 namespace google {
7097 class Type : public ::upb::reffed_ptr<const ::upb::EnumDef> { 6871 namespace protobuf {
7098 public: 6872 namespace FileDescriptorProto {
7099 Type(const ::upb::EnumDef* e, const void *ref_donor = NULL) 6873 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_FileDescriptorProto) }
7100 : reffed_ptr(e, ref_donor) { 6874 inline upb::reffed_ptr<const upb::FieldDef> dependency() { RETURN_REFFED(upb::Fi eldDef, upbdefs_google_protobuf_FileDescriptorProto_dependency) }
7101 UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_Type_is(e)); 6875 inline upb::reffed_ptr<const upb::FieldDef> enum_type() { RETURN_REFFED(upb::Fie ldDef, upbdefs_google_protobuf_FileDescriptorProto_enum_type) }
7102 } 6876 inline upb::reffed_ptr<const upb::FieldDef> extension() { RETURN_REFFED(upb::Fie ldDef, upbdefs_google_protobuf_FileDescriptorProto_extension) }
7103 static Type get() { 6877 inline upb::reffed_ptr<const upb::FieldDef> message_type() { RETURN_REFFED(upb:: FieldDef, upbdefs_google_protobuf_FileDescriptorProto_message_type) }
7104 const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Typ e_get(&e); 6878 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_FileDescriptorProto_name) }
7105 return Type(e, &e); 6879 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field Def, upbdefs_google_protobuf_FileDescriptorProto_options) }
7106 } 6880 inline upb::reffed_ptr<const upb::FieldDef> package() { RETURN_REFFED(upb::Field Def, upbdefs_google_protobuf_FileDescriptorProto_package) }
7107 }; 6881 inline upb::reffed_ptr<const upb::FieldDef> public_dependency() { RETURN_REFFED( upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_public_dependency) }
7108 }; 6882 inline upb::reffed_ptr<const upb::FieldDef> service() { RETURN_REFFED(upb::Field Def, upbdefs_google_protobuf_FileDescriptorProto_service) }
7109 6883 inline upb::reffed_ptr<const upb::FieldDef> source_code_info() { RETURN_REFFED(u pb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_source_code_info) }
7110 class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6884 inline upb::reffed_ptr<const upb::FieldDef> weak_dependency() { RETURN_REFFED(up b::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_weak_dependency) }
7111 public: 6885 } /* namespace FileDescriptorProto */
7112 FieldOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) 6886 } /* namespace protobuf */
7113 : reffed_ptr(m, ref_donor) { 6887 } /* namespace google */
7114 UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); 6888
7115 } 6889 namespace google {
7116 6890 namespace protobuf {
7117 static FieldOptions get() { 6891 namespace FileDescriptorSet {
7118 const ::upb::MessageDef* m = upbdefs_google_protobuf_FieldOptions_get(&m); 6892 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_FileDescriptorSet) }
7119 return FieldOptions(m, &m); 6893 inline upb::reffed_ptr<const upb::FieldDef> file() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_FileDescriptorSet_file) }
7120 } 6894 } /* namespace FileDescriptorSet */
7121 6895 } /* namespace protobuf */
7122 class CType : public ::upb::reffed_ptr<const ::upb::EnumDef> { 6896 } /* namespace google */
7123 public: 6897
7124 CType(const ::upb::EnumDef* e, const void *ref_donor = NULL) 6898 namespace google {
7125 : reffed_ptr(e, ref_donor) { 6899 namespace protobuf {
7126 UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_CType_is(e)); 6900 namespace FileOptions {
7127 } 6901 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_FileOptions) }
7128 static CType get() { 6902 inline upb::reffed_ptr<const upb::FieldDef> cc_generic_services() { RETURN_REFFE D(upb::FieldDef, upbdefs_google_protobuf_FileOptions_cc_generic_services) }
7129 const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_CType_get(& e); 6903 inline upb::reffed_ptr<const upb::FieldDef> go_package() { RETURN_REFFED(upb::Fi eldDef, upbdefs_google_protobuf_FileOptions_go_package) }
7130 return CType(e, &e); 6904 inline upb::reffed_ptr<const upb::FieldDef> java_generate_equals_and_hash() { RE TURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_generate_equ als_and_hash) }
7131 } 6905 inline upb::reffed_ptr<const upb::FieldDef> java_generic_services() { RETURN_REF FED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_generic_services) }
7132 }; 6906 inline upb::reffed_ptr<const upb::FieldDef> java_multiple_files() { RETURN_REFFE D(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_multiple_files) }
7133 6907 inline upb::reffed_ptr<const upb::FieldDef> java_outer_classname() { RETURN_REFF ED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_outer_classname) }
7134 class JSType : public ::upb::reffed_ptr<const ::upb::EnumDef> { 6908 inline upb::reffed_ptr<const upb::FieldDef> java_package() { RETURN_REFFED(upb:: FieldDef, upbdefs_google_protobuf_FileOptions_java_package) }
7135 public: 6909 inline upb::reffed_ptr<const upb::FieldDef> optimize_for() { RETURN_REFFED(upb:: FieldDef, upbdefs_google_protobuf_FileOptions_optimize_for) }
7136 JSType(const ::upb::EnumDef* e, const void *ref_donor = NULL) 6910 inline upb::reffed_ptr<const upb::FieldDef> py_generic_services() { RETURN_REFFE D(upb::FieldDef, upbdefs_google_protobuf_FileOptions_py_generic_services) }
7137 : reffed_ptr(e, ref_donor) { 6911 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF ED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_uninterpreted_option) }
7138 UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_JSType_is(e)); 6912 inline upb::reffed_ptr<const upb::EnumDef> OptimizeMode() { RETURN_REFFED(upb::E numDef, upbdefs_google_protobuf_FileOptions_OptimizeMode) }
7139 } 6913 } /* namespace FileOptions */
7140 static JSType get() { 6914 } /* namespace protobuf */
7141 const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_JSType_get( &e); 6915 } /* namespace google */
7142 return JSType(e, &e); 6916
7143 } 6917 namespace google {
7144 }; 6918 namespace protobuf {
7145 }; 6919 namespace MessageOptions {
7146 6920 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_MessageOptions) }
7147 class FileDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6921 inline upb::reffed_ptr<const upb::FieldDef> message_set_wire_format() { RETURN_R EFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_message_set_wire_for mat) }
7148 public: 6922 inline upb::reffed_ptr<const upb::FieldDef> no_standard_descriptor_accessor() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_no_standard_ descriptor_accessor) }
7149 FileDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) 6923 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF ED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_uninterpreted_option) }
7150 : reffed_ptr(m, ref_donor) { 6924 } /* namespace MessageOptions */
7151 UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); 6925 } /* namespace protobuf */
7152 } 6926 } /* namespace google */
7153 6927
7154 static FileDescriptorProto get() { 6928 namespace google {
7155 const ::upb::MessageDef* m = upbdefs_google_protobuf_FileDescriptorProto_get (&m); 6929 namespace protobuf {
7156 return FileDescriptorProto(m, &m); 6930 namespace MethodDescriptorProto {
7157 } 6931 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_MethodDescriptorProto) }
7158 }; 6932 inline upb::reffed_ptr<const upb::FieldDef> input_type() { RETURN_REFFED(upb::Fi eldDef, upbdefs_google_protobuf_MethodDescriptorProto_input_type) }
7159 6933 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_MethodDescriptorProto_name) }
7160 class FileDescriptorSet : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6934 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field Def, upbdefs_google_protobuf_MethodDescriptorProto_options) }
7161 public: 6935 inline upb::reffed_ptr<const upb::FieldDef> output_type() { RETURN_REFFED(upb::F ieldDef, upbdefs_google_protobuf_MethodDescriptorProto_output_type) }
7162 FileDescriptorSet(const ::upb::MessageDef* m, const void *ref_donor = NULL) 6936 } /* namespace MethodDescriptorProto */
7163 : reffed_ptr(m, ref_donor) { 6937 } /* namespace protobuf */
7164 UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorSet_is(m)); 6938 } /* namespace google */
7165 } 6939
7166 6940 namespace google {
7167 static FileDescriptorSet get() { 6941 namespace protobuf {
7168 const ::upb::MessageDef* m = upbdefs_google_protobuf_FileDescriptorSet_get(& m); 6942 namespace MethodOptions {
7169 return FileDescriptorSet(m, &m); 6943 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_MethodOptions) }
7170 } 6944 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF ED(upb::FieldDef, upbdefs_google_protobuf_MethodOptions_uninterpreted_option) }
7171 }; 6945 } /* namespace MethodOptions */
7172 6946 } /* namespace protobuf */
7173 class FileOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6947 } /* namespace google */
7174 public: 6948
7175 FileOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) 6949 namespace google {
7176 : reffed_ptr(m, ref_donor) { 6950 namespace protobuf {
7177 UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); 6951 namespace ServiceDescriptorProto {
7178 } 6952 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_ServiceDescriptorProto) }
7179 6953 inline upb::reffed_ptr<const upb::FieldDef> method() { RETURN_REFFED(upb::FieldD ef, upbdefs_google_protobuf_ServiceDescriptorProto_method) }
7180 static FileOptions get() { 6954 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_ServiceDescriptorProto_name) }
7181 const ::upb::MessageDef* m = upbdefs_google_protobuf_FileOptions_get(&m); 6955 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field Def, upbdefs_google_protobuf_ServiceDescriptorProto_options) }
7182 return FileOptions(m, &m); 6956 } /* namespace ServiceDescriptorProto */
7183 } 6957 } /* namespace protobuf */
7184 6958 } /* namespace google */
7185 class OptimizeMode : public ::upb::reffed_ptr<const ::upb::EnumDef> { 6959
7186 public: 6960 namespace google {
7187 OptimizeMode(const ::upb::EnumDef* e, const void *ref_donor = NULL) 6961 namespace protobuf {
7188 : reffed_ptr(e, ref_donor) { 6962 namespace ServiceOptions {
7189 UPB_ASSERT(upbdefs_google_protobuf_FileOptions_OptimizeMode_is(e)); 6963 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_ServiceOptions) }
7190 } 6964 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF ED(upb::FieldDef, upbdefs_google_protobuf_ServiceOptions_uninterpreted_option) }
7191 static OptimizeMode get() { 6965 } /* namespace ServiceOptions */
7192 const ::upb::EnumDef* e = upbdefs_google_protobuf_FileOptions_OptimizeMode _get(&e); 6966 } /* namespace protobuf */
7193 return OptimizeMode(e, &e); 6967 } /* namespace google */
7194 } 6968
7195 }; 6969 namespace google {
7196 }; 6970 namespace protobuf {
7197 6971 namespace SourceCodeInfo {
7198 class MessageOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6972 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_SourceCodeInfo) }
7199 public: 6973 inline upb::reffed_ptr<const upb::FieldDef> location() { RETURN_REFFED(upb::Fiel dDef, upbdefs_google_protobuf_SourceCodeInfo_location) }
7200 MessageOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) 6974 } /* namespace SourceCodeInfo */
7201 : reffed_ptr(m, ref_donor) { 6975 } /* namespace protobuf */
7202 UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); 6976 } /* namespace google */
7203 } 6977
7204 6978 namespace google {
7205 static MessageOptions get() { 6979 namespace protobuf {
7206 const ::upb::MessageDef* m = upbdefs_google_protobuf_MessageOptions_get(&m); 6980 namespace SourceCodeInfo {
7207 return MessageOptions(m, &m); 6981 namespace Location {
7208 } 6982 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_SourceCodeInfo_Location) }
7209 }; 6983 inline upb::reffed_ptr<const upb::FieldDef> leading_comments() { RETURN_REFFED(u pb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_leading_comments) }
7210 6984 inline upb::reffed_ptr<const upb::FieldDef> path() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_SourceCodeInfo_Location_path) }
7211 class MethodDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6985 inline upb::reffed_ptr<const upb::FieldDef> span() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_SourceCodeInfo_Location_span) }
7212 public: 6986 inline upb::reffed_ptr<const upb::FieldDef> trailing_comments() { RETURN_REFFED( upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_trailing_comments ) }
7213 MethodDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL ) 6987 } /* namespace Location */
7214 : reffed_ptr(m, ref_donor) { 6988 } /* namespace SourceCodeInfo */
7215 UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); 6989 } /* namespace protobuf */
7216 } 6990 } /* namespace google */
7217 6991
7218 static MethodDescriptorProto get() { 6992 namespace google {
7219 const ::upb::MessageDef* m = upbdefs_google_protobuf_MethodDescriptorProto_g et(&m); 6993 namespace protobuf {
7220 return MethodDescriptorProto(m, &m); 6994 namespace UninterpretedOption {
7221 } 6995 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_UninterpretedOption) }
7222 }; 6996 inline upb::reffed_ptr<const upb::FieldDef> aggregate_value() { RETURN_REFFED(up b::FieldDef, upbdefs_google_protobuf_UninterpretedOption_aggregate_value) }
7223 6997 inline upb::reffed_ptr<const upb::FieldDef> double_value() { RETURN_REFFED(upb:: FieldDef, upbdefs_google_protobuf_UninterpretedOption_double_value) }
7224 class MethodOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { 6998 inline upb::reffed_ptr<const upb::FieldDef> identifier_value() { RETURN_REFFED(u pb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_identifier_value) }
7225 public: 6999 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef , upbdefs_google_protobuf_UninterpretedOption_name) }
7226 MethodOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) 7000 inline upb::reffed_ptr<const upb::FieldDef> negative_int_value() { RETURN_REFFED (upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_negative_int_value) }
7227 : reffed_ptr(m, ref_donor) { 7001 inline upb::reffed_ptr<const upb::FieldDef> positive_int_value() { RETURN_REFFED (upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_positive_int_value) }
7228 UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)); 7002 inline upb::reffed_ptr<const upb::FieldDef> string_value() { RETURN_REFFED(upb:: FieldDef, upbdefs_google_protobuf_UninterpretedOption_string_value) }
7229 } 7003 } /* namespace UninterpretedOption */
7230 7004 } /* namespace protobuf */
7231 static MethodOptions get() { 7005 } /* namespace google */
7232 const ::upb::MessageDef* m = upbdefs_google_protobuf_MethodOptions_get(&m); 7006
7233 return MethodOptions(m, &m); 7007 namespace google {
7234 } 7008 namespace protobuf {
7235 }; 7009 namespace UninterpretedOption {
7236 7010 namespace NamePart {
7237 class OneofDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { 7011 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb:: MessageDef, upbdefs_google_protobuf_UninterpretedOption_NamePart) }
7238 public: 7012 inline upb::reffed_ptr<const upb::FieldDef> is_extension() { RETURN_REFFED(upb:: FieldDef, upbdefs_google_protobuf_UninterpretedOption_NamePart_is_extension) }
7239 OneofDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) 7013 inline upb::reffed_ptr<const upb::FieldDef> name_part() { RETURN_REFFED(upb::Fie ldDef, upbdefs_google_protobuf_UninterpretedOption_NamePart_name_part) }
7240 : reffed_ptr(m, ref_donor) { 7014 } /* namespace NamePart */
7241 UPB_ASSERT(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); 7015 } /* namespace UninterpretedOption */
7242 } 7016 } /* namespace protobuf */
7243 7017 } /* namespace google */
7244 static OneofDescriptorProto get() { 7018
7245 const ::upb::MessageDef* m = upbdefs_google_protobuf_OneofDescriptorProto_ge t(&m);
7246 return OneofDescriptorProto(m, &m);
7247 }
7248 };
7249
7250 class ServiceDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7251 public:
7252 ServiceDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NUL L)
7253 : reffed_ptr(m, ref_donor) {
7254 UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m));
7255 }
7256
7257 static ServiceDescriptorProto get() {
7258 const ::upb::MessageDef* m = upbdefs_google_protobuf_ServiceDescriptorProto_ get(&m);
7259 return ServiceDescriptorProto(m, &m);
7260 }
7261 };
7262
7263 class ServiceOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7264 public:
7265 ServiceOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7266 : reffed_ptr(m, ref_donor) {
7267 UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m));
7268 }
7269
7270 static ServiceOptions get() {
7271 const ::upb::MessageDef* m = upbdefs_google_protobuf_ServiceOptions_get(&m);
7272 return ServiceOptions(m, &m);
7273 }
7274 };
7275
7276 class SourceCodeInfo : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7277 public:
7278 SourceCodeInfo(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7279 : reffed_ptr(m, ref_donor) {
7280 UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_is(m));
7281 }
7282
7283 static SourceCodeInfo get() {
7284 const ::upb::MessageDef* m = upbdefs_google_protobuf_SourceCodeInfo_get(&m);
7285 return SourceCodeInfo(m, &m);
7286 }
7287
7288 class Location : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7289 public:
7290 Location(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7291 : reffed_ptr(m, ref_donor) {
7292 UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m));
7293 }
7294
7295 static Location get() {
7296 const ::upb::MessageDef* m = upbdefs_google_protobuf_SourceCodeInfo_Locati on_get(&m);
7297 return Location(m, &m);
7298 }
7299 };
7300 };
7301
7302 class UninterpretedOption : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7303 public:
7304 UninterpretedOption(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7305 : reffed_ptr(m, ref_donor) {
7306 UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m));
7307 }
7308
7309 static UninterpretedOption get() {
7310 const ::upb::MessageDef* m = upbdefs_google_protobuf_UninterpretedOption_get (&m);
7311 return UninterpretedOption(m, &m);
7312 }
7313
7314 class NamePart : public ::upb::reffed_ptr<const ::upb::MessageDef> {
7315 public:
7316 NamePart(const ::upb::MessageDef* m, const void *ref_donor = NULL)
7317 : reffed_ptr(m, ref_donor) {
7318 UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m));
7319 }
7320
7321 static NamePart get() {
7322 const ::upb::MessageDef* m = upbdefs_google_protobuf_UninterpretedOption_N amePart_get(&m);
7323 return NamePart(m, &m);
7324 }
7325 };
7326 };
7327
7328 } /* namespace protobuf */
7329 } /* namespace google */
7330 } /* namespace upbdefs */ 7019 } /* namespace upbdefs */
7331 7020
7332 #endif /* __cplusplus */ 7021
7333 7022 #undef RETURN_REFFED
7334 #endif /* UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_ */ 7023 #endif /* __cplusplus */
7024
7025 #endif /* GOOGLE_PROTOBUF_DESCRIPTOR_UPB_H_ */
7335 /* 7026 /*
7336 ** Internal-only definitions for the decoder. 7027 ** Internal-only definitions for the decoder.
7337 */ 7028 */
7338 7029
7339 #ifndef UPB_DECODER_INT_H_ 7030 #ifndef UPB_DECODER_INT_H_
7340 #define UPB_DECODER_INT_H_ 7031 #define UPB_DECODER_INT_H_
7341 7032
7033 #include <stdlib.h>
7342 /* 7034 /*
7343 ** upb::pb::Decoder 7035 ** upb::pb::Decoder
7344 ** 7036 **
7345 ** A high performance, streaming, resumable decoder for the binary protobuf 7037 ** A high performance, streaming, resumable decoder for the binary protobuf
7346 ** format. 7038 ** format.
7347 ** 7039 **
7348 ** This interface works the same regardless of what decoder backend is being 7040 ** This interface works the same regardless of what decoder backend is being
7349 ** used. A client of this class does not need to know whether decoding is using 7041 ** used. A client of this class does not need to know whether decoding is using
7350 ** a JITted decoder (DynASM, LLVM, etc) or an interpreted decoder. By default, 7042 ** a JITted decoder (DynASM, LLVM, etc) or an interpreted decoder. By default,
7351 ** it will always use the fastest available decoder. However, you can call 7043 ** it will always use the fastest available decoder. However, you can call
(...skipping 16 matching lines...) Expand all
7368 } /* namespace upb */ 7060 } /* namespace upb */
7369 #endif 7061 #endif
7370 7062
7371 UPB_DECLARE_TYPE(upb::pb::CodeCache, upb_pbcodecache) 7063 UPB_DECLARE_TYPE(upb::pb::CodeCache, upb_pbcodecache)
7372 UPB_DECLARE_TYPE(upb::pb::Decoder, upb_pbdecoder) 7064 UPB_DECLARE_TYPE(upb::pb::Decoder, upb_pbdecoder)
7373 UPB_DECLARE_TYPE(upb::pb::DecoderMethodOptions, upb_pbdecodermethodopts) 7065 UPB_DECLARE_TYPE(upb::pb::DecoderMethodOptions, upb_pbdecodermethodopts)
7374 7066
7375 UPB_DECLARE_DERIVED_TYPE(upb::pb::DecoderMethod, upb::RefCounted, 7067 UPB_DECLARE_DERIVED_TYPE(upb::pb::DecoderMethod, upb::RefCounted,
7376 upb_pbdecodermethod, upb_refcounted) 7068 upb_pbdecodermethod, upb_refcounted)
7377 7069
7378 /* The maximum number of bytes we are required to buffer internally between
7379 * calls to the decoder. The value is 14: a 5 byte unknown tag plus ten-byte
7380 * varint, less one because we are buffering an incomplete value.
7381 *
7382 * Should only be used by unit tests. */
7383 #define UPB_DECODER_MAX_RESIDUAL_BYTES 14
7384
7385 #ifdef __cplusplus 7070 #ifdef __cplusplus
7386 7071
7387 /* The parameters one uses to construct a DecoderMethod. 7072 /* The parameters one uses to construct a DecoderMethod.
7388 * TODO(haberman): move allowjit here? Seems more convenient for users. 7073 * TODO(haberman): move allowjit here? Seems more convenient for users.
7389 * TODO(haberman): move this to be heap allocated for ABI stability. */ 7074 * TODO(haberman): move this to be heap allocated for ABI stability. */
7390 class upb::pb::DecoderMethodOptions { 7075 class upb::pb::DecoderMethodOptions {
7391 public: 7076 public:
7392 /* Parameter represents the destination handlers that this method will push 7077 /* Parameter represents the destination handlers that this method will push
7393 * to. */ 7078 * to. */
7394 explicit DecoderMethodOptions(const Handlers* dest_handlers); 7079 explicit DecoderMethodOptions(const Handlers* dest_handlers);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
7431 private: 7116 private:
7432 UPB_DISALLOW_POD_OPS(DecoderMethod, upb::pb::DecoderMethod) 7117 UPB_DISALLOW_POD_OPS(DecoderMethod, upb::pb::DecoderMethod)
7433 }; 7118 };
7434 7119
7435 #endif 7120 #endif
7436 7121
7437 /* Preallocation hint: decoder won't allocate more bytes than this when first 7122 /* Preallocation hint: decoder won't allocate more bytes than this when first
7438 * constructed. This hint may be an overestimate for some build configurations. 7123 * constructed. This hint may be an overestimate for some build configurations.
7439 * But if the decoder library is upgraded without recompiling the application, 7124 * But if the decoder library is upgraded without recompiling the application,
7440 * it may be an underestimate. */ 7125 * it may be an underestimate. */
7441 #define UPB_PB_DECODER_SIZE 4416 7126 #define UPB_PB_DECODER_SIZE 4408
7442 7127
7443 #ifdef __cplusplus 7128 #ifdef __cplusplus
7444 7129
7445 /* A Decoder receives binary protobuf data on its input sink and pushes the 7130 /* A Decoder receives binary protobuf data on its input sink and pushes the
7446 * decoded data to its output sink. */ 7131 * decoded data to its output sink. */
7447 class upb::pb::Decoder { 7132 class upb::pb::Decoder {
7448 public: 7133 public:
7449 /* Constructs a decoder instance for the given method, which must outlive this 7134 /* Constructs a decoder instance for the given method, which must outlive this
7450 * decoder. Any errors during parsing will be set on the given status, which 7135 * decoder. Any errors during parsing will be set on the given status, which
7451 * must also outlive this decoder. 7136 * must also outlive this decoder.
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
7849 7534
7850 /* End of the delimited region, relative to ptr, NULL if not in this buf. */ 7535 /* End of the delimited region, relative to ptr, NULL if not in this buf. */
7851 const char *delim_end; 7536 const char *delim_end;
7852 7537
7853 /* End of the delimited region, relative to ptr, end if not in this buf. */ 7538 /* End of the delimited region, relative to ptr, end if not in this buf. */
7854 const char *data_end; 7539 const char *data_end;
7855 7540
7856 /* Overall stream offset of "buf." */ 7541 /* Overall stream offset of "buf." */
7857 uint64_t bufstart_ofs; 7542 uint64_t bufstart_ofs;
7858 7543
7859 /* Buffer for residual bytes not parsed from the previous buffer. */ 7544 /* Buffer for residual bytes not parsed from the previous buffer.
7860 char residual[UPB_DECODER_MAX_RESIDUAL_BYTES]; 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];
7861 char *residual_end; 7549 char *residual_end;
7862 7550
7863 /* Bytes of data that should be discarded from the input beore we start 7551 /* Bytes of data that should be discarded from the input beore we start
7864 * parsing again. We set this when we internally determine that we can 7552 * parsing again. We set this when we internally determine that we can
7865 * safely skip the next N bytes, but this region extends past the current 7553 * safely skip the next N bytes, but this region extends past the current
7866 * user buffer. */ 7554 * user buffer. */
7867 size_t skip; 7555 size_t skip;
7868 7556
7869 /* Stores the user buffer passed to our decode function. */ 7557 /* Stores the user buffer passed to our decode function. */
7870 const char *buf_param; 7558 const char *buf_param;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
8117 UPB_INLINE size_t upb_varint_size(uint64_t val) { 7805 UPB_INLINE size_t upb_varint_size(uint64_t val) {
8118 char buf[UPB_PB_VARINT_MAX_LEN]; 7806 char buf[UPB_PB_VARINT_MAX_LEN];
8119 return upb_vencode64(val, buf); 7807 return upb_vencode64(val, buf);
8120 } 7808 }
8121 7809
8122 /* Encodes a 32-bit varint, *not* sign-extended. */ 7810 /* Encodes a 32-bit varint, *not* sign-extended. */
8123 UPB_INLINE uint64_t upb_vencode32(uint32_t val) { 7811 UPB_INLINE uint64_t upb_vencode32(uint32_t val) {
8124 char buf[UPB_PB_VARINT_MAX_LEN]; 7812 char buf[UPB_PB_VARINT_MAX_LEN];
8125 size_t bytes = upb_vencode64(val, buf); 7813 size_t bytes = upb_vencode64(val, buf);
8126 uint64_t ret = 0; 7814 uint64_t ret = 0;
8127 UPB_ASSERT(bytes <= 5); 7815 assert(bytes <= 5);
8128 memcpy(&ret, buf, bytes); 7816 memcpy(&ret, buf, bytes);
8129 UPB_ASSERT(ret <= 0xffffffffffU); 7817 assert(ret <= 0xffffffffffU);
8130 return ret; 7818 return ret;
8131 } 7819 }
8132 7820
8133 #ifdef __cplusplus 7821 #ifdef __cplusplus
8134 } /* extern "C" */ 7822 } /* extern "C" */
8135 #endif 7823 #endif
8136 7824
8137 #endif /* UPB_VARINT_DECODER_H_ */ 7825 #endif /* UPB_VARINT_DECODER_H_ */
8138 /* 7826 /*
8139 ** upb::pb::Encoder (upb_pb_encoder) 7827 ** upb::pb::Encoder (upb_pb_encoder)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
8244 ** of data and efficiency is an issue, these may not be the best functions to 7932 ** of data and efficiency is an issue, these may not be the best functions to
8245 ** use (though they are useful for prototyping, before optimizing). 7933 ** use (though they are useful for prototyping, before optimizing).
8246 */ 7934 */
8247 7935
8248 #ifndef UPB_GLUE_H 7936 #ifndef UPB_GLUE_H
8249 #define UPB_GLUE_H 7937 #define UPB_GLUE_H
8250 7938
8251 #include <stdbool.h> 7939 #include <stdbool.h>
8252 7940
8253 #ifdef __cplusplus 7941 #ifdef __cplusplus
8254 #include <vector>
8255
8256 extern "C" { 7942 extern "C" {
8257 #endif 7943 #endif
8258 7944
8259 /* Loads a binary descriptor and returns a NULL-terminated array of unfrozen 7945 /* Loads all defs from the given protobuf binary descriptor, setting default
8260 * filedefs. The caller owns the returned array, which must be freed with 7946 * accessors and a default layout on all messages. The caller owns the
8261 * upb_gfree(). */ 7947 * returned array of defs, which will be of length *n. On error NULL is
8262 upb_filedef **upb_loaddescriptor(const char *buf, size_t n, const void *owner, 7948 * returned and status is set (if non-NULL). */
8263 upb_status *status); 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);
8264 7963
8265 #ifdef __cplusplus 7964 #ifdef __cplusplus
8266 } /* extern "C" */ 7965 } /* extern "C" */
8267 7966
8268 namespace upb { 7967 namespace upb {
8269 7968
8270 inline bool LoadDescriptor(const char* buf, size_t n, Status* status, 7969 /* All routines that load descriptors expect the descriptor to be a
8271 std::vector<reffed_ptr<FileDef> >* files) { 7970 * FileDescriptorSet. */
8272 FileDef** parsed_files = upb_loaddescriptor(buf, n, &parsed_files, status); 7971 inline bool LoadDescriptorFileIntoSymtab(SymbolTable* s, const char *fname,
7972 Status* status) {
7973 return upb_load_descriptor_file_into_symtab(s, fname, status);
7974 }
8273 7975
8274 if (parsed_files) { 7976 inline bool LoadDescriptorIntoSymtab(SymbolTable* s, const char* str,
8275 FileDef** p = parsed_files; 7977 size_t len, Status* status) {
8276 while (*p) { 7978 return upb_load_descriptor_into_symtab(s, str, len, status);
8277 files->push_back(reffed_ptr<FileDef>(*p, &parsed_files));
8278 ++p;
8279 }
8280 free(parsed_files);
8281 return true;
8282 } else {
8283 return false;
8284 }
8285 } 7979 }
8286 7980
8287 /* Templated so it can accept both string and std::string. */ 7981 /* Templated so it can accept both string and std::string. */
8288 template <typename T> 7982 template <typename T>
8289 bool LoadDescriptor(const T& desc, Status* status, 7983 bool LoadDescriptorIntoSymtab(SymbolTable* s, const T& desc, Status* status) {
8290 std::vector<reffed_ptr<FileDef> >* files) { 7984 return upb_load_descriptor_into_symtab(s, desc.c_str(), desc.size(), status);
8291 return LoadDescriptor(desc.c_str(), desc.size(), status, files);
8292 } 7985 }
8293 7986
8294 } /* namespace upb */ 7987 } /* namespace upb */
8295 7988
8296 #endif 7989 #endif
8297 7990
8298 #endif /* UPB_GLUE_H */ 7991 #endif /* UPB_GLUE_H */
8299 /* 7992 /*
8300 ** upb::pb::TextPrinter (upb_textprinter) 7993 ** upb::pb::TextPrinter (upb_textprinter)
8301 ** 7994 **
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
8383 */ 8076 */
8384 8077
8385 #ifndef UPB_JSON_PARSER_H_ 8078 #ifndef UPB_JSON_PARSER_H_
8386 #define UPB_JSON_PARSER_H_ 8079 #define UPB_JSON_PARSER_H_
8387 8080
8388 8081
8389 #ifdef __cplusplus 8082 #ifdef __cplusplus
8390 namespace upb { 8083 namespace upb {
8391 namespace json { 8084 namespace json {
8392 class Parser; 8085 class Parser;
8393 class ParserMethod;
8394 } /* namespace json */ 8086 } /* namespace json */
8395 } /* namespace upb */ 8087 } /* namespace upb */
8396 #endif 8088 #endif
8397 8089
8398 UPB_DECLARE_TYPE(upb::json::Parser, upb_json_parser) 8090 UPB_DECLARE_TYPE(upb::json::Parser, upb_json_parser)
8399 UPB_DECLARE_DERIVED_TYPE(upb::json::ParserMethod, upb::RefCounted,
8400 upb_json_parsermethod, upb_refcounted)
8401 8091
8402 /* upb::json::Parser **********************************************************/ 8092 /* upb::json::Parser **********************************************************/
8403 8093
8404 /* Preallocation hint: parser won't allocate more bytes than this when first 8094 /* Preallocation hint: parser won't allocate more bytes than this when first
8405 * constructed. This hint may be an overestimate for some build configurations. 8095 * constructed. This hint may be an overestimate for some build configurations.
8406 * But if the parser library is upgraded without recompiling the application, 8096 * But if the parser library is upgraded without recompiling the application,
8407 * it may be an underestimate. */ 8097 * it may be an underestimate. */
8408 #define UPB_JSON_PARSER_SIZE 4112 8098 #define UPB_JSON_PARSER_SIZE 3704
8409 8099
8410 #ifdef __cplusplus 8100 #ifdef __cplusplus
8411 8101
8412 /* Parses an incoming BytesStream, pushing the results to the destination 8102 /* Parses an incoming BytesStream, pushing the results to the destination
8413 * sink. */ 8103 * sink. */
8414 class upb::json::Parser { 8104 class upb::json::Parser {
8415 public: 8105 public:
8416 static Parser* Create(Environment* env, const ParserMethod* method, 8106 static Parser* Create(Environment* env, Sink* output);
8417 Sink* output);
8418 8107
8419 BytesSink* input(); 8108 BytesSink* input();
8420 8109
8421 private: 8110 private:
8422 UPB_DISALLOW_POD_OPS(Parser, upb::json::Parser) 8111 UPB_DISALLOW_POD_OPS(Parser, upb::json::Parser)
8423 }; 8112 };
8424 8113
8425 class upb::json::ParserMethod {
8426 public:
8427 /* Include base methods from upb::ReferenceCounted. */
8428 UPB_REFCOUNTED_CPPMETHODS
8429
8430 /* Returns handlers for parsing according to the specified schema. */
8431 static reffed_ptr<const ParserMethod> New(const upb::MessageDef* md);
8432
8433 /* The destination handlers that are statically bound to this method.
8434 * This method is only capable of outputting to a sink that uses these
8435 * handlers. */
8436 const Handlers* dest_handlers() const;
8437
8438 /* The input handlers for this decoder method. */
8439 const BytesHandler* input_handler() const;
8440
8441 private:
8442 UPB_DISALLOW_POD_OPS(ParserMethod, upb::json::ParserMethod)
8443 };
8444
8445 #endif 8114 #endif
8446 8115
8447 UPB_BEGIN_EXTERN_C 8116 UPB_BEGIN_EXTERN_C
8448 8117
8449 upb_json_parser* upb_json_parser_create(upb_env* e, 8118 upb_json_parser *upb_json_parser_create(upb_env *e, upb_sink *output);
8450 const upb_json_parsermethod* m,
8451 upb_sink* output);
8452 upb_bytessink *upb_json_parser_input(upb_json_parser *p); 8119 upb_bytessink *upb_json_parser_input(upb_json_parser *p);
8453 8120
8454 upb_json_parsermethod* upb_json_parsermethod_new(const upb_msgdef* md,
8455 const void* owner);
8456 const upb_handlers *upb_json_parsermethod_desthandlers(
8457 const upb_json_parsermethod *m);
8458 const upb_byteshandler *upb_json_parsermethod_inputhandler(
8459 const upb_json_parsermethod *m);
8460
8461 /* Include refcounted methods like upb_json_parsermethod_ref(). */
8462 UPB_REFCOUNTED_CMETHODS(upb_json_parsermethod, upb_json_parsermethod_upcast)
8463
8464 UPB_END_EXTERN_C 8121 UPB_END_EXTERN_C
8465 8122
8466 #ifdef __cplusplus 8123 #ifdef __cplusplus
8467 8124
8468 namespace upb { 8125 namespace upb {
8469 namespace json { 8126 namespace json {
8470 inline Parser* Parser::Create(Environment* env, const ParserMethod* method, 8127 inline Parser* Parser::Create(Environment* env, Sink* output) {
8471 Sink* output) { 8128 return upb_json_parser_create(env, output);
8472 return upb_json_parser_create(env, method, output);
8473 } 8129 }
8474 inline BytesSink* Parser::input() { 8130 inline BytesSink* Parser::input() {
8475 return upb_json_parser_input(this); 8131 return upb_json_parser_input(this);
8476 } 8132 }
8477
8478 inline const Handlers* ParserMethod::dest_handlers() const {
8479 return upb_json_parsermethod_desthandlers(this);
8480 }
8481 inline const BytesHandler* ParserMethod::input_handler() const {
8482 return upb_json_parsermethod_inputhandler(this);
8483 }
8484 /* static */
8485 inline reffed_ptr<const ParserMethod> ParserMethod::New(
8486 const MessageDef* md) {
8487 const upb_json_parsermethod *m = upb_json_parsermethod_new(md, &m);
8488 return reffed_ptr<const ParserMethod>(m, &m);
8489 }
8490
8491 } /* namespace json */ 8133 } /* namespace json */
8492 } /* namespace upb */ 8134 } /* namespace upb */
8493 8135
8494 #endif 8136 #endif
8495 8137
8496 8138
8497 #endif /* UPB_JSON_PARSER_H_ */ 8139 #endif /* UPB_JSON_PARSER_H_ */
8498 /* 8140 /*
8499 ** upb::json::Printer 8141 ** upb::json::Printer
8500 ** 8142 **
(...skipping 10 matching lines...) Expand all
8511 class Printer; 8153 class Printer;
8512 } /* namespace json */ 8154 } /* namespace json */
8513 } /* namespace upb */ 8155 } /* namespace upb */
8514 #endif 8156 #endif
8515 8157
8516 UPB_DECLARE_TYPE(upb::json::Printer, upb_json_printer) 8158 UPB_DECLARE_TYPE(upb::json::Printer, upb_json_printer)
8517 8159
8518 8160
8519 /* upb::json::Printer *********************************************************/ 8161 /* upb::json::Printer *********************************************************/
8520 8162
8521 #define UPB_JSON_PRINTER_SIZE 176 8163 #define UPB_JSON_PRINTER_SIZE 168
8522 8164
8523 #ifdef __cplusplus 8165 #ifdef __cplusplus
8524 8166
8525 /* Prints an incoming stream of data to a BytesSink in JSON format. */ 8167 /* Prints an incoming stream of data to a BytesSink in JSON format. */
8526 class upb::json::Printer { 8168 class upb::json::Printer {
8527 public: 8169 public:
8528 static Printer* Create(Environment* env, const upb::Handlers* handlers, 8170 static Printer* Create(Environment* env, const upb::Handlers* handlers,
8529 BytesSink* output); 8171 BytesSink* output);
8530 8172
8531 /* The input to the printer. */ 8173 /* The input to the printer. */
8532 Sink* input(); 8174 Sink* input();
8533 8175
8534 /* Returns handlers for printing according to the specified schema. 8176 /* Returns handlers for printing according to the specified schema. */
8535 * If preserve_proto_fieldnames is true, the output JSON will use the 8177 static reffed_ptr<const Handlers> NewHandlers(const upb::MessageDef* md);
8536 * original .proto field names (ie. {"my_field":3}) instead of using
8537 * camelCased names, which is the default: (eg. {"myField":3}). */
8538 static reffed_ptr<const Handlers> NewHandlers(const upb::MessageDef* md,
8539 bool preserve_proto_fieldnames);
8540 8178
8541 static const size_t kSize = UPB_JSON_PRINTER_SIZE; 8179 static const size_t kSize = UPB_JSON_PRINTER_SIZE;
8542 8180
8543 private: 8181 private:
8544 UPB_DISALLOW_POD_OPS(Printer, upb::json::Printer) 8182 UPB_DISALLOW_POD_OPS(Printer, upb::json::Printer)
8545 }; 8183 };
8546 8184
8547 #endif 8185 #endif
8548 8186
8549 UPB_BEGIN_EXTERN_C 8187 UPB_BEGIN_EXTERN_C
8550 8188
8551 /* Native C API. */ 8189 /* Native C API. */
8552 upb_json_printer *upb_json_printer_create(upb_env *e, const upb_handlers *h, 8190 upb_json_printer *upb_json_printer_create(upb_env *e, const upb_handlers *h,
8553 upb_bytessink *output); 8191 upb_bytessink *output);
8554 upb_sink *upb_json_printer_input(upb_json_printer *p); 8192 upb_sink *upb_json_printer_input(upb_json_printer *p);
8555 const upb_handlers *upb_json_printer_newhandlers(const upb_msgdef *md, 8193 const upb_handlers *upb_json_printer_newhandlers(const upb_msgdef *md,
8556 bool preserve_fieldnames,
8557 const void *owner); 8194 const void *owner);
8558 8195
8559 UPB_END_EXTERN_C 8196 UPB_END_EXTERN_C
8560 8197
8561 #ifdef __cplusplus 8198 #ifdef __cplusplus
8562 8199
8563 namespace upb { 8200 namespace upb {
8564 namespace json { 8201 namespace json {
8565 inline Printer* Printer::Create(Environment* env, const upb::Handlers* handlers, 8202 inline Printer* Printer::Create(Environment* env, const upb::Handlers* handlers,
8566 BytesSink* output) { 8203 BytesSink* output) {
8567 return upb_json_printer_create(env, handlers, output); 8204 return upb_json_printer_create(env, handlers, output);
8568 } 8205 }
8569 inline Sink* Printer::input() { return upb_json_printer_input(this); } 8206 inline Sink* Printer::input() { return upb_json_printer_input(this); }
8570 inline reffed_ptr<const Handlers> Printer::NewHandlers( 8207 inline reffed_ptr<const Handlers> Printer::NewHandlers(
8571 const upb::MessageDef *md, bool preserve_proto_fieldnames) { 8208 const upb::MessageDef *md) {
8572 const Handlers* h = upb_json_printer_newhandlers( 8209 const Handlers* h = upb_json_printer_newhandlers(md, &h);
8573 md, preserve_proto_fieldnames, &h);
8574 return reffed_ptr<const Handlers>(h, &h); 8210 return reffed_ptr<const Handlers>(h, &h);
8575 } 8211 }
8576 } /* namespace json */ 8212 } /* namespace json */
8577 } /* namespace upb */ 8213 } /* namespace upb */
8578 8214
8579 #endif 8215 #endif
8580 8216
8581 #endif /* UPB_JSON_TYPED_PRINTER_H_ */ 8217 #endif /* UPB_JSON_TYPED_PRINTER_H_ */
OLDNEW
« no previous file with comments | « third_party/protobuf/php/ext/google/protobuf/type_check.c ('k') | third_party/protobuf/php/ext/google/protobuf/upb.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698