| OLD | NEW |
| 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. |
| 8 ** - upb::EnumDef (upb_enumdef): describes an enum. | 9 ** - upb::EnumDef (upb_enumdef): describes an enum. |
| 9 ** - upb::OneofDef (upb_oneofdef): describes a oneof. | 10 ** - upb::OneofDef (upb_oneofdef): describes a oneof. |
| 10 ** - upb::Def (upb_def): base class of all the others. | 11 ** - upb::Def (upb_def): base class of all the others. |
| 11 ** | 12 ** |
| 12 ** TODO: definitions of services. | 13 ** TODO: definitions of services. |
| 13 ** | 14 ** |
| 14 ** Like upb_refcounted objects, defs are mutable only until frozen, and are | 15 ** Like upb_refcounted objects, defs are mutable only until frozen, and are |
| 15 ** only thread-safe once frozen. | 16 ** only thread-safe once frozen. |
| 16 ** | 17 ** |
| 17 ** This is a mixed C/C++ interface that offers a full API to both languages. | 18 ** This is a mixed C/C++ interface that offers a full API to both languages. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 */ | 73 */ |
| 73 | 74 |
| 74 #ifndef UPB_H_ | 75 #ifndef UPB_H_ |
| 75 #define UPB_H_ | 76 #define UPB_H_ |
| 76 | 77 |
| 77 #include <assert.h> | 78 #include <assert.h> |
| 78 #include <stdarg.h> | 79 #include <stdarg.h> |
| 79 #include <stdbool.h> | 80 #include <stdbool.h> |
| 80 #include <stddef.h> | 81 #include <stddef.h> |
| 81 | 82 |
| 83 #ifdef __cplusplus |
| 84 namespace upb { |
| 85 class Allocator; |
| 86 class Arena; |
| 87 class Environment; |
| 88 class ErrorSpace; |
| 89 class Status; |
| 90 template <int N> class InlinedArena; |
| 91 template <int N> class InlinedEnvironment; |
| 92 } |
| 93 #endif |
| 94 |
| 82 /* UPB_INLINE: inline if possible, emit standalone code if required. */ | 95 /* UPB_INLINE: inline if possible, emit standalone code if required. */ |
| 83 #ifdef __cplusplus | 96 #ifdef __cplusplus |
| 84 #define UPB_INLINE inline | 97 #define UPB_INLINE inline |
| 85 #elif defined (__GNUC__) | 98 #elif defined (__GNUC__) |
| 86 #define UPB_INLINE static __inline__ | 99 #define UPB_INLINE static __inline__ |
| 87 #else | 100 #else |
| 88 #define UPB_INLINE static | 101 #define UPB_INLINE static |
| 89 #endif | 102 #endif |
| 90 | 103 |
| 91 /* Define UPB_BIG_ENDIAN manually if you're on big endian and your compiler | 104 /* 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 Loading... |
| 139 #define UPB_DISALLOW_COPY_AND_ASSIGN(class_name) \ | 152 #define UPB_DISALLOW_COPY_AND_ASSIGN(class_name) \ |
| 140 class_name(const class_name&) = delete; \ | 153 class_name(const class_name&) = delete; \ |
| 141 void operator=(const class_name&) = delete; | 154 void operator=(const class_name&) = delete; |
| 142 #define UPB_DISALLOW_POD_OPS(class_name, full_class_name) \ | 155 #define UPB_DISALLOW_POD_OPS(class_name, full_class_name) \ |
| 143 class_name() = delete; \ | 156 class_name() = delete; \ |
| 144 ~class_name() = delete; \ | 157 ~class_name() = delete; \ |
| 145 UPB_DISALLOW_COPY_AND_ASSIGN(class_name) | 158 UPB_DISALLOW_COPY_AND_ASSIGN(class_name) |
| 146 #define UPB_ASSERT_STDLAYOUT(type) \ | 159 #define UPB_ASSERT_STDLAYOUT(type) \ |
| 147 static_assert(std::is_standard_layout<type>::value, \ | 160 static_assert(std::is_standard_layout<type>::value, \ |
| 148 #type " must be standard layout"); | 161 #type " must be standard layout"); |
| 162 #define UPB_FINAL final |
| 149 #else /* !defined(UPB_CXX11) */ | 163 #else /* !defined(UPB_CXX11) */ |
| 150 #define UPB_DISALLOW_COPY_AND_ASSIGN(class_name) \ | 164 #define UPB_DISALLOW_COPY_AND_ASSIGN(class_name) \ |
| 151 class_name(const class_name&); \ | 165 class_name(const class_name&); \ |
| 152 void operator=(const class_name&); | 166 void operator=(const class_name&); |
| 153 #define UPB_DISALLOW_POD_OPS(class_name, full_class_name) \ | 167 #define UPB_DISALLOW_POD_OPS(class_name, full_class_name) \ |
| 154 class_name(); \ | 168 class_name(); \ |
| 155 ~class_name(); \ | 169 ~class_name(); \ |
| 156 UPB_DISALLOW_COPY_AND_ASSIGN(class_name) | 170 UPB_DISALLOW_COPY_AND_ASSIGN(class_name) |
| 157 #define UPB_ASSERT_STDLAYOUT(type) | 171 #define UPB_ASSERT_STDLAYOUT(type) |
| 172 #define UPB_FINAL |
| 158 #endif | 173 #endif |
| 159 | 174 |
| 160 /* UPB_DECLARE_TYPE() | 175 /* UPB_DECLARE_TYPE() |
| 161 * UPB_DECLARE_DERIVED_TYPE() | 176 * UPB_DECLARE_DERIVED_TYPE() |
| 162 * UPB_DECLARE_DERIVED_TYPE2() | 177 * UPB_DECLARE_DERIVED_TYPE2() |
| 163 * | 178 * |
| 164 * Macros for declaring C and C++ types both, including inheritance. | 179 * Macros for declaring C and C++ types both, including inheritance. |
| 165 * The inheritance doesn't use real C++ inheritance, to stay compatible with C. | 180 * The inheritance doesn't use real C++ inheritance, to stay compatible with C. |
| 166 * | 181 * |
| 167 * These macros also provide upcasts: | 182 * These macros also provide upcasts: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 186 #define UPB_PRIVATE_FOR_CPP private: | 201 #define UPB_PRIVATE_FOR_CPP private: |
| 187 #define UPB_DECLARE_TYPE(cppname, cname) typedef cppname cname; | 202 #define UPB_DECLARE_TYPE(cppname, cname) typedef cppname cname; |
| 188 | 203 |
| 189 #define UPB_DECLARE_DERIVED_TYPE(cppname, cppbase, cname, cbase) \ | 204 #define UPB_DECLARE_DERIVED_TYPE(cppname, cppbase, cname, cbase) \ |
| 190 UPB_DECLARE_TYPE(cppname, cname) \ | 205 UPB_DECLARE_TYPE(cppname, cname) \ |
| 191 UPB_C_UPCASTS(cname, cbase) \ | 206 UPB_C_UPCASTS(cname, cbase) \ |
| 192 namespace upb { \ | 207 namespace upb { \ |
| 193 template <> \ | 208 template <> \ |
| 194 class Pointer<cppname> : public PointerBase<cppname, cppbase> { \ | 209 class Pointer<cppname> : public PointerBase<cppname, cppbase> { \ |
| 195 public: \ | 210 public: \ |
| 196 explicit Pointer(cppname* ptr) : PointerBase(ptr) {} \ | 211 explicit Pointer(cppname* ptr) \ |
| 212 : PointerBase<cppname, cppbase>(ptr) {} \ |
| 197 }; \ | 213 }; \ |
| 198 template <> \ | 214 template <> \ |
| 199 class Pointer<const cppname> \ | 215 class Pointer<const cppname> \ |
| 200 : public PointerBase<const cppname, const cppbase> { \ | 216 : public PointerBase<const cppname, const cppbase> { \ |
| 201 public: \ | 217 public: \ |
| 202 explicit Pointer(const cppname* ptr) : PointerBase(ptr) {} \ | 218 explicit Pointer(const cppname* ptr) \ |
| 219 : PointerBase<const cppname, const cppbase>(ptr) {} \ |
| 203 }; \ | 220 }; \ |
| 204 } | 221 } |
| 205 | 222 |
| 206 #define UPB_DECLARE_DERIVED_TYPE2(cppname, cppbase, cppbase2, cname, cbase, \ | 223 #define UPB_DECLARE_DERIVED_TYPE2(cppname, cppbase, cppbase2, cname, cbase, \ |
| 207 cbase2) \ | 224 cbase2) \ |
| 208 UPB_DECLARE_TYPE(cppname, cname) \ | 225 UPB_DECLARE_TYPE(cppname, cname) \ |
| 209 UPB_C_UPCASTS2(cname, cbase, cbase2) \ | 226 UPB_C_UPCASTS2(cname, cbase, cbase2) \ |
| 210 namespace upb { \ | 227 namespace upb { \ |
| 211 template <> \ | 228 template <> \ |
| 212 class Pointer<cppname> : public PointerBase2<cppname, cppbase, cppbase2> { \ | 229 class Pointer<cppname> : public PointerBase2<cppname, cppbase, cppbase2> { \ |
| 213 public: \ | 230 public: \ |
| 214 explicit Pointer(cppname* ptr) : PointerBase2(ptr) {} \ | 231 explicit Pointer(cppname* ptr) \ |
| 232 : PointerBase2<cppname, cppbase, cppbase2>(ptr) {} \ |
| 215 }; \ | 233 }; \ |
| 216 template <> \ | 234 template <> \ |
| 217 class Pointer<const cppname> \ | 235 class Pointer<const cppname> \ |
| 218 : public PointerBase2<const cppname, const cppbase, const cppbase2> { \ | 236 : public PointerBase2<const cppname, const cppbase, const cppbase2> { \ |
| 219 public: \ | 237 public: \ |
| 220 explicit Pointer(const cppname* ptr) : PointerBase2(ptr) {} \ | 238 explicit Pointer(const cppname* ptr) \ |
| 239 : PointerBase2<const cppname, const cppbase, const cppbase2>(ptr) {} \ |
| 221 }; \ | 240 }; \ |
| 222 } | 241 } |
| 223 | 242 |
| 224 #else /* !defined(__cplusplus) */ | 243 #else /* !defined(__cplusplus) */ |
| 225 | 244 |
| 226 #define UPB_BEGIN_EXTERN_C | 245 #define UPB_BEGIN_EXTERN_C |
| 227 #define UPB_END_EXTERN_C | 246 #define UPB_END_EXTERN_C |
| 228 #define UPB_PRIVATE_FOR_CPP | 247 #define UPB_PRIVATE_FOR_CPP |
| 229 #define UPB_DECLARE_TYPE(cppname, cname) \ | 248 #define UPB_DECLARE_TYPE(cppname, cname) \ |
| 230 struct cname; \ | 249 struct cname; \ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 245 #define UPB_UNUSED(var) (void)var | 264 #define UPB_UNUSED(var) (void)var |
| 246 | 265 |
| 247 /* For asserting something about a variable when the variable is not used for | 266 /* For asserting something about a variable when the variable is not used for |
| 248 * anything else. This prevents "unused variable" warnings when compiling in | 267 * anything else. This prevents "unused variable" warnings when compiling in |
| 249 * debug mode. */ | 268 * debug mode. */ |
| 250 #define UPB_ASSERT_VAR(var, predicate) UPB_UNUSED(var); assert(predicate) | 269 #define UPB_ASSERT_VAR(var, predicate) UPB_UNUSED(var); assert(predicate) |
| 251 | 270 |
| 252 /* Generic function type. */ | 271 /* Generic function type. */ |
| 253 typedef void upb_func(); | 272 typedef void upb_func(); |
| 254 | 273 |
| 274 |
| 255 /* C++ Casts ******************************************************************/ | 275 /* C++ Casts ******************************************************************/ |
| 256 | 276 |
| 257 #ifdef __cplusplus | 277 #ifdef __cplusplus |
| 258 | 278 |
| 259 namespace upb { | 279 namespace upb { |
| 260 | 280 |
| 261 template <class T> class Pointer; | 281 template <class T> class Pointer; |
| 262 | 282 |
| 263 /* Casts to a subclass. The caller must know that cast is correct; an | 283 /* Casts to a subclass. The caller must know that cast is correct; an |
| 264 * incorrect cast will throw an assertion failure in debug mode. | 284 * incorrect cast will throw an assertion failure in debug mode. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 public: | 342 public: |
| 323 explicit PointerBase2(T* ptr) : PointerBase<T, Base>(ptr) {} | 343 explicit PointerBase2(T* ptr) : PointerBase<T, Base>(ptr) {} |
| 324 operator Base2*() { return Pointer<Base>(*this); } | 344 operator Base2*() { return Pointer<Base>(*this); } |
| 325 }; | 345 }; |
| 326 | 346 |
| 327 } | 347 } |
| 328 | 348 |
| 329 #endif | 349 #endif |
| 330 | 350 |
| 331 | 351 |
| 332 /* upb::reffed_ptr ************************************************************/ | 352 /* upb::ErrorSpace ************************************************************/ |
| 333 | 353 |
| 334 #ifdef __cplusplus | 354 /* A upb::ErrorSpace represents some domain of possible error values. This lets |
| 335 | 355 * upb::Status attach specific error codes to operations, like POSIX/C errno, |
| 336 #include <algorithm> /* For std::swap(). */ | 356 * Win32 error codes, etc. Clients who want to know the very specific error |
| 337 | 357 * code can check the error space and then know the type of the integer code. |
| 338 namespace upb { | 358 * |
| 339 | 359 * NOTE: upb::ErrorSpace is currently not used and should be considered |
| 340 /* Provides RAII semantics for upb refcounted objects. Each reffed_ptr owns a | 360 * experimental. It is important primarily in cases where upb is performing |
| 341 * ref on whatever object it points to (if any). */ | 361 * I/O, but upb doesn't currently have any components that do this. */ |
| 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 | |
| 444 | 362 |
| 445 UPB_DECLARE_TYPE(upb::ErrorSpace, upb_errorspace) | 363 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); | |
| 455 | 364 |
| 456 #ifdef __cplusplus | 365 #ifdef __cplusplus |
| 457 class upb::ErrorSpace { | 366 class upb::ErrorSpace { |
| 458 #else | 367 #else |
| 459 struct upb_errorspace { | 368 struct upb_errorspace { |
| 460 #endif | 369 #endif |
| 461 const char *name; | 370 const char *name; |
| 462 /* Should the error message in the status object according to this code. */ | 371 }; |
| 463 void (*set_message)(upb_status* status, int code); | 372 |
| 464 }; | 373 |
| 465 | 374 /* upb::Status ****************************************************************/ |
| 466 #ifdef __cplusplus | 375 |
| 467 | 376 /* upb::Status represents a success or failure status and error message. |
| 468 /* Object representing a success or failure status. | |
| 469 * It owns no resources and allocates no memory, so it should work | 377 * It owns no resources and allocates no memory, so it should work |
| 470 * even in OOM situations. */ | 378 * even in OOM situations. */ |
| 471 | 379 UPB_DECLARE_TYPE(upb::Status, upb_status) |
| 472 class upb::Status { | 380 |
| 473 public: | 381 /* The maximum length of an error message before it will get truncated. */ |
| 474 Status(); | 382 #define UPB_STATUS_MAX_MESSAGE 128 |
| 475 | 383 |
| 476 /* Returns true if there is no error. */ | 384 UPB_BEGIN_EXTERN_C |
| 477 bool ok() const; | 385 |
| 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. */ | |
| 523 const char *upb_status_errmsg(const upb_status *status); | 386 const char *upb_status_errmsg(const upb_status *status); |
| 524 bool upb_ok(const upb_status *status); | 387 bool upb_ok(const upb_status *status); |
| 525 upb_errorspace *upb_status_errspace(const upb_status *status); | 388 upb_errorspace *upb_status_errspace(const upb_status *status); |
| 526 int upb_status_errcode(const upb_status *status); | 389 int upb_status_errcode(const upb_status *status); |
| 527 | 390 |
| 528 /* Any of the functions that write to a status object allow status to be NULL, | 391 /* Any of the functions that write to a status object allow status to be NULL, |
| 529 * to support use cases where the function's caller does not care about the | 392 * to support use cases where the function's caller does not care about the |
| 530 * status message. */ | 393 * status message. */ |
| 531 void upb_status_clear(upb_status *status); | 394 void upb_status_clear(upb_status *status); |
| 532 void upb_status_seterrmsg(upb_status *status, const char *msg); | 395 void upb_status_seterrmsg(upb_status *status, const char *msg); |
| 533 void upb_status_seterrf(upb_status *status, const char *fmt, ...); | 396 void upb_status_seterrf(upb_status *status, const char *fmt, ...); |
| 534 void upb_status_vseterrf(upb_status *status, const char *fmt, va_list args); | 397 void upb_status_vseterrf(upb_status *status, const char *fmt, va_list args); |
| 535 void upb_status_seterrcode(upb_status *status, upb_errorspace *space, int code); | |
| 536 void upb_status_copy(upb_status *to, const upb_status *from); | 398 void upb_status_copy(upb_status *to, const upb_status *from); |
| 537 | 399 |
| 538 #ifdef __cplusplus | 400 UPB_END_EXTERN_C |
| 539 } /* extern "C" */ | 401 |
| 540 | 402 #ifdef __cplusplus |
| 541 namespace upb { | 403 |
| 542 | 404 class upb::Status { |
| 543 /* C++ Wrappers */ | 405 public: |
| 544 inline Status::Status() { Clear(); } | 406 Status() { upb_status_clear(this); } |
| 545 inline bool Status::ok() const { return upb_ok(this); } | 407 |
| 546 inline const char* Status::error_message() const { | 408 /* Returns true if there is no error. */ |
| 547 return upb_status_errmsg(this); | 409 bool ok() const { return upb_ok(this); } |
| 548 } | 410 |
| 549 inline void Status::SetErrorMessage(const char* msg) { | 411 /* Optional error space and code, useful if the caller wants to |
| 550 upb_status_seterrmsg(this, msg); | 412 * programmatically check the specific kind of error. */ |
| 551 } | 413 ErrorSpace* error_space() { return upb_status_errspace(this); } |
| 552 inline void Status::SetFormattedErrorMessage(const char* fmt, ...) { | 414 int error_code() const { return upb_status_errcode(this); } |
| 553 va_list args; | 415 |
| 554 va_start(args, fmt); | 416 /* The returned string is invalidated by any other call into the status. */ |
| 555 upb_status_vseterrf(this, fmt, args); | 417 const char *error_message() const { return upb_status_errmsg(this); } |
| 556 va_end(args); | 418 |
| 557 } | 419 /* The error message will be truncated if it is longer than |
| 558 inline void Status::SetErrorCode(ErrorSpace* space, int code) { | 420 * UPB_STATUS_MAX_MESSAGE-4. */ |
| 559 upb_status_seterrcode(this, space, code); | 421 void SetErrorMessage(const char* msg) { upb_status_seterrmsg(this, msg); } |
| 560 } | 422 void SetFormattedErrorMessage(const char* fmt, ...) { |
| 561 inline void Status::Clear() { upb_status_clear(this); } | 423 va_list args; |
| 562 inline void Status::CopyFrom(const Status& other) { | 424 va_start(args, fmt); |
| 563 upb_status_copy(this, &other); | 425 upb_status_vseterrf(this, fmt, args); |
| 564 } | 426 va_end(args); |
| 565 | 427 } |
| 566 } /* namespace upb */ | 428 |
| 567 | 429 /* Resets the status to a successful state with no message. */ |
| 430 void Clear() { upb_status_clear(this); } |
| 431 |
| 432 void CopyFrom(const Status& other) { upb_status_copy(this, &other); } |
| 433 |
| 434 private: |
| 435 UPB_DISALLOW_COPY_AND_ASSIGN(Status) |
| 436 #else |
| 437 struct upb_status { |
| 568 #endif | 438 #endif |
| 439 bool ok_; |
| 440 |
| 441 /* Specific status code defined by some error space (optional). */ |
| 442 int code_; |
| 443 upb_errorspace *error_space_; |
| 444 |
| 445 /* TODO(haberman): add file/line of error? */ |
| 446 |
| 447 /* Error message; NULL-terminated. */ |
| 448 char msg[UPB_STATUS_MAX_MESSAGE]; |
| 449 }; |
| 450 |
| 451 #define UPB_STATUS_INIT {true, 0, NULL, {0}} |
| 452 |
| 453 |
| 454 /** Built-in error spaces. ****************************************************/ |
| 455 |
| 456 /* Errors raised by upb that we want to be able to detect programmatically. */ |
| 457 typedef enum { |
| 458 UPB_NOMEM /* Can't reuse ENOMEM because it is POSIX, not ISO C. */ |
| 459 } upb_errcode_t; |
| 460 |
| 461 extern upb_errorspace upb_upberr; |
| 462 |
| 463 void upb_upberr_setoom(upb_status *s); |
| 464 |
| 465 /* Since errno is defined by standard C, we define an error space for it in |
| 466 * core upb. Other error spaces should be defined in other, platform-specific |
| 467 * modules. */ |
| 468 |
| 469 extern upb_errorspace upb_errnoerr; |
| 470 |
| 471 |
| 472 /** upb::Allocator ************************************************************/ |
| 473 |
| 474 /* A upb::Allocator is a possibly-stateful allocator object. |
| 475 * |
| 476 * It could either be an arena allocator (which doesn't require individual |
| 477 * free() calls) or a regular malloc() (which does). The client must therefore |
| 478 * free memory unless it knows that the allocator is an arena allocator. */ |
| 479 UPB_DECLARE_TYPE(upb::Allocator, upb_alloc) |
| 480 |
| 481 /* A malloc()/free() function. |
| 482 * If "size" is 0 then the function acts like free(), otherwise it acts like |
| 483 * realloc(). Only "oldsize" bytes from a previous allocation are preserved. */ |
| 484 typedef void *upb_alloc_func(upb_alloc *alloc, void *ptr, size_t oldsize, |
| 485 size_t size); |
| 486 |
| 487 #ifdef __cplusplus |
| 488 |
| 489 class upb::Allocator UPB_FINAL { |
| 490 public: |
| 491 Allocator() {} |
| 492 |
| 493 private: |
| 494 UPB_DISALLOW_COPY_AND_ASSIGN(Allocator) |
| 495 |
| 496 public: |
| 497 #else |
| 498 struct upb_alloc { |
| 499 #endif /* __cplusplus */ |
| 500 upb_alloc_func *func; |
| 501 }; |
| 502 |
| 503 UPB_INLINE void *upb_malloc(upb_alloc *alloc, size_t size) { |
| 504 assert(size > 0); |
| 505 return alloc->func(alloc, NULL, 0, size); |
| 506 } |
| 507 |
| 508 UPB_INLINE void *upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize, |
| 509 size_t size) { |
| 510 assert(size > 0); |
| 511 return alloc->func(alloc, ptr, oldsize, size); |
| 512 } |
| 513 |
| 514 UPB_INLINE void upb_free(upb_alloc *alloc, void *ptr) { |
| 515 alloc->func(alloc, ptr, 0, 0); |
| 516 } |
| 517 |
| 518 /* The global allocator used by upb. Uses the standard malloc()/free(). */ |
| 519 |
| 520 extern upb_alloc upb_alloc_global; |
| 521 |
| 522 /* Functions that hard-code the global malloc. |
| 523 * |
| 524 * We still get benefit because we can put custom logic into our global |
| 525 * allocator, like injecting out-of-memory faults in debug/testing builds. */ |
| 526 |
| 527 UPB_INLINE void *upb_gmalloc(size_t size) { |
| 528 return upb_malloc(&upb_alloc_global, size); |
| 529 } |
| 530 |
| 531 UPB_INLINE void *upb_grealloc(void *ptr, size_t oldsize, size_t size) { |
| 532 return upb_realloc(&upb_alloc_global, ptr, oldsize, size); |
| 533 } |
| 534 |
| 535 UPB_INLINE void upb_gfree(void *ptr) { |
| 536 upb_free(&upb_alloc_global, ptr); |
| 537 } |
| 538 |
| 539 /* upb::Arena *****************************************************************/ |
| 540 |
| 541 /* upb::Arena is a specific allocator implementation that uses arena allocation. |
| 542 * The user provides an allocator that will be used to allocate the underlying |
| 543 * arena blocks. Arenas by nature do not require the individual allocations |
| 544 * to be freed. However the Arena does allow users to register cleanup |
| 545 * functions that will run when the arena is destroyed. |
| 546 * |
| 547 * A upb::Arena is *not* thread-safe. |
| 548 * |
| 549 * You could write a thread-safe arena allocator that satisfies the |
| 550 * upb::Allocator interface, but it would not be as efficient for the |
| 551 * single-threaded case. */ |
| 552 UPB_DECLARE_TYPE(upb::Arena, upb_arena) |
| 553 |
| 554 typedef void upb_cleanup_func(void *ud); |
| 555 |
| 556 #define UPB_ARENA_BLOCK_OVERHEAD (sizeof(size_t)*4) |
| 557 |
| 558 UPB_BEGIN_EXTERN_C |
| 559 |
| 560 void upb_arena_init(upb_arena *a); |
| 561 void upb_arena_init2(upb_arena *a, void *mem, size_t n, upb_alloc *alloc); |
| 562 void upb_arena_uninit(upb_arena *a); |
| 563 upb_alloc *upb_arena_alloc(upb_arena *a); |
| 564 bool upb_arena_addcleanup(upb_arena *a, upb_cleanup_func *func, void *ud); |
| 565 size_t upb_arena_bytesallocated(const upb_arena *a); |
| 566 void upb_arena_setnextblocksize(upb_arena *a, size_t size); |
| 567 void upb_arena_setmaxblocksize(upb_arena *a, size_t size); |
| 568 |
| 569 UPB_END_EXTERN_C |
| 570 |
| 571 #ifdef __cplusplus |
| 572 |
| 573 class upb::Arena { |
| 574 public: |
| 575 /* A simple arena with no initial memory block and the default allocator. */ |
| 576 Arena() { upb_arena_init(this); } |
| 577 |
| 578 /* Constructs an arena with the given initial block which allocates blocks |
| 579 * with the given allocator. The given allocator must outlive the Arena. |
| 580 * |
| 581 * If you pass NULL for the allocator it will default to the global allocator |
| 582 * upb_alloc_global, and NULL/0 for the initial block will cause there to be |
| 583 * no initial block. */ |
| 584 Arena(void *mem, size_t len, Allocator* a) { |
| 585 upb_arena_init2(this, mem, len, a); |
| 586 } |
| 587 |
| 588 ~Arena() { upb_arena_uninit(this); } |
| 589 |
| 590 /* Sets the size of the next block the Arena will request (unless the |
| 591 * requested allocation is larger). Each block will double in size until the |
| 592 * max limit is reached. */ |
| 593 void SetNextBlockSize(size_t size) { upb_arena_setnextblocksize(this, size); } |
| 594 |
| 595 /* Sets the maximum block size. No blocks larger than this will be requested |
| 596 * from the underlying allocator unless individual arena allocations are |
| 597 * larger. */ |
| 598 void SetMaxBlockSize(size_t size) { upb_arena_setmaxblocksize(this, size); } |
| 599 |
| 600 /* Allows this arena to be used as a generic allocator. |
| 601 * |
| 602 * The arena does not need free() calls so when using Arena as an allocator |
| 603 * it is safe to skip them. However they are no-ops so there is no harm in |
| 604 * calling free() either. */ |
| 605 Allocator* allocator() { return upb_arena_alloc(this); } |
| 606 |
| 607 /* Add a cleanup function to run when the arena is destroyed. |
| 608 * Returns false on out-of-memory. */ |
| 609 bool AddCleanup(upb_cleanup_func* func, void* ud) { |
| 610 return upb_arena_addcleanup(this, func, ud); |
| 611 } |
| 612 |
| 613 /* Total number of bytes that have been allocated. It is undefined what |
| 614 * Realloc() does to this counter. */ |
| 615 size_t BytesAllocated() const { |
| 616 return upb_arena_bytesallocated(this); |
| 617 } |
| 618 |
| 619 private: |
| 620 UPB_DISALLOW_COPY_AND_ASSIGN(Arena) |
| 621 |
| 622 #else |
| 623 struct upb_arena { |
| 624 #endif /* __cplusplus */ |
| 625 /* We implement the allocator interface. |
| 626 * This must be the first member of upb_arena! */ |
| 627 upb_alloc alloc; |
| 628 |
| 629 /* Allocator to allocate arena blocks. We are responsible for freeing these |
| 630 * when we are destroyed. */ |
| 631 upb_alloc *block_alloc; |
| 632 |
| 633 size_t bytes_allocated; |
| 634 size_t next_block_size; |
| 635 size_t max_block_size; |
| 636 |
| 637 /* Linked list of blocks. Points to an arena_block, defined in env.c */ |
| 638 void *block_head; |
| 639 |
| 640 /* Cleanup entries. Pointer to a cleanup_ent, defined in env.c */ |
| 641 void *cleanup_head; |
| 642 |
| 643 /* For future expansion, since the size of this struct is exposed to users. */ |
| 644 void *future1; |
| 645 void *future2; |
| 646 }; |
| 647 |
| 648 |
| 649 /* upb::Environment ***********************************************************/ |
| 650 |
| 651 /* A upb::Environment provides a means for injecting malloc and an |
| 652 * error-reporting callback into encoders/decoders. This allows them to be |
| 653 * independent of nearly all assumptions about their actual environment. |
| 654 * |
| 655 * It is also a container for allocating the encoders/decoders themselves that |
| 656 * insulates clients from knowing their actual size. This provides ABI |
| 657 * compatibility even if the size of the objects change. And this allows the |
| 658 * structure definitions to be in the .c files instead of the .h files, making |
| 659 * the .h files smaller and more readable. |
| 660 * |
| 661 * We might want to consider renaming this to "Pipeline" if/when the concept of |
| 662 * a pipeline element becomes more formalized. */ |
| 663 UPB_DECLARE_TYPE(upb::Environment, upb_env) |
| 664 |
| 665 /* A function that receives an error report from an encoder or decoder. The |
| 666 * callback can return true to request that the error should be recovered, but |
| 667 * if the error is not recoverable this has no effect. */ |
| 668 typedef bool upb_error_func(void *ud, const upb_status *status); |
| 669 |
| 670 UPB_BEGIN_EXTERN_C |
| 671 |
| 672 void upb_env_init(upb_env *e); |
| 673 void upb_env_init2(upb_env *e, void *mem, size_t n, upb_alloc *alloc); |
| 674 void upb_env_uninit(upb_env *e); |
| 675 |
| 676 void upb_env_initonly(upb_env *e); |
| 677 |
| 678 upb_arena *upb_env_arena(upb_env *e); |
| 679 bool upb_env_ok(const upb_env *e); |
| 680 void upb_env_seterrorfunc(upb_env *e, upb_error_func *func, void *ud); |
| 681 |
| 682 /* Convenience wrappers around the methods of the contained arena. */ |
| 683 void upb_env_reporterrorsto(upb_env *e, upb_status *s); |
| 684 bool upb_env_reporterror(upb_env *e, const upb_status *s); |
| 685 void *upb_env_malloc(upb_env *e, size_t size); |
| 686 void *upb_env_realloc(upb_env *e, void *ptr, size_t oldsize, size_t size); |
| 687 void upb_env_free(upb_env *e, void *ptr); |
| 688 bool upb_env_addcleanup(upb_env *e, upb_cleanup_func *func, void *ud); |
| 689 size_t upb_env_bytesallocated(const upb_env *e); |
| 690 |
| 691 UPB_END_EXTERN_C |
| 692 |
| 693 #ifdef __cplusplus |
| 694 |
| 695 class upb::Environment { |
| 696 public: |
| 697 /* The given Arena must outlive this environment. */ |
| 698 Environment() { upb_env_initonly(this); } |
| 699 |
| 700 Environment(void *mem, size_t len, Allocator *a) : arena_(mem, len, a) { |
| 701 upb_env_initonly(this); |
| 702 } |
| 703 |
| 704 Arena* arena() { return upb_env_arena(this); } |
| 705 |
| 706 /* Set a custom error reporting function. */ |
| 707 void SetErrorFunction(upb_error_func* func, void* ud) { |
| 708 upb_env_seterrorfunc(this, func, ud); |
| 709 } |
| 710 |
| 711 /* Set the error reporting function to simply copy the status to the given |
| 712 * status and abort. */ |
| 713 void ReportErrorsTo(Status* status) { upb_env_reporterrorsto(this, status); } |
| 714 |
| 715 /* Returns true if all allocations and AddCleanup() calls have succeeded, |
| 716 * and no errors were reported with ReportError() (except ones that recovered |
| 717 * successfully). */ |
| 718 bool ok() const { return upb_env_ok(this); } |
| 719 |
| 720 /* Reports an error to this environment's callback, returning true if |
| 721 * the caller should try to recover. */ |
| 722 bool ReportError(const Status* status) { |
| 723 return upb_env_reporterror(this, status); |
| 724 } |
| 725 |
| 726 private: |
| 727 UPB_DISALLOW_COPY_AND_ASSIGN(Environment) |
| 728 |
| 729 #else |
| 730 struct upb_env { |
| 731 #endif /* __cplusplus */ |
| 732 upb_arena arena_; |
| 733 upb_error_func *error_func_; |
| 734 void *error_ud_; |
| 735 bool ok_; |
| 736 }; |
| 737 |
| 738 |
| 739 /* upb::InlinedArena **********************************************************/ |
| 740 /* upb::InlinedEnvironment ****************************************************/ |
| 741 |
| 742 /* upb::InlinedArena and upb::InlinedEnvironment seed their arenas with a |
| 743 * predefined amount of memory. No heap memory will be allocated until the |
| 744 * initial block is exceeded. |
| 745 * |
| 746 * These types only exist in C++ */ |
| 747 |
| 748 #ifdef __cplusplus |
| 749 |
| 750 template <int N> class upb::InlinedArena : public upb::Arena { |
| 751 public: |
| 752 InlinedArena() : Arena(initial_block_, N, NULL) {} |
| 753 explicit InlinedArena(Allocator* a) : Arena(initial_block_, N, a) {} |
| 754 |
| 755 private: |
| 756 UPB_DISALLOW_COPY_AND_ASSIGN(InlinedArena) |
| 757 |
| 758 char initial_block_[N + UPB_ARENA_BLOCK_OVERHEAD]; |
| 759 }; |
| 760 |
| 761 template <int N> class upb::InlinedEnvironment : public upb::Environment { |
| 762 public: |
| 763 InlinedEnvironment() : Environment(initial_block_, N, NULL) {} |
| 764 explicit InlinedEnvironment(Allocator *a) |
| 765 : Environment(initial_block_, N, a) {} |
| 766 |
| 767 private: |
| 768 UPB_DISALLOW_COPY_AND_ASSIGN(InlinedEnvironment) |
| 769 |
| 770 char initial_block_[N + UPB_ARENA_BLOCK_OVERHEAD]; |
| 771 }; |
| 772 |
| 773 #endif /* __cplusplus */ |
| 774 |
| 775 |
| 569 | 776 |
| 570 #endif /* UPB_H_ */ | 777 #endif /* UPB_H_ */ |
| 571 | 778 |
| 572 #ifdef __cplusplus | 779 #ifdef __cplusplus |
| 573 extern "C" { | 780 extern "C" { |
| 574 #endif | 781 #endif |
| 575 | 782 |
| 576 | 783 |
| 577 /* upb_value ******************************************************************/ | 784 /* upb_value ******************************************************************/ |
| 578 | 785 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 600 #endif | 807 #endif |
| 601 } upb_value; | 808 } upb_value; |
| 602 | 809 |
| 603 #ifdef NDEBUG | 810 #ifdef NDEBUG |
| 604 #define SET_TYPE(dest, val) UPB_UNUSED(val) | 811 #define SET_TYPE(dest, val) UPB_UNUSED(val) |
| 605 #else | 812 #else |
| 606 #define SET_TYPE(dest, val) dest = val | 813 #define SET_TYPE(dest, val) dest = val |
| 607 #endif | 814 #endif |
| 608 | 815 |
| 609 /* Like strdup(), which isn't always available since it's not ANSI C. */ | 816 /* Like strdup(), which isn't always available since it's not ANSI C. */ |
| 610 char *upb_strdup(const char *s); | 817 char *upb_strdup(const char *s, upb_alloc *a); |
| 611 /* Variant that works with a length-delimited rather than NULL-delimited string, | 818 /* Variant that works with a length-delimited rather than NULL-delimited string, |
| 612 * as supported by strtable. */ | 819 * as supported by strtable. */ |
| 613 char *upb_strdup2(const char *s, size_t len); | 820 char *upb_strdup2(const char *s, size_t len, upb_alloc *a); |
| 821 |
| 822 UPB_INLINE char *upb_gstrdup(const char *s) { |
| 823 return upb_strdup(s, &upb_alloc_global); |
| 824 } |
| 614 | 825 |
| 615 UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val, | 826 UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val, |
| 616 upb_ctype_t ctype) { | 827 upb_ctype_t ctype) { |
| 617 v->val = val; | 828 v->val = val; |
| 618 SET_TYPE(v->ctype, ctype); | 829 SET_TYPE(v->ctype, ctype); |
| 619 } | 830 } |
| 620 | 831 |
| 621 UPB_INLINE upb_value _upb_value_val(uint64_t val, upb_ctype_t ctype) { | 832 UPB_INLINE upb_value _upb_value_val(uint64_t val, upb_ctype_t ctype) { |
| 622 upb_value ret; | 833 upb_value ret; |
| 623 _upb_value_setval(&ret, val, ctype); | 834 _upb_value_setval(&ret, val, ctype); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 upb_ctype_t ctype; /* Type of all values. */ | 991 upb_ctype_t ctype; /* Type of all values. */ |
| 781 uint8_t size_lg2; /* Size of the hashtable part is 2^size_lg2 entries. */ | 992 uint8_t size_lg2; /* Size of the hashtable part is 2^size_lg2 entries. */ |
| 782 | 993 |
| 783 /* Hash table entries. | 994 /* Hash table entries. |
| 784 * Making this const isn't entirely accurate; what we really want is for it to | 995 * Making this const isn't entirely accurate; what we really want is for it to |
| 785 * have the same const-ness as the table it's inside. But there's no way to | 996 * have the same const-ness as the table it's inside. But there's no way to |
| 786 * declare that in C. So we have to make it const so that we can statically | 997 * declare that in C. So we have to make it const so that we can statically |
| 787 * initialize const hash tables. Then we cast away const when we have to. | 998 * initialize const hash tables. Then we cast away const when we have to. |
| 788 */ | 999 */ |
| 789 const upb_tabent *entries; | 1000 const upb_tabent *entries; |
| 1001 |
| 1002 #ifndef NDEBUG |
| 1003 /* This table's allocator. We make the user pass it in to every relevant |
| 1004 * function and only use this to check it in debug mode. We do this solely |
| 1005 * to keep upb_table as small as possible. This might seem slightly paranoid |
| 1006 * but the plan is to use upb_table for all map fields and extension sets in |
| 1007 * a forthcoming message representation, so there could be a lot of these. |
| 1008 * If this turns out to be too annoying later, we can change it (since this |
| 1009 * is an internal-only header file). */ |
| 1010 upb_alloc *alloc; |
| 1011 #endif |
| 790 } upb_table; | 1012 } upb_table; |
| 791 | 1013 |
| 1014 #ifdef NDEBUG |
| 1015 # define UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries) \ |
| 1016 {count, mask, ctype, size_lg2, entries} |
| 1017 #else |
| 1018 # ifdef UPB_DEBUG_REFS |
| 1019 /* At the moment the only mutable tables we statically initialize are debug |
| 1020 * ref tables. */ |
| 1021 # define UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries) \ |
| 1022 {count, mask, ctype, size_lg2, entries, &upb_alloc_debugrefs} |
| 1023 # else |
| 1024 # define UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries) \ |
| 1025 {count, mask, ctype, size_lg2, entries, NULL} |
| 1026 # endif |
| 1027 #endif |
| 1028 |
| 792 typedef struct { | 1029 typedef struct { |
| 793 upb_table t; | 1030 upb_table t; |
| 794 } upb_strtable; | 1031 } upb_strtable; |
| 795 | 1032 |
| 796 #define UPB_STRTABLE_INIT(count, mask, ctype, size_lg2, entries) \ | 1033 #define UPB_STRTABLE_INIT(count, mask, ctype, size_lg2, entries) \ |
| 797 {{count, mask, ctype, size_lg2, entries}} | 1034 {UPB_TABLE_INIT(count, mask, ctype, size_lg2, entries)} |
| 798 | 1035 |
| 799 #define UPB_EMPTY_STRTABLE_INIT(ctype) \ | 1036 #define UPB_EMPTY_STRTABLE_INIT(ctype) \ |
| 800 UPB_STRTABLE_INIT(0, 0, ctype, 0, NULL) | 1037 UPB_STRTABLE_INIT(0, 0, ctype, 0, NULL) |
| 801 | 1038 |
| 802 typedef struct { | 1039 typedef struct { |
| 803 upb_table t; /* For entries that don't fit in the array part. */ | 1040 upb_table t; /* For entries that don't fit in the array part. */ |
| 804 const upb_tabval *array; /* Array part of the table. See const note above. */ | 1041 const upb_tabval *array; /* Array part of the table. See const note above. */ |
| 805 size_t array_size; /* Array part size. */ | 1042 size_t array_size; /* Array part size. */ |
| 806 size_t array_count; /* Array part number of elements. */ | 1043 size_t array_count; /* Array part number of elements. */ |
| 807 } upb_inttable; | 1044 } upb_inttable; |
| 808 | 1045 |
| 809 #define UPB_INTTABLE_INIT(count, mask, ctype, size_lg2, ent, a, asize, acount) \ | 1046 #define UPB_INTTABLE_INIT(count, mask, ctype, size_lg2, ent, a, asize, acount) \ |
| 810 {{count, mask, ctype, size_lg2, ent}, a, asize, acount} | 1047 {UPB_TABLE_INIT(count, mask, ctype, size_lg2, ent), a, asize, acount} |
| 811 | 1048 |
| 812 #define UPB_EMPTY_INTTABLE_INIT(ctype) \ | 1049 #define UPB_EMPTY_INTTABLE_INIT(ctype) \ |
| 813 UPB_INTTABLE_INIT(0, 0, ctype, 0, NULL, NULL, 0, 0) | 1050 UPB_INTTABLE_INIT(0, 0, ctype, 0, NULL, NULL, 0, 0) |
| 814 | 1051 |
| 815 #define UPB_ARRAY_EMPTYENT -1 | 1052 #define UPB_ARRAY_EMPTYENT -1 |
| 816 | 1053 |
| 817 UPB_INLINE size_t upb_table_size(const upb_table *t) { | 1054 UPB_INLINE size_t upb_table_size(const upb_table *t) { |
| 818 if (t->size_lg2 == 0) | 1055 if (t->size_lg2 == 0) |
| 819 return 0; | 1056 return 0; |
| 820 else | 1057 else |
| (...skipping 19 matching lines...) Expand all Loading... |
| 840 static const upb_tabent *upb_getentry(const upb_table *t, uint32_t hash) { | 1077 static const upb_tabent *upb_getentry(const upb_table *t, uint32_t hash) { |
| 841 return t->entries + (hash & t->mask); | 1078 return t->entries + (hash & t->mask); |
| 842 } | 1079 } |
| 843 | 1080 |
| 844 UPB_INLINE bool upb_arrhas(upb_tabval key) { | 1081 UPB_INLINE bool upb_arrhas(upb_tabval key) { |
| 845 return key.val != (uint64_t)-1; | 1082 return key.val != (uint64_t)-1; |
| 846 } | 1083 } |
| 847 | 1084 |
| 848 /* Initialize and uninitialize a table, respectively. If memory allocation | 1085 /* Initialize and uninitialize a table, respectively. If memory allocation |
| 849 * failed, false is returned that the table is uninitialized. */ | 1086 * failed, false is returned that the table is uninitialized. */ |
| 850 bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype); | 1087 bool upb_inttable_init2(upb_inttable *table, upb_ctype_t ctype, upb_alloc *a); |
| 851 bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype); | 1088 bool upb_strtable_init2(upb_strtable *table, upb_ctype_t ctype, upb_alloc *a); |
| 852 void upb_inttable_uninit(upb_inttable *table); | 1089 void upb_inttable_uninit2(upb_inttable *table, upb_alloc *a); |
| 853 void upb_strtable_uninit(upb_strtable *table); | 1090 void upb_strtable_uninit2(upb_strtable *table, upb_alloc *a); |
| 1091 |
| 1092 UPB_INLINE bool upb_inttable_init(upb_inttable *table, upb_ctype_t ctype) { |
| 1093 return upb_inttable_init2(table, ctype, &upb_alloc_global); |
| 1094 } |
| 1095 |
| 1096 UPB_INLINE bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype) { |
| 1097 return upb_strtable_init2(table, ctype, &upb_alloc_global); |
| 1098 } |
| 1099 |
| 1100 UPB_INLINE void upb_inttable_uninit(upb_inttable *table) { |
| 1101 upb_inttable_uninit2(table, &upb_alloc_global); |
| 1102 } |
| 1103 |
| 1104 UPB_INLINE void upb_strtable_uninit(upb_strtable *table) { |
| 1105 upb_strtable_uninit2(table, &upb_alloc_global); |
| 1106 } |
| 854 | 1107 |
| 855 /* Returns the number of values in the table. */ | 1108 /* Returns the number of values in the table. */ |
| 856 size_t upb_inttable_count(const upb_inttable *t); | 1109 size_t upb_inttable_count(const upb_inttable *t); |
| 857 UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) { | 1110 UPB_INLINE size_t upb_strtable_count(const upb_strtable *t) { |
| 858 return t->t.count; | 1111 return t->t.count; |
| 859 } | 1112 } |
| 860 | 1113 |
| 861 /* Inserts the given key into the hashtable with the given value. The key must | 1114 /* Inserts the given key into the hashtable with the given value. The key must |
| 862 * not already exist in the hash table. For string tables, the key must be | 1115 * not already exist in the hash table. For string tables, the key must be |
| 863 * NULL-terminated, and the table will make an internal copy of the key. | 1116 * NULL-terminated, and the table will make an internal copy of the key. |
| 864 * Inttables must not insert a value of UINTPTR_MAX. | 1117 * Inttables must not insert a value of UINTPTR_MAX. |
| 865 * | 1118 * |
| 866 * If a table resize was required but memory allocation failed, false is | 1119 * If a table resize was required but memory allocation failed, false is |
| 867 * returned and the table is unchanged. */ | 1120 * returned and the table is unchanged. */ |
| 868 bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val); | 1121 bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val, |
| 869 bool upb_strtable_insert2(upb_strtable *t, const char *key, size_t len, | 1122 upb_alloc *a); |
| 870 upb_value val); | 1123 bool upb_strtable_insert3(upb_strtable *t, const char *key, size_t len, |
| 1124 upb_value val, upb_alloc *a); |
| 1125 |
| 1126 UPB_INLINE bool upb_inttable_insert(upb_inttable *t, uintptr_t key, |
| 1127 upb_value val) { |
| 1128 return upb_inttable_insert2(t, key, val, &upb_alloc_global); |
| 1129 } |
| 1130 |
| 1131 UPB_INLINE bool upb_strtable_insert2(upb_strtable *t, const char *key, |
| 1132 size_t len, upb_value val) { |
| 1133 return upb_strtable_insert3(t, key, len, val, &upb_alloc_global); |
| 1134 } |
| 871 | 1135 |
| 872 /* For NULL-terminated strings. */ | 1136 /* For NULL-terminated strings. */ |
| 873 UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key, | 1137 UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key, |
| 874 upb_value val) { | 1138 upb_value val) { |
| 875 return upb_strtable_insert2(t, key, strlen(key), val); | 1139 return upb_strtable_insert2(t, key, strlen(key), val); |
| 876 } | 1140 } |
| 877 | 1141 |
| 878 /* Looks up key in this table, returning "true" if the key was found. | 1142 /* Looks up key in this table, returning "true" if the key was found. |
| 879 * If v is non-NULL, copies the value for this key into *v. */ | 1143 * If v is non-NULL, copies the value for this key into *v. */ |
| 880 bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v); | 1144 bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v); |
| 881 bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len, | 1145 bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len, |
| 882 upb_value *v); | 1146 upb_value *v); |
| 883 | 1147 |
| 884 /* For NULL-terminated strings. */ | 1148 /* For NULL-terminated strings. */ |
| 885 UPB_INLINE bool upb_strtable_lookup(const upb_strtable *t, const char *key, | 1149 UPB_INLINE bool upb_strtable_lookup(const upb_strtable *t, const char *key, |
| 886 upb_value *v) { | 1150 upb_value *v) { |
| 887 return upb_strtable_lookup2(t, key, strlen(key), v); | 1151 return upb_strtable_lookup2(t, key, strlen(key), v); |
| 888 } | 1152 } |
| 889 | 1153 |
| 890 /* Removes an item from the table. Returns true if the remove was successful, | 1154 /* Removes an item from the table. Returns true if the remove was successful, |
| 891 * and stores the removed item in *val if non-NULL. */ | 1155 * and stores the removed item in *val if non-NULL. */ |
| 892 bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val); | 1156 bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val); |
| 893 bool upb_strtable_remove2(upb_strtable *t, const char *key, size_t len, | 1157 bool upb_strtable_remove3(upb_strtable *t, const char *key, size_t len, |
| 894 upb_value *val); | 1158 upb_value *val, upb_alloc *alloc); |
| 1159 |
| 1160 UPB_INLINE bool upb_strtable_remove2(upb_strtable *t, const char *key, |
| 1161 size_t len, upb_value *val) { |
| 1162 return upb_strtable_remove3(t, key, len, val, &upb_alloc_global); |
| 1163 } |
| 895 | 1164 |
| 896 /* For NULL-terminated strings. */ | 1165 /* For NULL-terminated strings. */ |
| 897 UPB_INLINE bool upb_strtable_remove(upb_strtable *t, const char *key, | 1166 UPB_INLINE bool upb_strtable_remove(upb_strtable *t, const char *key, |
| 898 upb_value *v) { | 1167 upb_value *v) { |
| 899 return upb_strtable_remove2(t, key, strlen(key), v); | 1168 return upb_strtable_remove2(t, key, strlen(key), v); |
| 900 } | 1169 } |
| 901 | 1170 |
| 902 /* Updates an existing entry in an inttable. If the entry does not exist, | 1171 /* Updates an existing entry in an inttable. If the entry does not exist, |
| 903 * returns false and does nothing. Unlike insert/remove, this does not | 1172 * returns false and does nothing. Unlike insert/remove, this does not |
| 904 * invalidate iterators. */ | 1173 * invalidate iterators. */ |
| 905 bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val); | 1174 bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val); |
| 906 | 1175 |
| 907 /* Handy routines for treating an inttable like a stack. May not be mixed with | 1176 /* Handy routines for treating an inttable like a stack. May not be mixed with |
| 908 * other insert/remove calls. */ | 1177 * other insert/remove calls. */ |
| 909 bool upb_inttable_push(upb_inttable *t, upb_value val); | 1178 bool upb_inttable_push2(upb_inttable *t, upb_value val, upb_alloc *a); |
| 910 upb_value upb_inttable_pop(upb_inttable *t); | 1179 upb_value upb_inttable_pop(upb_inttable *t); |
| 911 | 1180 |
| 1181 UPB_INLINE bool upb_inttable_push(upb_inttable *t, upb_value val) { |
| 1182 return upb_inttable_push2(t, val, &upb_alloc_global); |
| 1183 } |
| 1184 |
| 912 /* Convenience routines for inttables with pointer keys. */ | 1185 /* Convenience routines for inttables with pointer keys. */ |
| 913 bool upb_inttable_insertptr(upb_inttable *t, const void *key, upb_value val); | 1186 bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val, |
| 1187 upb_alloc *a); |
| 914 bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val); | 1188 bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val); |
| 915 bool upb_inttable_lookupptr( | 1189 bool upb_inttable_lookupptr( |
| 916 const upb_inttable *t, const void *key, upb_value *val); | 1190 const upb_inttable *t, const void *key, upb_value *val); |
| 917 | 1191 |
| 1192 UPB_INLINE bool upb_inttable_insertptr(upb_inttable *t, const void *key, |
| 1193 upb_value val) { |
| 1194 return upb_inttable_insertptr2(t, key, val, &upb_alloc_global); |
| 1195 } |
| 1196 |
| 918 /* Optimizes the table for the current set of entries, for both memory use and | 1197 /* Optimizes the table for the current set of entries, for both memory use and |
| 919 * lookup time. Client should call this after all entries have been inserted; | 1198 * lookup time. Client should call this after all entries have been inserted; |
| 920 * inserting more entries is legal, but will likely require a table resize. */ | 1199 * inserting more entries is legal, but will likely require a table resize. */ |
| 921 void upb_inttable_compact(upb_inttable *t); | 1200 void upb_inttable_compact2(upb_inttable *t, upb_alloc *a); |
| 1201 |
| 1202 UPB_INLINE void upb_inttable_compact(upb_inttable *t) { |
| 1203 upb_inttable_compact2(t, &upb_alloc_global); |
| 1204 } |
| 922 | 1205 |
| 923 /* A special-case inlinable version of the lookup routine for 32-bit | 1206 /* A special-case inlinable version of the lookup routine for 32-bit |
| 924 * integers. */ | 1207 * integers. */ |
| 925 UPB_INLINE bool upb_inttable_lookup32(const upb_inttable *t, uint32_t key, | 1208 UPB_INLINE bool upb_inttable_lookup32(const upb_inttable *t, uint32_t key, |
| 926 upb_value *v) { | 1209 upb_value *v) { |
| 927 *v = upb_value_int32(0); /* Silence compiler warnings. */ | 1210 *v = upb_value_int32(0); /* Silence compiler warnings. */ |
| 928 if (key < t->array_size) { | 1211 if (key < t->array_size) { |
| 929 upb_tabval arrval = t->array[key]; | 1212 upb_tabval arrval = t->array[key]; |
| 930 if (upb_arrhas(arrval)) { | 1213 if (upb_arrhas(arrval)) { |
| 931 _upb_value_setval(v, arrval.val, t->t.ctype); | 1214 _upb_value_setval(v, arrval.val, t->t.ctype); |
| 932 return true; | 1215 return true; |
| 933 } else { | 1216 } else { |
| 934 return false; | 1217 return false; |
| 935 } | 1218 } |
| 936 } else { | 1219 } else { |
| 937 const upb_tabent *e; | 1220 const upb_tabent *e; |
| 938 if (t->t.entries == NULL) return false; | 1221 if (t->t.entries == NULL) return false; |
| 939 for (e = upb_getentry(&t->t, upb_inthash(key)); true; e = e->next) { | 1222 for (e = upb_getentry(&t->t, upb_inthash(key)); true; e = e->next) { |
| 940 if ((uint32_t)e->key == key) { | 1223 if ((uint32_t)e->key == key) { |
| 941 _upb_value_setval(v, e->val.val, t->t.ctype); | 1224 _upb_value_setval(v, e->val.val, t->t.ctype); |
| 942 return true; | 1225 return true; |
| 943 } | 1226 } |
| 944 if (e->next == NULL) return false; | 1227 if (e->next == NULL) return false; |
| 945 } | 1228 } |
| 946 } | 1229 } |
| 947 } | 1230 } |
| 948 | 1231 |
| 949 /* Exposed for testing only. */ | 1232 /* Exposed for testing only. */ |
| 950 bool upb_strtable_resize(upb_strtable *t, size_t size_lg2); | 1233 bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_alloc *a); |
| 951 | 1234 |
| 952 /* Iterators ******************************************************************/ | 1235 /* Iterators ******************************************************************/ |
| 953 | 1236 |
| 954 /* Iterators for int and string tables. We are subject to some kind of unusual | 1237 /* Iterators for int and string tables. We are subject to some kind of unusual |
| 955 * design constraints: | 1238 * design constraints: |
| 956 * | 1239 * |
| 957 * For high-level languages: | 1240 * For high-level languages: |
| 958 * - we must be able to guarantee that we don't crash or corrupt memory even if | 1241 * - we must be able to guarantee that we don't crash or corrupt memory even if |
| 959 * the program accesses an invalidated iterator. | 1242 * the program accesses an invalidated iterator. |
| 960 * | 1243 * |
| (...skipping 24 matching lines...) Expand all Loading... |
| 985 */ | 1268 */ |
| 986 | 1269 |
| 987 typedef struct { | 1270 typedef struct { |
| 988 const upb_strtable *t; | 1271 const upb_strtable *t; |
| 989 size_t index; | 1272 size_t index; |
| 990 } upb_strtable_iter; | 1273 } upb_strtable_iter; |
| 991 | 1274 |
| 992 void upb_strtable_begin(upb_strtable_iter *i, const upb_strtable *t); | 1275 void upb_strtable_begin(upb_strtable_iter *i, const upb_strtable *t); |
| 993 void upb_strtable_next(upb_strtable_iter *i); | 1276 void upb_strtable_next(upb_strtable_iter *i); |
| 994 bool upb_strtable_done(const upb_strtable_iter *i); | 1277 bool upb_strtable_done(const upb_strtable_iter *i); |
| 995 const char *upb_strtable_iter_key(upb_strtable_iter *i); | 1278 const char *upb_strtable_iter_key(const upb_strtable_iter *i); |
| 996 size_t upb_strtable_iter_keylength(upb_strtable_iter *i); | 1279 size_t upb_strtable_iter_keylength(const upb_strtable_iter *i); |
| 997 upb_value upb_strtable_iter_value(const upb_strtable_iter *i); | 1280 upb_value upb_strtable_iter_value(const upb_strtable_iter *i); |
| 998 void upb_strtable_iter_setdone(upb_strtable_iter *i); | 1281 void upb_strtable_iter_setdone(upb_strtable_iter *i); |
| 999 bool upb_strtable_iter_isequal(const upb_strtable_iter *i1, | 1282 bool upb_strtable_iter_isequal(const upb_strtable_iter *i1, |
| 1000 const upb_strtable_iter *i2); | 1283 const upb_strtable_iter *i2); |
| 1001 | 1284 |
| 1002 | 1285 |
| 1003 /* upb_inttable_iter **********************************************************/ | 1286 /* upb_inttable_iter **********************************************************/ |
| 1004 | 1287 |
| 1005 /* upb_inttable_iter i; | 1288 /* upb_inttable_iter i; |
| 1006 * upb_inttable_begin(&i, t); | 1289 * upb_inttable_begin(&i, t); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 * the code that originally created the object. | 1322 * the code that originally created the object. |
| 1040 * | 1323 * |
| 1041 * Enabling this requires the application to define upb_lock()/upb_unlock() | 1324 * Enabling this requires the application to define upb_lock()/upb_unlock() |
| 1042 * functions that acquire/release a global mutex (or #define UPB_THREAD_UNSAFE). | 1325 * functions that acquire/release a global mutex (or #define UPB_THREAD_UNSAFE). |
| 1043 * For this reason we don't enable it by default, even in debug builds. | 1326 * For this reason we don't enable it by default, even in debug builds. |
| 1044 */ | 1327 */ |
| 1045 | 1328 |
| 1046 /* #define UPB_DEBUG_REFS */ | 1329 /* #define UPB_DEBUG_REFS */ |
| 1047 | 1330 |
| 1048 #ifdef __cplusplus | 1331 #ifdef __cplusplus |
| 1049 namespace upb { class RefCounted; } | 1332 namespace upb { |
| 1333 class RefCounted; |
| 1334 template <class T> class reffed_ptr; |
| 1335 } |
| 1050 #endif | 1336 #endif |
| 1051 | 1337 |
| 1052 UPB_DECLARE_TYPE(upb::RefCounted, upb_refcounted) | 1338 UPB_DECLARE_TYPE(upb::RefCounted, upb_refcounted) |
| 1053 | 1339 |
| 1054 struct upb_refcounted_vtbl; | 1340 struct upb_refcounted_vtbl; |
| 1055 | 1341 |
| 1056 #ifdef __cplusplus | 1342 #ifdef __cplusplus |
| 1057 | 1343 |
| 1058 class upb::RefCounted { | 1344 class upb::RefCounted { |
| 1059 public: | 1345 public: |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 | 1393 |
| 1108 bool is_frozen; | 1394 bool is_frozen; |
| 1109 | 1395 |
| 1110 #ifdef UPB_DEBUG_REFS | 1396 #ifdef UPB_DEBUG_REFS |
| 1111 upb_inttable *refs; /* Maps owner -> trackedref for incoming refs. */ | 1397 upb_inttable *refs; /* Maps owner -> trackedref for incoming refs. */ |
| 1112 upb_inttable *ref2s; /* Set of targets for outgoing ref2s. */ | 1398 upb_inttable *ref2s; /* Set of targets for outgoing ref2s. */ |
| 1113 #endif | 1399 #endif |
| 1114 }; | 1400 }; |
| 1115 | 1401 |
| 1116 #ifdef UPB_DEBUG_REFS | 1402 #ifdef UPB_DEBUG_REFS |
| 1117 #define UPB_REFCOUNT_INIT(refs, ref2s) \ | 1403 extern upb_alloc upb_alloc_debugrefs; |
| 1118 {&static_refcount, NULL, NULL, 0, true, refs, ref2s} | 1404 #define UPB_REFCOUNT_INIT(vtbl, refs, ref2s) \ |
| 1405 {&static_refcount, NULL, vtbl, 0, true, refs, ref2s} |
| 1119 #else | 1406 #else |
| 1120 #define UPB_REFCOUNT_INIT(refs, ref2s) {&static_refcount, NULL, NULL, 0, true} | 1407 #define UPB_REFCOUNT_INIT(vtbl, refs, ref2s) \ |
| 1408 {&static_refcount, NULL, vtbl, 0, true} |
| 1121 #endif | 1409 #endif |
| 1122 | 1410 |
| 1123 UPB_BEGIN_EXTERN_C | 1411 UPB_BEGIN_EXTERN_C |
| 1124 | 1412 |
| 1125 /* It is better to use tracked refs when possible, for the extra debugging | 1413 /* It is better to use tracked refs when possible, for the extra debugging |
| 1126 * capability. But if this is not possible (because you don't have easy access | 1414 * capability. But if this is not possible (because you don't have easy access |
| 1127 * to a stable pointer value that is associated with the ref), you can pass | 1415 * to a stable pointer value that is associated with the ref), you can pass |
| 1128 * UPB_UNTRACKED_REF instead. */ | 1416 * UPB_UNTRACKED_REF instead. */ |
| 1129 extern const void *UPB_UNTRACKED_REF; | 1417 extern const void *UPB_UNTRACKED_REF; |
| 1130 | 1418 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 } | 1531 } |
| 1244 inline void RefCounted::DonateRef(const void *from, const void *to) const { | 1532 inline void RefCounted::DonateRef(const void *from, const void *to) const { |
| 1245 upb_refcounted_donateref(this, from, to); | 1533 upb_refcounted_donateref(this, from, to); |
| 1246 } | 1534 } |
| 1247 inline void RefCounted::CheckRef(const void *owner) const { | 1535 inline void RefCounted::CheckRef(const void *owner) const { |
| 1248 upb_refcounted_checkref(this, owner); | 1536 upb_refcounted_checkref(this, owner); |
| 1249 } | 1537 } |
| 1250 } /* namespace upb */ | 1538 } /* namespace upb */ |
| 1251 #endif | 1539 #endif |
| 1252 | 1540 |
| 1541 |
| 1542 /* upb::reffed_ptr ************************************************************/ |
| 1543 |
| 1544 #ifdef __cplusplus |
| 1545 |
| 1546 #include <algorithm> /* For std::swap(). */ |
| 1547 |
| 1548 /* Provides RAII semantics for upb refcounted objects. Each reffed_ptr owns a |
| 1549 * ref on whatever object it points to (if any). */ |
| 1550 template <class T> class upb::reffed_ptr { |
| 1551 public: |
| 1552 reffed_ptr() : ptr_(NULL) {} |
| 1553 |
| 1554 /* If ref_donor is NULL, takes a new ref, otherwise adopts from ref_donor. */ |
| 1555 template <class U> |
| 1556 reffed_ptr(U* val, const void* ref_donor = NULL) |
| 1557 : ptr_(upb::upcast(val)) { |
| 1558 if (ref_donor) { |
| 1559 assert(ptr_); |
| 1560 ptr_->DonateRef(ref_donor, this); |
| 1561 } else if (ptr_) { |
| 1562 ptr_->Ref(this); |
| 1563 } |
| 1564 } |
| 1565 |
| 1566 template <class U> |
| 1567 reffed_ptr(const reffed_ptr<U>& other) |
| 1568 : ptr_(upb::upcast(other.get())) { |
| 1569 if (ptr_) ptr_->Ref(this); |
| 1570 } |
| 1571 |
| 1572 reffed_ptr(const reffed_ptr& other) |
| 1573 : ptr_(upb::upcast(other.get())) { |
| 1574 if (ptr_) ptr_->Ref(this); |
| 1575 } |
| 1576 |
| 1577 ~reffed_ptr() { if (ptr_) ptr_->Unref(this); } |
| 1578 |
| 1579 template <class U> |
| 1580 reffed_ptr& operator=(const reffed_ptr<U>& other) { |
| 1581 reset(other.get()); |
| 1582 return *this; |
| 1583 } |
| 1584 |
| 1585 reffed_ptr& operator=(const reffed_ptr& other) { |
| 1586 reset(other.get()); |
| 1587 return *this; |
| 1588 } |
| 1589 |
| 1590 /* TODO(haberman): add C++11 move construction/assignment for greater |
| 1591 * efficiency. */ |
| 1592 |
| 1593 void swap(reffed_ptr& other) { |
| 1594 if (ptr_ == other.ptr_) { |
| 1595 return; |
| 1596 } |
| 1597 |
| 1598 if (ptr_) ptr_->DonateRef(this, &other); |
| 1599 if (other.ptr_) other.ptr_->DonateRef(&other, this); |
| 1600 std::swap(ptr_, other.ptr_); |
| 1601 } |
| 1602 |
| 1603 T& operator*() const { |
| 1604 assert(ptr_); |
| 1605 return *ptr_; |
| 1606 } |
| 1607 |
| 1608 T* operator->() const { |
| 1609 assert(ptr_); |
| 1610 return ptr_; |
| 1611 } |
| 1612 |
| 1613 T* get() const { return ptr_; } |
| 1614 |
| 1615 /* If ref_donor is NULL, takes a new ref, otherwise adopts from ref_donor. */ |
| 1616 template <class U> |
| 1617 void reset(U* ptr = NULL, const void* ref_donor = NULL) { |
| 1618 reffed_ptr(ptr, ref_donor).swap(*this); |
| 1619 } |
| 1620 |
| 1621 template <class U> |
| 1622 reffed_ptr<U> down_cast() { |
| 1623 return reffed_ptr<U>(upb::down_cast<U*>(get())); |
| 1624 } |
| 1625 |
| 1626 template <class U> |
| 1627 reffed_ptr<U> dyn_cast() { |
| 1628 return reffed_ptr<U>(upb::dyn_cast<U*>(get())); |
| 1629 } |
| 1630 |
| 1631 /* Plain release() is unsafe; if we were the only owner, it would leak the |
| 1632 * object. Instead we provide this: */ |
| 1633 T* ReleaseTo(const void* new_owner) { |
| 1634 T* ret = NULL; |
| 1635 ptr_->DonateRef(this, new_owner); |
| 1636 std::swap(ret, ptr_); |
| 1637 return ret; |
| 1638 } |
| 1639 |
| 1640 private: |
| 1641 T* ptr_; |
| 1642 }; |
| 1643 |
| 1644 #endif /* __cplusplus */ |
| 1645 |
| 1253 #endif /* UPB_REFCOUNT_H_ */ | 1646 #endif /* UPB_REFCOUNT_H_ */ |
| 1254 | 1647 |
| 1255 #ifdef __cplusplus | 1648 #ifdef __cplusplus |
| 1256 #include <cstring> | 1649 #include <cstring> |
| 1257 #include <string> | 1650 #include <string> |
| 1258 #include <vector> | 1651 #include <vector> |
| 1259 | 1652 |
| 1260 namespace upb { | 1653 namespace upb { |
| 1261 class Def; | 1654 class Def; |
| 1262 class EnumDef; | 1655 class EnumDef; |
| 1263 class FieldDef; | 1656 class FieldDef; |
| 1657 class FileDef; |
| 1264 class MessageDef; | 1658 class MessageDef; |
| 1265 class OneofDef; | 1659 class OneofDef; |
| 1266 } | 1660 } |
| 1267 #endif | 1661 #endif |
| 1268 | 1662 |
| 1269 UPB_DECLARE_DERIVED_TYPE(upb::Def, upb::RefCounted, upb_def, upb_refcounted) | 1663 UPB_DECLARE_DERIVED_TYPE(upb::Def, upb::RefCounted, upb_def, upb_refcounted) |
| 1664 UPB_DECLARE_DERIVED_TYPE(upb::OneofDef, upb::RefCounted, upb_oneofdef, |
| 1665 upb_refcounted) |
| 1666 UPB_DECLARE_DERIVED_TYPE(upb::FileDef, upb::RefCounted, upb_filedef, |
| 1667 upb_refcounted) |
| 1270 | 1668 |
| 1271 /* The maximum message depth that the type graph can have. This is a resource | 1669 /* The maximum message depth that the type graph can have. This is a resource |
| 1272 * limit for the C stack since we sometimes need to recursively traverse the | 1670 * limit for the C stack since we sometimes need to recursively traverse the |
| 1273 * graph. Cycles are ok; the traversal will stop when it detects a cycle, but | 1671 * graph. Cycles are ok; the traversal will stop when it detects a cycle, but |
| 1274 * we must hit the cycle before the maximum depth is reached. | 1672 * we must hit the cycle before the maximum depth is reached. |
| 1275 * | 1673 * |
| 1276 * If having a single static limit is too inflexible, we can add another variant | 1674 * If having a single static limit is too inflexible, we can add another variant |
| 1277 * of Def::Freeze that allows specifying this as a parameter. */ | 1675 * of Def::Freeze that allows specifying this as a parameter. */ |
| 1278 #define UPB_MAX_MESSAGE_DEPTH 64 | 1676 #define UPB_MAX_MESSAGE_DEPTH 64 |
| 1279 | 1677 |
| 1280 | 1678 |
| 1281 /* upb::Def: base class for defs *********************************************/ | 1679 /* upb::Def: base class for top-level defs ***********************************/ |
| 1282 | 1680 |
| 1283 /* All the different kind of defs we support. These correspond 1:1 with | 1681 /* All the different kind of defs that can be defined at the top-level and put |
| 1284 * declarations in a .proto file. */ | 1682 * in a SymbolTable or appear in a FileDef::defs() list. This excludes some |
| 1683 * defs (like oneofs and files). It only includes fields because they can be |
| 1684 * defined as extensions. */ |
| 1285 typedef enum { | 1685 typedef enum { |
| 1286 UPB_DEF_MSG, | 1686 UPB_DEF_MSG, |
| 1287 UPB_DEF_FIELD, | 1687 UPB_DEF_FIELD, |
| 1288 UPB_DEF_ENUM, | 1688 UPB_DEF_ENUM, |
| 1289 UPB_DEF_ONEOF, | |
| 1290 UPB_DEF_SERVICE, /* Not yet implemented. */ | 1689 UPB_DEF_SERVICE, /* Not yet implemented. */ |
| 1291 UPB_DEF_ANY = -1 /* Wildcard for upb_symtab_get*() */ | 1690 UPB_DEF_ANY = -1 /* Wildcard for upb_symtab_get*() */ |
| 1292 } upb_deftype_t; | 1691 } upb_deftype_t; |
| 1293 | 1692 |
| 1294 #ifdef __cplusplus | 1693 #ifdef __cplusplus |
| 1295 | 1694 |
| 1296 /* The base class of all defs. Its base is upb::RefCounted (use upb::upcast() | 1695 /* The base class of all defs. Its base is upb::RefCounted (use upb::upcast() |
| 1297 * to convert). */ | 1696 * to convert). */ |
| 1298 class upb::Def { | 1697 class upb::Def { |
| 1299 public: | 1698 public: |
| 1300 typedef upb_deftype_t Type; | 1699 typedef upb_deftype_t Type; |
| 1301 | 1700 |
| 1302 Def* Dup(const void *owner) const; | 1701 Def* Dup(const void *owner) const; |
| 1303 | 1702 |
| 1304 /* upb::RefCounted methods like Ref()/Unref(). */ | 1703 /* upb::RefCounted methods like Ref()/Unref(). */ |
| 1305 UPB_REFCOUNTED_CPPMETHODS | 1704 UPB_REFCOUNTED_CPPMETHODS |
| 1306 | 1705 |
| 1307 Type def_type() const; | 1706 Type def_type() const; |
| 1308 | 1707 |
| 1309 /* "fullname" is the def's fully-qualified name (eg. foo.bar.Message). */ | 1708 /* "fullname" is the def's fully-qualified name (eg. foo.bar.Message). */ |
| 1310 const char *full_name() const; | 1709 const char *full_name() const; |
| 1311 | 1710 |
| 1711 /* The final part of a def's name (eg. Message). */ |
| 1712 const char *name() const; |
| 1713 |
| 1312 /* The def must be mutable. Caller retains ownership of fullname. Defs are | 1714 /* The def must be mutable. Caller retains ownership of fullname. Defs are |
| 1313 * not required to have a name; if a def has no name when it is frozen, it | 1715 * not required to have a name; if a def has no name when it is frozen, it |
| 1314 * will remain an anonymous def. On failure, returns false and details in "s" | 1716 * will remain an anonymous def. On failure, returns false and details in "s" |
| 1315 * if non-NULL. */ | 1717 * if non-NULL. */ |
| 1316 bool set_full_name(const char* fullname, upb::Status* s); | 1718 bool set_full_name(const char* fullname, upb::Status* s); |
| 1317 bool set_full_name(const std::string &fullname, upb::Status* s); | 1719 bool set_full_name(const std::string &fullname, upb::Status* s); |
| 1318 | 1720 |
| 1721 /* The file in which this def appears. It is not necessary to add a def to a |
| 1722 * file (and consequently the accessor may return NULL). Set this by calling |
| 1723 * file->Add(def). */ |
| 1724 FileDef* file() const; |
| 1725 |
| 1319 /* Freezes the given defs; this validates all constraints and marks the defs | 1726 /* Freezes the given defs; this validates all constraints and marks the defs |
| 1320 * as frozen (read-only). "defs" may not contain any fielddefs, but fields | 1727 * as frozen (read-only). "defs" may not contain any fielddefs, but fields |
| 1321 * of any msgdefs will be frozen. | 1728 * of any msgdefs will be frozen. |
| 1322 * | 1729 * |
| 1323 * Symbolic references to sub-types and enum defaults must have already been | 1730 * Symbolic references to sub-types and enum defaults must have already been |
| 1324 * resolved. Any mutable defs reachable from any of "defs" must also be in | 1731 * resolved. Any mutable defs reachable from any of "defs" must also be in |
| 1325 * the list; more formally, "defs" must be a transitive closure of mutable | 1732 * the list; more formally, "defs" must be a transitive closure of mutable |
| 1326 * defs. | 1733 * defs. |
| 1327 * | 1734 * |
| 1328 * After this operation succeeds, the finalized defs must only be accessed | 1735 * After this operation succeeds, the finalized defs must only be accessed |
| 1329 * through a const pointer! */ | 1736 * through a const pointer! */ |
| 1330 static bool Freeze(Def* const* defs, int n, Status* status); | 1737 static bool Freeze(Def* const* defs, size_t n, Status* status); |
| 1331 static bool Freeze(const std::vector<Def*>& defs, Status* status); | 1738 static bool Freeze(const std::vector<Def*>& defs, Status* status); |
| 1332 | 1739 |
| 1333 private: | 1740 private: |
| 1334 UPB_DISALLOW_POD_OPS(Def, upb::Def) | 1741 UPB_DISALLOW_POD_OPS(Def, upb::Def) |
| 1335 }; | 1742 }; |
| 1336 | 1743 |
| 1337 #endif /* __cplusplus */ | 1744 #endif /* __cplusplus */ |
| 1338 | 1745 |
| 1339 UPB_BEGIN_EXTERN_C | 1746 UPB_BEGIN_EXTERN_C |
| 1340 | 1747 |
| 1341 /* Native C API. */ | 1748 /* Native C API. */ |
| 1342 upb_def *upb_def_dup(const upb_def *def, const void *owner); | 1749 upb_def *upb_def_dup(const upb_def *def, const void *owner); |
| 1343 | 1750 |
| 1344 /* Include upb_refcounted methods like upb_def_ref()/upb_def_unref(). */ | 1751 /* Include upb_refcounted methods like upb_def_ref()/upb_def_unref(). */ |
| 1345 UPB_REFCOUNTED_CMETHODS(upb_def, upb_def_upcast) | 1752 UPB_REFCOUNTED_CMETHODS(upb_def, upb_def_upcast) |
| 1346 | 1753 |
| 1347 upb_deftype_t upb_def_type(const upb_def *d); | 1754 upb_deftype_t upb_def_type(const upb_def *d); |
| 1348 const char *upb_def_fullname(const upb_def *d); | 1755 const char *upb_def_fullname(const upb_def *d); |
| 1756 const char *upb_def_name(const upb_def *d); |
| 1757 const upb_filedef *upb_def_file(const upb_def *d); |
| 1349 bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s); | 1758 bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s); |
| 1350 bool upb_def_freeze(upb_def *const *defs, int n, upb_status *s); | 1759 bool upb_def_freeze(upb_def *const *defs, size_t n, upb_status *s); |
| 1760 |
| 1761 /* Temporary API: for internal use only. */ |
| 1762 bool _upb_def_validate(upb_def *const*defs, size_t n, upb_status *s); |
| 1351 | 1763 |
| 1352 UPB_END_EXTERN_C | 1764 UPB_END_EXTERN_C |
| 1353 | 1765 |
| 1354 | 1766 |
| 1355 /* upb::Def casts *************************************************************/ | 1767 /* upb::Def casts *************************************************************/ |
| 1356 | 1768 |
| 1357 #ifdef __cplusplus | 1769 #ifdef __cplusplus |
| 1358 #define UPB_CPP_CASTS(cname, cpptype) \ | 1770 #define UPB_CPP_CASTS(cname, cpptype) \ |
| 1359 namespace upb { \ | 1771 namespace upb { \ |
| 1360 template <> \ | 1772 template <> \ |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 UPB_DEF_CASTS(lower, upper, cppname) | 1825 UPB_DEF_CASTS(lower, upper, cppname) |
| 1414 | 1826 |
| 1415 #define UPB_DECLARE_DEF_TYPE(cppname, lower, upper) \ | 1827 #define UPB_DECLARE_DEF_TYPE(cppname, lower, upper) \ |
| 1416 UPB_DECLARE_DERIVED_TYPE2(cppname, upb::Def, upb::RefCounted, \ | 1828 UPB_DECLARE_DERIVED_TYPE2(cppname, upb::Def, upb::RefCounted, \ |
| 1417 upb_ ## lower, upb_def, upb_refcounted) \ | 1829 upb_ ## lower, upb_def, upb_refcounted) \ |
| 1418 UPB_DEF_CASTS(lower, upper, cppname) | 1830 UPB_DEF_CASTS(lower, upper, cppname) |
| 1419 | 1831 |
| 1420 UPB_DECLARE_DEF_TYPE(upb::FieldDef, fielddef, FIELD) | 1832 UPB_DECLARE_DEF_TYPE(upb::FieldDef, fielddef, FIELD) |
| 1421 UPB_DECLARE_DEF_TYPE(upb::MessageDef, msgdef, MSG) | 1833 UPB_DECLARE_DEF_TYPE(upb::MessageDef, msgdef, MSG) |
| 1422 UPB_DECLARE_DEF_TYPE(upb::EnumDef, enumdef, ENUM) | 1834 UPB_DECLARE_DEF_TYPE(upb::EnumDef, enumdef, ENUM) |
| 1423 UPB_DECLARE_DEF_TYPE(upb::OneofDef, oneofdef, ONEOF) | |
| 1424 | 1835 |
| 1425 #undef UPB_DECLARE_DEF_TYPE | 1836 #undef UPB_DECLARE_DEF_TYPE |
| 1426 #undef UPB_DEF_CASTS | 1837 #undef UPB_DEF_CASTS |
| 1427 #undef UPB_CPP_CASTS | 1838 #undef UPB_CPP_CASTS |
| 1428 | 1839 |
| 1429 | 1840 |
| 1430 /* upb::FieldDef **************************************************************/ | 1841 /* upb::FieldDef **************************************************************/ |
| 1431 | 1842 |
| 1432 /* The types a field can have. Note that this list is not identical to the | 1843 /* The types a field can have. Note that this list is not identical to the |
| 1433 * types defined in descriptor.proto, which gives INT32 and SINT32 separate | 1844 * types defined in descriptor.proto, which gives INT32 and SINT32 separate |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 UPB_DESCRIPTOR_TYPE_MESSAGE = 11, | 1887 UPB_DESCRIPTOR_TYPE_MESSAGE = 11, |
| 1477 UPB_DESCRIPTOR_TYPE_BYTES = 12, | 1888 UPB_DESCRIPTOR_TYPE_BYTES = 12, |
| 1478 UPB_DESCRIPTOR_TYPE_UINT32 = 13, | 1889 UPB_DESCRIPTOR_TYPE_UINT32 = 13, |
| 1479 UPB_DESCRIPTOR_TYPE_ENUM = 14, | 1890 UPB_DESCRIPTOR_TYPE_ENUM = 14, |
| 1480 UPB_DESCRIPTOR_TYPE_SFIXED32 = 15, | 1891 UPB_DESCRIPTOR_TYPE_SFIXED32 = 15, |
| 1481 UPB_DESCRIPTOR_TYPE_SFIXED64 = 16, | 1892 UPB_DESCRIPTOR_TYPE_SFIXED64 = 16, |
| 1482 UPB_DESCRIPTOR_TYPE_SINT32 = 17, | 1893 UPB_DESCRIPTOR_TYPE_SINT32 = 17, |
| 1483 UPB_DESCRIPTOR_TYPE_SINT64 = 18 | 1894 UPB_DESCRIPTOR_TYPE_SINT64 = 18 |
| 1484 } upb_descriptortype_t; | 1895 } upb_descriptortype_t; |
| 1485 | 1896 |
| 1897 typedef enum { |
| 1898 UPB_SYNTAX_PROTO2 = 2, |
| 1899 UPB_SYNTAX_PROTO3 = 3 |
| 1900 } upb_syntax_t; |
| 1901 |
| 1486 /* Maximum field number allowed for FieldDefs. This is an inherent limit of the | 1902 /* Maximum field number allowed for FieldDefs. This is an inherent limit of the |
| 1487 * protobuf wire format. */ | 1903 * protobuf wire format. */ |
| 1488 #define UPB_MAX_FIELDNUMBER ((1 << 29) - 1) | 1904 #define UPB_MAX_FIELDNUMBER ((1 << 29) - 1) |
| 1489 | 1905 |
| 1490 #ifdef __cplusplus | 1906 #ifdef __cplusplus |
| 1491 | 1907 |
| 1492 /* A upb_fielddef describes a single field in a message. It is most often | 1908 /* A upb_fielddef describes a single field in a message. It is most often |
| 1493 * found as a part of a upb_msgdef, but can also stand alone to represent | 1909 * found as a part of a upb_msgdef, but can also stand alone to represent |
| 1494 * an extension. | 1910 * an extension. |
| 1495 * | 1911 * |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 /* Functionality from upb::Def. */ | 1946 /* Functionality from upb::Def. */ |
| 1531 const char* full_name() const; | 1947 const char* full_name() const; |
| 1532 | 1948 |
| 1533 bool type_is_set() const; /* set_[descriptor_]type() has been called? */ | 1949 bool type_is_set() const; /* set_[descriptor_]type() has been called? */ |
| 1534 Type type() const; /* Requires that type_is_set() == true. */ | 1950 Type type() const; /* Requires that type_is_set() == true. */ |
| 1535 Label label() const; /* Defaults to UPB_LABEL_OPTIONAL. */ | 1951 Label label() const; /* Defaults to UPB_LABEL_OPTIONAL. */ |
| 1536 const char* name() const; /* NULL if uninitialized. */ | 1952 const char* name() const; /* NULL if uninitialized. */ |
| 1537 uint32_t number() const; /* Returns 0 if uninitialized. */ | 1953 uint32_t number() const; /* Returns 0 if uninitialized. */ |
| 1538 bool is_extension() const; | 1954 bool is_extension() const; |
| 1539 | 1955 |
| 1956 /* Copies the JSON name for this field into the given buffer. Returns the |
| 1957 * actual size of the JSON name, including the NULL terminator. If the |
| 1958 * return value is 0, the JSON name is unset. If the return value is |
| 1959 * greater than len, the JSON name was truncated. The buffer is always |
| 1960 * NULL-terminated if len > 0. |
| 1961 * |
| 1962 * The JSON name always defaults to a camelCased version of the regular |
| 1963 * name. However if the regular name is unset, the JSON name will be unset |
| 1964 * also. |
| 1965 */ |
| 1966 size_t GetJsonName(char* buf, size_t len) const; |
| 1967 |
| 1968 /* Convenience version of the above function which copies the JSON name |
| 1969 * into the given string, returning false if the name is not set. */ |
| 1970 template <class T> |
| 1971 bool GetJsonName(T* str) { |
| 1972 str->resize(GetJsonName(NULL, 0)); |
| 1973 GetJsonName(&(*str)[0], str->size()); |
| 1974 return str->size() > 0; |
| 1975 } |
| 1976 |
| 1540 /* For UPB_TYPE_MESSAGE fields only where is_tag_delimited() == false, | 1977 /* For UPB_TYPE_MESSAGE fields only where is_tag_delimited() == false, |
| 1541 * indicates whether this field should have lazy parsing handlers that yield | 1978 * indicates whether this field should have lazy parsing handlers that yield |
| 1542 * the unparsed string for the submessage. | 1979 * the unparsed string for the submessage. |
| 1543 * | 1980 * |
| 1544 * TODO(haberman): I think we want to move this into a FieldOptions container | 1981 * TODO(haberman): I think we want to move this into a FieldOptions container |
| 1545 * when we add support for custom options (the FieldOptions struct will | 1982 * when we add support for custom options (the FieldOptions struct will |
| 1546 * contain both regular FieldOptions like "lazy" *and* custom options). */ | 1983 * contain both regular FieldOptions like "lazy" *and* custom options). */ |
| 1547 bool lazy() const; | 1984 bool lazy() const; |
| 1548 | 1985 |
| 1549 /* For non-string, non-submessage fields, this indicates whether binary | 1986 /* For non-string, non-submessage fields, this indicates whether binary |
| 1550 * protobufs are encoded in packed or non-packed format. | 1987 * protobufs are encoded in packed or non-packed format. |
| 1551 * | 1988 * |
| 1552 * TODO(haberman): see note above about putting options like this into a | 1989 * TODO(haberman): see note above about putting options like this into a |
| 1553 * FieldOptions container. */ | 1990 * FieldOptions container. */ |
| 1554 bool packed() const; | 1991 bool packed() const; |
| 1555 | 1992 |
| 1556 /* An integer that can be used as an index into an array of fields for | 1993 /* An integer that can be used as an index into an array of fields for |
| 1557 * whatever message this field belongs to. Guaranteed to be less than | 1994 * whatever message this field belongs to. Guaranteed to be less than |
| 1558 * f->containing_type()->field_count(). May only be accessed once the def has | 1995 * f->containing_type()->field_count(). May only be accessed once the def has |
| 1559 * been finalized. */ | 1996 * been finalized. */ |
| 1560 int index() const; | 1997 uint32_t index() const; |
| 1561 | 1998 |
| 1562 /* The MessageDef to which this field belongs. | 1999 /* The MessageDef to which this field belongs. |
| 1563 * | 2000 * |
| 1564 * If this field has been added to a MessageDef, that message can be retrieved | 2001 * If this field has been added to a MessageDef, that message can be retrieved |
| 1565 * directly (this is always the case for frozen FieldDefs). | 2002 * directly (this is always the case for frozen FieldDefs). |
| 1566 * | 2003 * |
| 1567 * If the field has not yet been added to a MessageDef, you can set the name | 2004 * If the field has not yet been added to a MessageDef, you can set the name |
| 1568 * of the containing type symbolically instead. This is mostly useful for | 2005 * of the containing type symbolically instead. This is mostly useful for |
| 1569 * extensions, where the extension is declared separately from the message. */ | 2006 * extensions, where the extension is declared separately from the message. */ |
| 1570 const MessageDef* containing_type() const; | 2007 const MessageDef* containing_type() const; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1582 * appropriately. */ | 2019 * appropriately. */ |
| 1583 DescriptorType descriptor_type() const; | 2020 DescriptorType descriptor_type() const; |
| 1584 | 2021 |
| 1585 /* Convenient field type tests. */ | 2022 /* Convenient field type tests. */ |
| 1586 bool IsSubMessage() const; | 2023 bool IsSubMessage() const; |
| 1587 bool IsString() const; | 2024 bool IsString() const; |
| 1588 bool IsSequence() const; | 2025 bool IsSequence() const; |
| 1589 bool IsPrimitive() const; | 2026 bool IsPrimitive() const; |
| 1590 bool IsMap() const; | 2027 bool IsMap() const; |
| 1591 | 2028 |
| 2029 /* Whether this field must be able to explicitly represent presence: |
| 2030 * |
| 2031 * * This is always false for repeated fields (an empty repeated field is |
| 2032 * equivalent to a repeated field with zero entries). |
| 2033 * |
| 2034 * * This is always true for submessages. |
| 2035 * |
| 2036 * * For other fields, it depends on the message (see |
| 2037 * MessageDef::SetPrimitivesHavePresence()) |
| 2038 */ |
| 2039 bool HasPresence() const; |
| 2040 |
| 1592 /* How integers are encoded. Only meaningful for integer types. | 2041 /* How integers are encoded. Only meaningful for integer types. |
| 1593 * Defaults to UPB_INTFMT_VARIABLE, and is reset when "type" changes. */ | 2042 * Defaults to UPB_INTFMT_VARIABLE, and is reset when "type" changes. */ |
| 1594 IntegerFormat integer_format() const; | 2043 IntegerFormat integer_format() const; |
| 1595 | 2044 |
| 1596 /* Whether a submessage field is tag-delimited or not (if false, then | 2045 /* Whether a submessage field is tag-delimited or not (if false, then |
| 1597 * length-delimited). May only be set when type() == UPB_TYPE_MESSAGE. */ | 2046 * length-delimited). May only be set when type() == UPB_TYPE_MESSAGE. */ |
| 1598 bool is_tag_delimited() const; | 2047 bool is_tag_delimited() const; |
| 1599 | 2048 |
| 1600 /* Returns the non-string default value for this fielddef, which may either | 2049 /* Returns the non-string default value for this fielddef, which may either |
| 1601 * be something the client set explicitly or the "default default" (0 for | 2050 * be something the client set explicitly or the "default default" (0 for |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1683 * MessageDef, and may not be set after that. | 2132 * MessageDef, and may not be set after that. |
| 1684 * | 2133 * |
| 1685 * "name" is the same as full_name()/set_full_name(), but since fielddefs | 2134 * "name" is the same as full_name()/set_full_name(), but since fielddefs |
| 1686 * most often use simple, non-qualified names, we provide this accessor | 2135 * most often use simple, non-qualified names, we provide this accessor |
| 1687 * also. Generally only extensions will want to think of this name as | 2136 * also. Generally only extensions will want to think of this name as |
| 1688 * fully-qualified. */ | 2137 * fully-qualified. */ |
| 1689 bool set_number(uint32_t number, upb::Status* s); | 2138 bool set_number(uint32_t number, upb::Status* s); |
| 1690 bool set_name(const char* name, upb::Status* s); | 2139 bool set_name(const char* name, upb::Status* s); |
| 1691 bool set_name(const std::string& name, upb::Status* s); | 2140 bool set_name(const std::string& name, upb::Status* s); |
| 1692 | 2141 |
| 2142 /* Sets the JSON name to the given string. */ |
| 2143 /* TODO(haberman): implement. Right now only default json_name (camelCase) |
| 2144 * is supported. */ |
| 2145 bool set_json_name(const char* json_name, upb::Status* s); |
| 2146 bool set_json_name(const std::string& name, upb::Status* s); |
| 2147 |
| 2148 /* Clears the JSON name. This will make it revert to its default, which is |
| 2149 * a camelCased version of the regular field name. */ |
| 2150 void clear_json_name(); |
| 2151 |
| 1693 void set_integer_format(IntegerFormat format); | 2152 void set_integer_format(IntegerFormat format); |
| 1694 bool set_tag_delimited(bool tag_delimited, upb::Status* s); | 2153 bool set_tag_delimited(bool tag_delimited, upb::Status* s); |
| 1695 | 2154 |
| 1696 /* Sets default value for the field. The call must exactly match the type | 2155 /* Sets default value for the field. The call must exactly match the type |
| 1697 * of the field. Enum fields may use either setint32 or setstring to set | 2156 * of the field. Enum fields may use either setint32 or setstring to set |
| 1698 * the default numerically or symbolically, respectively, but symbolic | 2157 * the default numerically or symbolically, respectively, but symbolic |
| 1699 * defaults must be resolved before finalizing (see ResolveEnumDefault()). | 2158 * defaults must be resolved before finalizing (see ResolveEnumDefault()). |
| 1700 * | 2159 * |
| 1701 * Changing the type of a field will reset its default. */ | 2160 * Changing the type of a field will reset its default. */ |
| 1702 void set_default_int64(int64_t val); | 2161 void set_default_int64(int64_t val); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1747 | 2206 |
| 1748 bool upb_fielddef_typeisset(const upb_fielddef *f); | 2207 bool upb_fielddef_typeisset(const upb_fielddef *f); |
| 1749 upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f); | 2208 upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f); |
| 1750 upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f); | 2209 upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f); |
| 1751 upb_label_t upb_fielddef_label(const upb_fielddef *f); | 2210 upb_label_t upb_fielddef_label(const upb_fielddef *f); |
| 1752 uint32_t upb_fielddef_number(const upb_fielddef *f); | 2211 uint32_t upb_fielddef_number(const upb_fielddef *f); |
| 1753 const char *upb_fielddef_name(const upb_fielddef *f); | 2212 const char *upb_fielddef_name(const upb_fielddef *f); |
| 1754 bool upb_fielddef_isextension(const upb_fielddef *f); | 2213 bool upb_fielddef_isextension(const upb_fielddef *f); |
| 1755 bool upb_fielddef_lazy(const upb_fielddef *f); | 2214 bool upb_fielddef_lazy(const upb_fielddef *f); |
| 1756 bool upb_fielddef_packed(const upb_fielddef *f); | 2215 bool upb_fielddef_packed(const upb_fielddef *f); |
| 2216 size_t upb_fielddef_getjsonname(const upb_fielddef *f, char *buf, size_t len); |
| 1757 const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f); | 2217 const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f); |
| 1758 const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f); | 2218 const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f); |
| 1759 upb_msgdef *upb_fielddef_containingtype_mutable(upb_fielddef *f); | 2219 upb_msgdef *upb_fielddef_containingtype_mutable(upb_fielddef *f); |
| 1760 const char *upb_fielddef_containingtypename(upb_fielddef *f); | 2220 const char *upb_fielddef_containingtypename(upb_fielddef *f); |
| 1761 upb_intfmt_t upb_fielddef_intfmt(const upb_fielddef *f); | 2221 upb_intfmt_t upb_fielddef_intfmt(const upb_fielddef *f); |
| 1762 uint32_t upb_fielddef_index(const upb_fielddef *f); | 2222 uint32_t upb_fielddef_index(const upb_fielddef *f); |
| 1763 bool upb_fielddef_istagdelim(const upb_fielddef *f); | 2223 bool upb_fielddef_istagdelim(const upb_fielddef *f); |
| 1764 bool upb_fielddef_issubmsg(const upb_fielddef *f); | 2224 bool upb_fielddef_issubmsg(const upb_fielddef *f); |
| 1765 bool upb_fielddef_isstring(const upb_fielddef *f); | 2225 bool upb_fielddef_isstring(const upb_fielddef *f); |
| 1766 bool upb_fielddef_isseq(const upb_fielddef *f); | 2226 bool upb_fielddef_isseq(const upb_fielddef *f); |
| 1767 bool upb_fielddef_isprimitive(const upb_fielddef *f); | 2227 bool upb_fielddef_isprimitive(const upb_fielddef *f); |
| 1768 bool upb_fielddef_ismap(const upb_fielddef *f); | 2228 bool upb_fielddef_ismap(const upb_fielddef *f); |
| 2229 bool upb_fielddef_haspresence(const upb_fielddef *f); |
| 1769 int64_t upb_fielddef_defaultint64(const upb_fielddef *f); | 2230 int64_t upb_fielddef_defaultint64(const upb_fielddef *f); |
| 1770 int32_t upb_fielddef_defaultint32(const upb_fielddef *f); | 2231 int32_t upb_fielddef_defaultint32(const upb_fielddef *f); |
| 1771 uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f); | 2232 uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f); |
| 1772 uint32_t upb_fielddef_defaultuint32(const upb_fielddef *f); | 2233 uint32_t upb_fielddef_defaultuint32(const upb_fielddef *f); |
| 1773 bool upb_fielddef_defaultbool(const upb_fielddef *f); | 2234 bool upb_fielddef_defaultbool(const upb_fielddef *f); |
| 1774 float upb_fielddef_defaultfloat(const upb_fielddef *f); | 2235 float upb_fielddef_defaultfloat(const upb_fielddef *f); |
| 1775 double upb_fielddef_defaultdouble(const upb_fielddef *f); | 2236 double upb_fielddef_defaultdouble(const upb_fielddef *f); |
| 1776 const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len); | 2237 const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len); |
| 1777 bool upb_fielddef_enumhasdefaultint32(const upb_fielddef *f); | 2238 bool upb_fielddef_enumhasdefaultint32(const upb_fielddef *f); |
| 1778 bool upb_fielddef_enumhasdefaultstr(const upb_fielddef *f); | 2239 bool upb_fielddef_enumhasdefaultstr(const upb_fielddef *f); |
| 1779 bool upb_fielddef_hassubdef(const upb_fielddef *f); | 2240 bool upb_fielddef_hassubdef(const upb_fielddef *f); |
| 1780 const upb_def *upb_fielddef_subdef(const upb_fielddef *f); | 2241 const upb_def *upb_fielddef_subdef(const upb_fielddef *f); |
| 1781 const upb_msgdef *upb_fielddef_msgsubdef(const upb_fielddef *f); | 2242 const upb_msgdef *upb_fielddef_msgsubdef(const upb_fielddef *f); |
| 1782 const upb_enumdef *upb_fielddef_enumsubdef(const upb_fielddef *f); | 2243 const upb_enumdef *upb_fielddef_enumsubdef(const upb_fielddef *f); |
| 1783 const char *upb_fielddef_subdefname(const upb_fielddef *f); | 2244 const char *upb_fielddef_subdefname(const upb_fielddef *f); |
| 1784 | 2245 |
| 1785 void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type); | 2246 void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type); |
| 1786 void upb_fielddef_setdescriptortype(upb_fielddef *f, int type); | 2247 void upb_fielddef_setdescriptortype(upb_fielddef *f, int type); |
| 1787 void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label); | 2248 void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label); |
| 1788 bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s); | 2249 bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s); |
| 1789 bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s); | 2250 bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s); |
| 2251 bool upb_fielddef_setjsonname(upb_fielddef *f, const char *name, upb_status *s); |
| 2252 bool upb_fielddef_clearjsonname(upb_fielddef *f); |
| 1790 bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name, | 2253 bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name, |
| 1791 upb_status *s); | 2254 upb_status *s); |
| 1792 void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension); | 2255 void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension); |
| 1793 void upb_fielddef_setlazy(upb_fielddef *f, bool lazy); | 2256 void upb_fielddef_setlazy(upb_fielddef *f, bool lazy); |
| 1794 void upb_fielddef_setpacked(upb_fielddef *f, bool packed); | 2257 void upb_fielddef_setpacked(upb_fielddef *f, bool packed); |
| 1795 void upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt); | 2258 void upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt); |
| 1796 void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim); | 2259 void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim); |
| 1797 void upb_fielddef_setdefaultint64(upb_fielddef *f, int64_t val); | 2260 void upb_fielddef_setdefaultint64(upb_fielddef *f, int64_t val); |
| 1798 void upb_fielddef_setdefaultint32(upb_fielddef *f, int32_t val); | 2261 void upb_fielddef_setdefaultint32(upb_fielddef *f, int32_t val); |
| 1799 void upb_fielddef_setdefaultuint64(upb_fielddef *f, uint64_t val); | 2262 void upb_fielddef_setdefaultuint64(upb_fielddef *f, uint64_t val); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1820 bool upb_fielddef_checkintfmt(int32_t fmt); | 2283 bool upb_fielddef_checkintfmt(int32_t fmt); |
| 1821 | 2284 |
| 1822 UPB_END_EXTERN_C | 2285 UPB_END_EXTERN_C |
| 1823 | 2286 |
| 1824 | 2287 |
| 1825 /* upb::MessageDef ************************************************************/ | 2288 /* upb::MessageDef ************************************************************/ |
| 1826 | 2289 |
| 1827 typedef upb_inttable_iter upb_msg_field_iter; | 2290 typedef upb_inttable_iter upb_msg_field_iter; |
| 1828 typedef upb_strtable_iter upb_msg_oneof_iter; | 2291 typedef upb_strtable_iter upb_msg_oneof_iter; |
| 1829 | 2292 |
| 2293 /* Well-known field tag numbers for map-entry messages. */ |
| 2294 #define UPB_MAPENTRY_KEY 1 |
| 2295 #define UPB_MAPENTRY_VALUE 2 |
| 2296 |
| 1830 #ifdef __cplusplus | 2297 #ifdef __cplusplus |
| 1831 | 2298 |
| 1832 /* Structure that describes a single .proto message type. | 2299 /* Structure that describes a single .proto message type. |
| 1833 * | 2300 * |
| 1834 * Its base class is upb::Def (use upb::upcast() to convert). */ | 2301 * Its base class is upb::Def (use upb::upcast() to convert). */ |
| 1835 class upb::MessageDef { | 2302 class upb::MessageDef { |
| 1836 public: | 2303 public: |
| 1837 /* Returns NULL if memory allocation failed. */ | 2304 /* Returns NULL if memory allocation failed. */ |
| 1838 static reffed_ptr<MessageDef> New(); | 2305 static reffed_ptr<MessageDef> New(); |
| 1839 | 2306 |
| 1840 /* upb::RefCounted methods like Ref()/Unref(). */ | 2307 /* upb::RefCounted methods like Ref()/Unref(). */ |
| 1841 UPB_REFCOUNTED_CPPMETHODS | 2308 UPB_REFCOUNTED_CPPMETHODS |
| 1842 | 2309 |
| 1843 /* Functionality from upb::Def. */ | 2310 /* Functionality from upb::Def. */ |
| 1844 const char* full_name() const; | 2311 const char* full_name() const; |
| 2312 const char* name() const; |
| 1845 bool set_full_name(const char* fullname, Status* s); | 2313 bool set_full_name(const char* fullname, Status* s); |
| 1846 bool set_full_name(const std::string& fullname, Status* s); | 2314 bool set_full_name(const std::string& fullname, Status* s); |
| 1847 | 2315 |
| 1848 /* Call to freeze this MessageDef. | 2316 /* Call to freeze this MessageDef. |
| 1849 * WARNING: this will fail if this message has any unfrozen submessages! | 2317 * WARNING: this will fail if this message has any unfrozen submessages! |
| 1850 * Messages with cycles must be frozen as a batch using upb::Def::Freeze(). */ | 2318 * Messages with cycles must be frozen as a batch using upb::Def::Freeze(). */ |
| 1851 bool Freeze(Status* s); | 2319 bool Freeze(Status* s); |
| 1852 | 2320 |
| 1853 /* The number of fields that belong to the MessageDef. */ | 2321 /* The number of fields that belong to the MessageDef. */ |
| 1854 int field_count() const; | 2322 int field_count() const; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1877 /* Adds a oneof (upb_oneofdef object) to a msgdef. Requires that the msgdef, | 2345 /* Adds a oneof (upb_oneofdef object) to a msgdef. Requires that the msgdef, |
| 1878 * oneof, and any fielddefs are mutable, that the fielddefs contained in the | 2346 * oneof, and any fielddefs are mutable, that the fielddefs contained in the |
| 1879 * oneof do not have any name or number conflicts with existing fields in the | 2347 * oneof do not have any name or number conflicts with existing fields in the |
| 1880 * msgdef, and that the oneof's name is unique among all oneofs in the msgdef. | 2348 * msgdef, and that the oneof's name is unique among all oneofs in the msgdef. |
| 1881 * If the oneof is added successfully, all of its fields will be added | 2349 * If the oneof is added successfully, all of its fields will be added |
| 1882 * directly to the msgdef as well. In error cases, false is returned and the | 2350 * directly to the msgdef as well. In error cases, false is returned and the |
| 1883 * msgdef is unchanged. */ | 2351 * msgdef is unchanged. */ |
| 1884 bool AddOneof(OneofDef* o, Status* s); | 2352 bool AddOneof(OneofDef* o, Status* s); |
| 1885 bool AddOneof(const reffed_ptr<OneofDef>& o, Status* s); | 2353 bool AddOneof(const reffed_ptr<OneofDef>& o, Status* s); |
| 1886 | 2354 |
| 2355 upb_syntax_t syntax() const; |
| 2356 |
| 2357 /* Returns false if we don't support this syntax value. */ |
| 2358 bool set_syntax(upb_syntax_t syntax); |
| 2359 |
| 2360 /* Set this to false to indicate that primitive fields should not have |
| 2361 * explicit presence information associated with them. This will affect all |
| 2362 * fields added to this message. Defaults to true. */ |
| 2363 void SetPrimitivesHavePresence(bool have_presence); |
| 2364 |
| 1887 /* These return NULL if the field is not found. */ | 2365 /* These return NULL if the field is not found. */ |
| 1888 FieldDef* FindFieldByNumber(uint32_t number); | 2366 FieldDef* FindFieldByNumber(uint32_t number); |
| 1889 FieldDef* FindFieldByName(const char *name, size_t len); | 2367 FieldDef* FindFieldByName(const char *name, size_t len); |
| 1890 const FieldDef* FindFieldByNumber(uint32_t number) const; | 2368 const FieldDef* FindFieldByNumber(uint32_t number) const; |
| 1891 const FieldDef* FindFieldByName(const char* name, size_t len) const; | 2369 const FieldDef* FindFieldByName(const char* name, size_t len) const; |
| 1892 | 2370 |
| 1893 | 2371 |
| 1894 FieldDef* FindFieldByName(const char *name) { | 2372 FieldDef* FindFieldByName(const char *name) { |
| 1895 return FindFieldByName(name, strlen(name)); | 2373 return FindFieldByName(name, strlen(name)); |
| 1896 } | 2374 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2062 UPB_BEGIN_EXTERN_C | 2540 UPB_BEGIN_EXTERN_C |
| 2063 | 2541 |
| 2064 /* Returns NULL if memory allocation failed. */ | 2542 /* Returns NULL if memory allocation failed. */ |
| 2065 upb_msgdef *upb_msgdef_new(const void *owner); | 2543 upb_msgdef *upb_msgdef_new(const void *owner); |
| 2066 | 2544 |
| 2067 /* Include upb_refcounted methods like upb_msgdef_ref(). */ | 2545 /* Include upb_refcounted methods like upb_msgdef_ref(). */ |
| 2068 UPB_REFCOUNTED_CMETHODS(upb_msgdef, upb_msgdef_upcast2) | 2546 UPB_REFCOUNTED_CMETHODS(upb_msgdef, upb_msgdef_upcast2) |
| 2069 | 2547 |
| 2070 bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status); | 2548 bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status); |
| 2071 | 2549 |
| 2550 upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner); |
| 2072 const char *upb_msgdef_fullname(const upb_msgdef *m); | 2551 const char *upb_msgdef_fullname(const upb_msgdef *m); |
| 2073 bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname, upb_status *s); | 2552 const char *upb_msgdef_name(const upb_msgdef *m); |
| 2553 int upb_msgdef_numoneofs(const upb_msgdef *m); |
| 2554 upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m); |
| 2074 | 2555 |
| 2075 upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner); | |
| 2076 bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor, | 2556 bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor, |
| 2077 upb_status *s); | 2557 upb_status *s); |
| 2078 bool upb_msgdef_addoneof(upb_msgdef *m, upb_oneofdef *o, const void *ref_donor, | 2558 bool upb_msgdef_addoneof(upb_msgdef *m, upb_oneofdef *o, const void *ref_donor, |
| 2079 upb_status *s); | 2559 upb_status *s); |
| 2560 bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname, upb_status *s); |
| 2561 void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry); |
| 2562 bool upb_msgdef_mapentry(const upb_msgdef *m); |
| 2563 bool upb_msgdef_setsyntax(upb_msgdef *m, upb_syntax_t syntax); |
| 2080 | 2564 |
| 2081 /* Field lookup in a couple of different variations: | 2565 /* Field lookup in a couple of different variations: |
| 2082 * - itof = int to field | 2566 * - itof = int to field |
| 2083 * - ntof = name to field | 2567 * - ntof = name to field |
| 2084 * - ntofz = name to field, null-terminated string. */ | 2568 * - ntofz = name to field, null-terminated string. */ |
| 2085 const upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i); | 2569 const upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i); |
| 2086 const upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name, | 2570 const upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name, |
| 2087 size_t len); | 2571 size_t len); |
| 2088 int upb_msgdef_numfields(const upb_msgdef *m); | 2572 int upb_msgdef_numfields(const upb_msgdef *m); |
| 2089 | 2573 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2111 UPB_INLINE const upb_oneofdef *upb_msgdef_ntooz(const upb_msgdef *m, | 2595 UPB_INLINE const upb_oneofdef *upb_msgdef_ntooz(const upb_msgdef *m, |
| 2112 const char *name) { | 2596 const char *name) { |
| 2113 return upb_msgdef_ntoo(m, name, strlen(name)); | 2597 return upb_msgdef_ntoo(m, name, strlen(name)); |
| 2114 } | 2598 } |
| 2115 | 2599 |
| 2116 UPB_INLINE upb_oneofdef *upb_msgdef_ntoo_mutable(upb_msgdef *m, | 2600 UPB_INLINE upb_oneofdef *upb_msgdef_ntoo_mutable(upb_msgdef *m, |
| 2117 const char *name, size_t len) { | 2601 const char *name, size_t len) { |
| 2118 return (upb_oneofdef *)upb_msgdef_ntoo(m, name, len); | 2602 return (upb_oneofdef *)upb_msgdef_ntoo(m, name, len); |
| 2119 } | 2603 } |
| 2120 | 2604 |
| 2121 void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry); | 2605 /* Lookup of either field or oneof by name. Returns whether either was found. |
| 2122 bool upb_msgdef_mapentry(const upb_msgdef *m); | 2606 * If the return is true, then the found def will be set, and the non-found |
| 2607 * one set to NULL. */ |
| 2608 bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len, |
| 2609 const upb_fielddef **f, const upb_oneofdef **o); |
| 2123 | 2610 |
| 2124 /* Well-known field tag numbers for map-entry messages. */ | 2611 UPB_INLINE bool upb_msgdef_lookupnamez(const upb_msgdef *m, const char *name, |
| 2125 #define UPB_MAPENTRY_KEY 1 | 2612 const upb_fielddef **f, |
| 2126 #define UPB_MAPENTRY_VALUE 2 | 2613 const upb_oneofdef **o) { |
| 2614 return upb_msgdef_lookupname(m, name, strlen(name), f, o); |
| 2615 } |
| 2127 | 2616 |
| 2128 const upb_oneofdef *upb_msgdef_findoneof(const upb_msgdef *m, | 2617 /* Iteration over fields and oneofs. For example: |
| 2129 const char *name); | 2618 * |
| 2130 int upb_msgdef_numoneofs(const upb_msgdef *m); | 2619 * upb_msg_field_iter i; |
| 2131 | |
| 2132 /* upb_msg_field_iter i; | |
| 2133 * for(upb_msg_field_begin(&i, m); | 2620 * for(upb_msg_field_begin(&i, m); |
| 2134 * !upb_msg_field_done(&i); | 2621 * !upb_msg_field_done(&i); |
| 2135 * upb_msg_field_next(&i)) { | 2622 * upb_msg_field_next(&i)) { |
| 2136 * upb_fielddef *f = upb_msg_iter_field(&i); | 2623 * upb_fielddef *f = upb_msg_iter_field(&i); |
| 2137 * // ... | 2624 * // ... |
| 2138 * } | 2625 * } |
| 2139 * | 2626 * |
| 2140 * For C we don't have separate iterators for const and non-const. | 2627 * For C we don't have separate iterators for const and non-const. |
| 2141 * It is the caller's responsibility to cast the upb_fielddef* to | 2628 * It is the caller's responsibility to cast the upb_fielddef* to |
| 2142 * const if the upb_msgdef* is const. */ | 2629 * const if the upb_msgdef* is const. */ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2168 class upb::EnumDef { | 2655 class upb::EnumDef { |
| 2169 public: | 2656 public: |
| 2170 /* Returns NULL if memory allocation failed. */ | 2657 /* Returns NULL if memory allocation failed. */ |
| 2171 static reffed_ptr<EnumDef> New(); | 2658 static reffed_ptr<EnumDef> New(); |
| 2172 | 2659 |
| 2173 /* upb::RefCounted methods like Ref()/Unref(). */ | 2660 /* upb::RefCounted methods like Ref()/Unref(). */ |
| 2174 UPB_REFCOUNTED_CPPMETHODS | 2661 UPB_REFCOUNTED_CPPMETHODS |
| 2175 | 2662 |
| 2176 /* Functionality from upb::Def. */ | 2663 /* Functionality from upb::Def. */ |
| 2177 const char* full_name() const; | 2664 const char* full_name() const; |
| 2665 const char* name() const; |
| 2178 bool set_full_name(const char* fullname, Status* s); | 2666 bool set_full_name(const char* fullname, Status* s); |
| 2179 bool set_full_name(const std::string& fullname, Status* s); | 2667 bool set_full_name(const std::string& fullname, Status* s); |
| 2180 | 2668 |
| 2181 /* Call to freeze this EnumDef. */ | 2669 /* Call to freeze this EnumDef. */ |
| 2182 bool Freeze(Status* s); | 2670 bool Freeze(Status* s); |
| 2183 | 2671 |
| 2184 /* The value that is used as the default when no field default is specified. | 2672 /* The value that is used as the default when no field default is specified. |
| 2185 * If not set explicitly, the first value that was added will be used. | 2673 * If not set explicitly, the first value that was added will be used. |
| 2186 * The default value must be a member of the enum. | 2674 * The default value must be a member of the enum. |
| 2187 * Requires that value_count() > 0. */ | 2675 * Requires that value_count() > 0. */ |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2242 upb_enumdef *upb_enumdef_new(const void *owner); | 2730 upb_enumdef *upb_enumdef_new(const void *owner); |
| 2243 upb_enumdef *upb_enumdef_dup(const upb_enumdef *e, const void *owner); | 2731 upb_enumdef *upb_enumdef_dup(const upb_enumdef *e, const void *owner); |
| 2244 | 2732 |
| 2245 /* Include upb_refcounted methods like upb_enumdef_ref(). */ | 2733 /* Include upb_refcounted methods like upb_enumdef_ref(). */ |
| 2246 UPB_REFCOUNTED_CMETHODS(upb_enumdef, upb_enumdef_upcast2) | 2734 UPB_REFCOUNTED_CMETHODS(upb_enumdef, upb_enumdef_upcast2) |
| 2247 | 2735 |
| 2248 bool upb_enumdef_freeze(upb_enumdef *e, upb_status *status); | 2736 bool upb_enumdef_freeze(upb_enumdef *e, upb_status *status); |
| 2249 | 2737 |
| 2250 /* From upb_def. */ | 2738 /* From upb_def. */ |
| 2251 const char *upb_enumdef_fullname(const upb_enumdef *e); | 2739 const char *upb_enumdef_fullname(const upb_enumdef *e); |
| 2740 const char *upb_enumdef_name(const upb_enumdef *e); |
| 2252 bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname, | 2741 bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname, |
| 2253 upb_status *s); | 2742 upb_status *s); |
| 2254 | 2743 |
| 2255 int32_t upb_enumdef_default(const upb_enumdef *e); | 2744 int32_t upb_enumdef_default(const upb_enumdef *e); |
| 2256 bool upb_enumdef_setdefault(upb_enumdef *e, int32_t val, upb_status *s); | 2745 bool upb_enumdef_setdefault(upb_enumdef *e, int32_t val, upb_status *s); |
| 2257 int upb_enumdef_numvals(const upb_enumdef *e); | 2746 int upb_enumdef_numvals(const upb_enumdef *e); |
| 2258 bool upb_enumdef_addval(upb_enumdef *e, const char *name, int32_t num, | 2747 bool upb_enumdef_addval(upb_enumdef *e, const char *name, int32_t num, |
| 2259 upb_status *status); | 2748 upb_status *status); |
| 2260 | 2749 |
| 2261 /* Enum lookups: | 2750 /* Enum lookups: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2283 int32_t upb_enum_iter_number(upb_enum_iter *iter); | 2772 int32_t upb_enum_iter_number(upb_enum_iter *iter); |
| 2284 | 2773 |
| 2285 UPB_END_EXTERN_C | 2774 UPB_END_EXTERN_C |
| 2286 | 2775 |
| 2287 /* upb::OneofDef **************************************************************/ | 2776 /* upb::OneofDef **************************************************************/ |
| 2288 | 2777 |
| 2289 typedef upb_inttable_iter upb_oneof_iter; | 2778 typedef upb_inttable_iter upb_oneof_iter; |
| 2290 | 2779 |
| 2291 #ifdef __cplusplus | 2780 #ifdef __cplusplus |
| 2292 | 2781 |
| 2293 /* Class that represents a oneof. Its base class is upb::Def (convert with | 2782 /* Class that represents a oneof. */ |
| 2294 * upb::upcast()). */ | |
| 2295 class upb::OneofDef { | 2783 class upb::OneofDef { |
| 2296 public: | 2784 public: |
| 2297 /* Returns NULL if memory allocation failed. */ | 2785 /* Returns NULL if memory allocation failed. */ |
| 2298 static reffed_ptr<OneofDef> New(); | 2786 static reffed_ptr<OneofDef> New(); |
| 2299 | 2787 |
| 2300 /* upb::RefCounted methods like Ref()/Unref(). */ | 2788 /* upb::RefCounted methods like Ref()/Unref(). */ |
| 2301 UPB_REFCOUNTED_CPPMETHODS | 2789 UPB_REFCOUNTED_CPPMETHODS |
| 2302 | 2790 |
| 2303 /* Functionality from upb::Def. */ | |
| 2304 const char* full_name() const; | |
| 2305 | |
| 2306 /* Returns the MessageDef that owns this OneofDef. */ | 2791 /* Returns the MessageDef that owns this OneofDef. */ |
| 2307 const MessageDef* containing_type() const; | 2792 const MessageDef* containing_type() const; |
| 2308 | 2793 |
| 2309 /* Returns the name of this oneof. This is the name used to look up the oneof | 2794 /* Returns the name of this oneof. This is the name used to look up the oneof |
| 2310 * by name once added to a message def. */ | 2795 * by name once added to a message def. */ |
| 2311 const char* name() const; | 2796 const char* name() const; |
| 2312 bool set_name(const char* name, Status* s); | 2797 bool set_name(const char* name, Status* s); |
| 2798 bool set_name(const std::string& name, Status* s); |
| 2313 | 2799 |
| 2314 /* Returns the number of fields currently defined in the oneof. */ | 2800 /* Returns the number of fields currently defined in the oneof. */ |
| 2315 int field_count() const; | 2801 int field_count() const; |
| 2316 | 2802 |
| 2317 /* Adds a field to the oneof. The field must not have been added to any other | 2803 /* Adds a field to the oneof. The field must not have been added to any other |
| 2318 * oneof or msgdef. If the oneof is not yet part of a msgdef, then when the | 2804 * oneof or msgdef. If the oneof is not yet part of a msgdef, then when the |
| 2319 * oneof is eventually added to a msgdef, all fields added to the oneof will | 2805 * oneof is eventually added to a msgdef, all fields added to the oneof will |
| 2320 * also be added to the msgdef at that time. If the oneof is already part of a | 2806 * also be added to the msgdef at that time. If the oneof is already part of a |
| 2321 * msgdef, the field must either be a part of that msgdef already, or must not | 2807 * msgdef, the field must either be a part of that msgdef already, or must not |
| 2322 * be a part of any msgdef; in the latter case, the field is added to the | 2808 * 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 Loading... |
| 2396 | 2882 |
| 2397 #endif /* __cplusplus */ | 2883 #endif /* __cplusplus */ |
| 2398 | 2884 |
| 2399 UPB_BEGIN_EXTERN_C | 2885 UPB_BEGIN_EXTERN_C |
| 2400 | 2886 |
| 2401 /* Native C API. */ | 2887 /* Native C API. */ |
| 2402 upb_oneofdef *upb_oneofdef_new(const void *owner); | 2888 upb_oneofdef *upb_oneofdef_new(const void *owner); |
| 2403 upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner); | 2889 upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner); |
| 2404 | 2890 |
| 2405 /* Include upb_refcounted methods like upb_oneofdef_ref(). */ | 2891 /* Include upb_refcounted methods like upb_oneofdef_ref(). */ |
| 2406 UPB_REFCOUNTED_CMETHODS(upb_oneofdef, upb_oneofdef_upcast2) | 2892 UPB_REFCOUNTED_CMETHODS(upb_oneofdef, upb_oneofdef_upcast) |
| 2407 | 2893 |
| 2408 const char *upb_oneofdef_name(const upb_oneofdef *o); | 2894 const char *upb_oneofdef_name(const upb_oneofdef *o); |
| 2409 bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s); | 2895 bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s); |
| 2410 | 2896 |
| 2411 const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o); | 2897 const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o); |
| 2412 int upb_oneofdef_numfields(const upb_oneofdef *o); | 2898 int upb_oneofdef_numfields(const upb_oneofdef *o); |
| 2413 bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f, | 2899 bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f, |
| 2414 const void *ref_donor, | 2900 const void *ref_donor, |
| 2415 upb_status *s); | 2901 upb_status *s); |
| 2416 | 2902 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2432 * } | 2918 * } |
| 2433 */ | 2919 */ |
| 2434 void upb_oneof_begin(upb_oneof_iter *iter, const upb_oneofdef *o); | 2920 void upb_oneof_begin(upb_oneof_iter *iter, const upb_oneofdef *o); |
| 2435 void upb_oneof_next(upb_oneof_iter *iter); | 2921 void upb_oneof_next(upb_oneof_iter *iter); |
| 2436 bool upb_oneof_done(upb_oneof_iter *iter); | 2922 bool upb_oneof_done(upb_oneof_iter *iter); |
| 2437 upb_fielddef *upb_oneof_iter_field(const upb_oneof_iter *iter); | 2923 upb_fielddef *upb_oneof_iter_field(const upb_oneof_iter *iter); |
| 2438 void upb_oneof_iter_setdone(upb_oneof_iter *iter); | 2924 void upb_oneof_iter_setdone(upb_oneof_iter *iter); |
| 2439 | 2925 |
| 2440 UPB_END_EXTERN_C | 2926 UPB_END_EXTERN_C |
| 2441 | 2927 |
| 2928 |
| 2929 /* upb::FileDef ***************************************************************/ |
| 2930 |
| 2931 #ifdef __cplusplus |
| 2932 |
| 2933 /* Class that represents a .proto file with some things defined in it. |
| 2934 * |
| 2935 * Many users won't care about FileDefs, but they are necessary if you want to |
| 2936 * read the values of file-level options. */ |
| 2937 class upb::FileDef { |
| 2938 public: |
| 2939 /* Returns NULL if memory allocation failed. */ |
| 2940 static reffed_ptr<FileDef> New(); |
| 2941 |
| 2942 /* upb::RefCounted methods like Ref()/Unref(). */ |
| 2943 UPB_REFCOUNTED_CPPMETHODS |
| 2944 |
| 2945 /* Get/set name of the file (eg. "foo/bar.proto"). */ |
| 2946 const char* name() const; |
| 2947 bool set_name(const char* name, Status* s); |
| 2948 bool set_name(const std::string& name, Status* s); |
| 2949 |
| 2950 /* Package name for definitions inside the file (eg. "foo.bar"). */ |
| 2951 const char* package() const; |
| 2952 bool set_package(const char* package, Status* s); |
| 2953 |
| 2954 /* Syntax for the file. Defaults to proto2. */ |
| 2955 upb_syntax_t syntax() const; |
| 2956 void set_syntax(upb_syntax_t syntax); |
| 2957 |
| 2958 /* Get the list of defs from the file. These are returned in the order that |
| 2959 * they were added to the FileDef. */ |
| 2960 int def_count() const; |
| 2961 const Def* def(int index) const; |
| 2962 Def* def(int index); |
| 2963 |
| 2964 /* Get the list of dependencies from the file. These are returned in the |
| 2965 * order that they were added to the FileDef. */ |
| 2966 int dependency_count() const; |
| 2967 const FileDef* dependency(int index) const; |
| 2968 |
| 2969 /* Adds defs to this file. The def must not already belong to another |
| 2970 * file. |
| 2971 * |
| 2972 * Note: this does *not* ensure that this def's name is unique in this file! |
| 2973 * Use a SymbolTable if you want to check this property. Especially since |
| 2974 * properly checking uniqueness would require a check across *all* files |
| 2975 * (including dependencies). */ |
| 2976 bool AddDef(Def* def, Status* s); |
| 2977 bool AddMessage(MessageDef* m, Status* s); |
| 2978 bool AddEnum(EnumDef* e, Status* s); |
| 2979 bool AddExtension(FieldDef* f, Status* s); |
| 2980 |
| 2981 /* Adds a dependency of this file. */ |
| 2982 bool AddDependency(const FileDef* file); |
| 2983 |
| 2984 /* Freezes this FileDef and all messages/enums under it. All subdefs must be |
| 2985 * resolved and all messages/enums must validate. Returns true if this |
| 2986 * succeeded. |
| 2987 * |
| 2988 * TODO(haberman): should we care whether the file's dependencies are frozen |
| 2989 * already? */ |
| 2990 bool Freeze(Status* s); |
| 2991 |
| 2992 private: |
| 2993 UPB_DISALLOW_POD_OPS(FileDef, upb::FileDef) |
| 2994 }; |
| 2995 |
| 2996 #endif |
| 2997 |
| 2998 UPB_BEGIN_EXTERN_C |
| 2999 |
| 3000 upb_filedef *upb_filedef_new(const void *owner); |
| 3001 |
| 3002 /* Include upb_refcounted methods like upb_msgdef_ref(). */ |
| 3003 UPB_REFCOUNTED_CMETHODS(upb_filedef, upb_filedef_upcast) |
| 3004 |
| 3005 const char *upb_filedef_name(const upb_filedef *f); |
| 3006 const char *upb_filedef_package(const upb_filedef *f); |
| 3007 upb_syntax_t upb_filedef_syntax(const upb_filedef *f); |
| 3008 size_t upb_filedef_defcount(const upb_filedef *f); |
| 3009 size_t upb_filedef_depcount(const upb_filedef *f); |
| 3010 const upb_def *upb_filedef_def(const upb_filedef *f, size_t i); |
| 3011 const upb_filedef *upb_filedef_dep(const upb_filedef *f, size_t i); |
| 3012 |
| 3013 bool upb_filedef_freeze(upb_filedef *f, upb_status *s); |
| 3014 bool upb_filedef_setname(upb_filedef *f, const char *name, upb_status *s); |
| 3015 bool upb_filedef_setpackage(upb_filedef *f, const char *package, upb_status *s); |
| 3016 bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax, upb_status *s); |
| 3017 |
| 3018 bool upb_filedef_adddef(upb_filedef *f, upb_def *def, const void *ref_donor, |
| 3019 upb_status *s); |
| 3020 bool upb_filedef_adddep(upb_filedef *f, const upb_filedef *dep); |
| 3021 |
| 3022 UPB_INLINE bool upb_filedef_addmsg(upb_filedef *f, upb_msgdef *m, |
| 3023 const void *ref_donor, upb_status *s) { |
| 3024 return upb_filedef_adddef(f, upb_msgdef_upcast_mutable(m), ref_donor, s); |
| 3025 } |
| 3026 |
| 3027 UPB_INLINE bool upb_filedef_addenum(upb_filedef *f, upb_enumdef *e, |
| 3028 const void *ref_donor, upb_status *s) { |
| 3029 return upb_filedef_adddef(f, upb_enumdef_upcast_mutable(e), ref_donor, s); |
| 3030 } |
| 3031 |
| 3032 UPB_INLINE bool upb_filedef_addext(upb_filedef *file, upb_fielddef *f, |
| 3033 const void *ref_donor, upb_status *s) { |
| 3034 return upb_filedef_adddef(file, upb_fielddef_upcast_mutable(f), ref_donor, s); |
| 3035 } |
| 3036 UPB_INLINE upb_def *upb_filedef_mutabledef(upb_filedef *f, int i) { |
| 3037 return (upb_def*)upb_filedef_def(f, i); |
| 3038 } |
| 3039 |
| 3040 UPB_END_EXTERN_C |
| 3041 |
| 2442 #ifdef __cplusplus | 3042 #ifdef __cplusplus |
| 2443 | 3043 |
| 2444 UPB_INLINE const char* upb_safecstr(const std::string& str) { | 3044 UPB_INLINE const char* upb_safecstr(const std::string& str) { |
| 2445 assert(str.size() == std::strlen(str.c_str())); | 3045 assert(str.size() == std::strlen(str.c_str())); |
| 2446 return str.c_str(); | 3046 return str.c_str(); |
| 2447 } | 3047 } |
| 2448 | 3048 |
| 2449 /* Inline C++ wrappers. */ | 3049 /* Inline C++ wrappers. */ |
| 2450 namespace upb { | 3050 namespace upb { |
| 2451 | 3051 |
| 2452 inline Def* Def::Dup(const void* owner) const { | 3052 inline Def* Def::Dup(const void* owner) const { |
| 2453 return upb_def_dup(this, owner); | 3053 return upb_def_dup(this, owner); |
| 2454 } | 3054 } |
| 2455 inline Def::Type Def::def_type() const { return upb_def_type(this); } | 3055 inline Def::Type Def::def_type() const { return upb_def_type(this); } |
| 2456 inline const char* Def::full_name() const { return upb_def_fullname(this); } | 3056 inline const char* Def::full_name() const { return upb_def_fullname(this); } |
| 3057 inline const char* Def::name() const { return upb_def_name(this); } |
| 2457 inline bool Def::set_full_name(const char* fullname, Status* s) { | 3058 inline bool Def::set_full_name(const char* fullname, Status* s) { |
| 2458 return upb_def_setfullname(this, fullname, s); | 3059 return upb_def_setfullname(this, fullname, s); |
| 2459 } | 3060 } |
| 2460 inline bool Def::set_full_name(const std::string& fullname, Status* s) { | 3061 inline bool Def::set_full_name(const std::string& fullname, Status* s) { |
| 2461 return upb_def_setfullname(this, upb_safecstr(fullname), s); | 3062 return upb_def_setfullname(this, upb_safecstr(fullname), s); |
| 2462 } | 3063 } |
| 2463 inline bool Def::Freeze(Def* const* defs, int n, Status* status) { | 3064 inline bool Def::Freeze(Def* const* defs, size_t n, Status* status) { |
| 2464 return upb_def_freeze(defs, n, status); | 3065 return upb_def_freeze(defs, n, status); |
| 2465 } | 3066 } |
| 2466 inline bool Def::Freeze(const std::vector<Def*>& defs, Status* status) { | 3067 inline bool Def::Freeze(const std::vector<Def*>& defs, Status* status) { |
| 2467 return upb_def_freeze((Def* const*)&defs[0], defs.size(), status); | 3068 return upb_def_freeze((Def* const*)&defs[0], defs.size(), status); |
| 2468 } | 3069 } |
| 2469 | 3070 |
| 2470 inline bool FieldDef::CheckType(int32_t val) { | 3071 inline bool FieldDef::CheckType(int32_t val) { |
| 2471 return upb_fielddef_checktype(val); | 3072 return upb_fielddef_checktype(val); |
| 2472 } | 3073 } |
| 2473 inline bool FieldDef::CheckLabel(int32_t val) { | 3074 inline bool FieldDef::CheckLabel(int32_t val) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2520 return upb_fielddef_descriptortype(this); | 3121 return upb_fielddef_descriptortype(this); |
| 2521 } | 3122 } |
| 2522 inline FieldDef::Label FieldDef::label() const { | 3123 inline FieldDef::Label FieldDef::label() const { |
| 2523 return upb_fielddef_label(this); | 3124 return upb_fielddef_label(this); |
| 2524 } | 3125 } |
| 2525 inline uint32_t FieldDef::number() const { return upb_fielddef_number(this); } | 3126 inline uint32_t FieldDef::number() const { return upb_fielddef_number(this); } |
| 2526 inline const char* FieldDef::name() const { return upb_fielddef_name(this); } | 3127 inline const char* FieldDef::name() const { return upb_fielddef_name(this); } |
| 2527 inline bool FieldDef::is_extension() const { | 3128 inline bool FieldDef::is_extension() const { |
| 2528 return upb_fielddef_isextension(this); | 3129 return upb_fielddef_isextension(this); |
| 2529 } | 3130 } |
| 3131 inline size_t FieldDef::GetJsonName(char* buf, size_t len) const { |
| 3132 return upb_fielddef_getjsonname(this, buf, len); |
| 3133 } |
| 2530 inline bool FieldDef::lazy() const { | 3134 inline bool FieldDef::lazy() const { |
| 2531 return upb_fielddef_lazy(this); | 3135 return upb_fielddef_lazy(this); |
| 2532 } | 3136 } |
| 2533 inline void FieldDef::set_lazy(bool lazy) { | 3137 inline void FieldDef::set_lazy(bool lazy) { |
| 2534 upb_fielddef_setlazy(this, lazy); | 3138 upb_fielddef_setlazy(this, lazy); |
| 2535 } | 3139 } |
| 2536 inline bool FieldDef::packed() const { | 3140 inline bool FieldDef::packed() const { |
| 2537 return upb_fielddef_packed(this); | 3141 return upb_fielddef_packed(this); |
| 2538 } | 3142 } |
| 3143 inline uint32_t FieldDef::index() const { |
| 3144 return upb_fielddef_index(this); |
| 3145 } |
| 2539 inline void FieldDef::set_packed(bool packed) { | 3146 inline void FieldDef::set_packed(bool packed) { |
| 2540 upb_fielddef_setpacked(this, packed); | 3147 upb_fielddef_setpacked(this, packed); |
| 2541 } | 3148 } |
| 2542 inline const MessageDef* FieldDef::containing_type() const { | 3149 inline const MessageDef* FieldDef::containing_type() const { |
| 2543 return upb_fielddef_containingtype(this); | 3150 return upb_fielddef_containingtype(this); |
| 2544 } | 3151 } |
| 2545 inline const OneofDef* FieldDef::containing_oneof() const { | 3152 inline const OneofDef* FieldDef::containing_oneof() const { |
| 2546 return upb_fielddef_containingoneof(this); | 3153 return upb_fielddef_containingoneof(this); |
| 2547 } | 3154 } |
| 2548 inline const char* FieldDef::containing_type_name() { | 3155 inline const char* FieldDef::containing_type_name() { |
| 2549 return upb_fielddef_containingtypename(this); | 3156 return upb_fielddef_containingtypename(this); |
| 2550 } | 3157 } |
| 2551 inline bool FieldDef::set_number(uint32_t number, Status* s) { | 3158 inline bool FieldDef::set_number(uint32_t number, Status* s) { |
| 2552 return upb_fielddef_setnumber(this, number, s); | 3159 return upb_fielddef_setnumber(this, number, s); |
| 2553 } | 3160 } |
| 2554 inline bool FieldDef::set_name(const char *name, Status* s) { | 3161 inline bool FieldDef::set_name(const char *name, Status* s) { |
| 2555 return upb_fielddef_setname(this, name, s); | 3162 return upb_fielddef_setname(this, name, s); |
| 2556 } | 3163 } |
| 2557 inline bool FieldDef::set_name(const std::string& name, Status* s) { | 3164 inline bool FieldDef::set_name(const std::string& name, Status* s) { |
| 2558 return upb_fielddef_setname(this, upb_safecstr(name), s); | 3165 return upb_fielddef_setname(this, upb_safecstr(name), s); |
| 2559 } | 3166 } |
| 3167 inline bool FieldDef::set_json_name(const char *name, Status* s) { |
| 3168 return upb_fielddef_setjsonname(this, name, s); |
| 3169 } |
| 3170 inline bool FieldDef::set_json_name(const std::string& name, Status* s) { |
| 3171 return upb_fielddef_setjsonname(this, upb_safecstr(name), s); |
| 3172 } |
| 3173 inline void FieldDef::clear_json_name() { |
| 3174 upb_fielddef_clearjsonname(this); |
| 3175 } |
| 2560 inline bool FieldDef::set_containing_type_name(const char *name, Status* s) { | 3176 inline bool FieldDef::set_containing_type_name(const char *name, Status* s) { |
| 2561 return upb_fielddef_setcontainingtypename(this, name, s); | 3177 return upb_fielddef_setcontainingtypename(this, name, s); |
| 2562 } | 3178 } |
| 2563 inline bool FieldDef::set_containing_type_name(const std::string &name, | 3179 inline bool FieldDef::set_containing_type_name(const std::string &name, |
| 2564 Status *s) { | 3180 Status *s) { |
| 2565 return upb_fielddef_setcontainingtypename(this, upb_safecstr(name), s); | 3181 return upb_fielddef_setcontainingtypename(this, upb_safecstr(name), s); |
| 2566 } | 3182 } |
| 2567 inline void FieldDef::set_type(upb_fieldtype_t type) { | 3183 inline void FieldDef::set_type(upb_fieldtype_t type) { |
| 2568 upb_fielddef_settype(this, type); | 3184 upb_fielddef_settype(this, type); |
| 2569 } | 3185 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2664 return upb_fielddef_setsubdefname(this, upb_safecstr(name), s); | 3280 return upb_fielddef_setsubdefname(this, upb_safecstr(name), s); |
| 2665 } | 3281 } |
| 2666 | 3282 |
| 2667 inline reffed_ptr<MessageDef> MessageDef::New() { | 3283 inline reffed_ptr<MessageDef> MessageDef::New() { |
| 2668 upb_msgdef *m = upb_msgdef_new(&m); | 3284 upb_msgdef *m = upb_msgdef_new(&m); |
| 2669 return reffed_ptr<MessageDef>(m, &m); | 3285 return reffed_ptr<MessageDef>(m, &m); |
| 2670 } | 3286 } |
| 2671 inline const char *MessageDef::full_name() const { | 3287 inline const char *MessageDef::full_name() const { |
| 2672 return upb_msgdef_fullname(this); | 3288 return upb_msgdef_fullname(this); |
| 2673 } | 3289 } |
| 3290 inline const char *MessageDef::name() const { |
| 3291 return upb_msgdef_name(this); |
| 3292 } |
| 3293 inline upb_syntax_t MessageDef::syntax() const { |
| 3294 return upb_msgdef_syntax(this); |
| 3295 } |
| 2674 inline bool MessageDef::set_full_name(const char* fullname, Status* s) { | 3296 inline bool MessageDef::set_full_name(const char* fullname, Status* s) { |
| 2675 return upb_msgdef_setfullname(this, fullname, s); | 3297 return upb_msgdef_setfullname(this, fullname, s); |
| 2676 } | 3298 } |
| 2677 inline bool MessageDef::set_full_name(const std::string& fullname, Status* s) { | 3299 inline bool MessageDef::set_full_name(const std::string& fullname, Status* s) { |
| 2678 return upb_msgdef_setfullname(this, upb_safecstr(fullname), s); | 3300 return upb_msgdef_setfullname(this, upb_safecstr(fullname), s); |
| 2679 } | 3301 } |
| 3302 inline bool MessageDef::set_syntax(upb_syntax_t syntax) { |
| 3303 return upb_msgdef_setsyntax(this, syntax); |
| 3304 } |
| 2680 inline bool MessageDef::Freeze(Status* status) { | 3305 inline bool MessageDef::Freeze(Status* status) { |
| 2681 return upb_msgdef_freeze(this, status); | 3306 return upb_msgdef_freeze(this, status); |
| 2682 } | 3307 } |
| 2683 inline int MessageDef::field_count() const { | 3308 inline int MessageDef::field_count() const { |
| 2684 return upb_msgdef_numfields(this); | 3309 return upb_msgdef_numfields(this); |
| 2685 } | 3310 } |
| 2686 inline int MessageDef::oneof_count() const { | 3311 inline int MessageDef::oneof_count() const { |
| 2687 return upb_msgdef_numoneofs(this); | 3312 return upb_msgdef_numoneofs(this); |
| 2688 } | 3313 } |
| 2689 inline bool MessageDef::AddField(upb_fielddef* f, Status* s) { | 3314 inline bool MessageDef::AddField(upb_fielddef* f, Status* s) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2851 return !(*this == other); | 3476 return !(*this == other); |
| 2852 } | 3477 } |
| 2853 | 3478 |
| 2854 inline reffed_ptr<EnumDef> EnumDef::New() { | 3479 inline reffed_ptr<EnumDef> EnumDef::New() { |
| 2855 upb_enumdef *e = upb_enumdef_new(&e); | 3480 upb_enumdef *e = upb_enumdef_new(&e); |
| 2856 return reffed_ptr<EnumDef>(e, &e); | 3481 return reffed_ptr<EnumDef>(e, &e); |
| 2857 } | 3482 } |
| 2858 inline const char* EnumDef::full_name() const { | 3483 inline const char* EnumDef::full_name() const { |
| 2859 return upb_enumdef_fullname(this); | 3484 return upb_enumdef_fullname(this); |
| 2860 } | 3485 } |
| 3486 inline const char* EnumDef::name() const { |
| 3487 return upb_enumdef_name(this); |
| 3488 } |
| 2861 inline bool EnumDef::set_full_name(const char* fullname, Status* s) { | 3489 inline bool EnumDef::set_full_name(const char* fullname, Status* s) { |
| 2862 return upb_enumdef_setfullname(this, fullname, s); | 3490 return upb_enumdef_setfullname(this, fullname, s); |
| 2863 } | 3491 } |
| 2864 inline bool EnumDef::set_full_name(const std::string& fullname, Status* s) { | 3492 inline bool EnumDef::set_full_name(const std::string& fullname, Status* s) { |
| 2865 return upb_enumdef_setfullname(this, upb_safecstr(fullname), s); | 3493 return upb_enumdef_setfullname(this, upb_safecstr(fullname), s); |
| 2866 } | 3494 } |
| 2867 inline bool EnumDef::Freeze(Status* status) { | 3495 inline bool EnumDef::Freeze(Status* status) { |
| 2868 return upb_enumdef_freeze(this, status); | 3496 return upb_enumdef_freeze(this, status); |
| 2869 } | 3497 } |
| 2870 inline int32_t EnumDef::default_value() const { | 3498 inline int32_t EnumDef::default_value() const { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2900 inline const char* EnumDef::Iterator::name() { | 3528 inline const char* EnumDef::Iterator::name() { |
| 2901 return upb_enum_iter_name(&iter_); | 3529 return upb_enum_iter_name(&iter_); |
| 2902 } | 3530 } |
| 2903 inline bool EnumDef::Iterator::Done() { return upb_enum_done(&iter_); } | 3531 inline bool EnumDef::Iterator::Done() { return upb_enum_done(&iter_); } |
| 2904 inline void EnumDef::Iterator::Next() { return upb_enum_next(&iter_); } | 3532 inline void EnumDef::Iterator::Next() { return upb_enum_next(&iter_); } |
| 2905 | 3533 |
| 2906 inline reffed_ptr<OneofDef> OneofDef::New() { | 3534 inline reffed_ptr<OneofDef> OneofDef::New() { |
| 2907 upb_oneofdef *o = upb_oneofdef_new(&o); | 3535 upb_oneofdef *o = upb_oneofdef_new(&o); |
| 2908 return reffed_ptr<OneofDef>(o, &o); | 3536 return reffed_ptr<OneofDef>(o, &o); |
| 2909 } | 3537 } |
| 2910 inline const char* OneofDef::full_name() const { | |
| 2911 return upb_oneofdef_name(this); | |
| 2912 } | |
| 2913 | 3538 |
| 2914 inline const MessageDef* OneofDef::containing_type() const { | 3539 inline const MessageDef* OneofDef::containing_type() const { |
| 2915 return upb_oneofdef_containingtype(this); | 3540 return upb_oneofdef_containingtype(this); |
| 2916 } | 3541 } |
| 2917 inline const char* OneofDef::name() const { | 3542 inline const char* OneofDef::name() const { |
| 2918 return upb_oneofdef_name(this); | 3543 return upb_oneofdef_name(this); |
| 2919 } | 3544 } |
| 2920 inline bool OneofDef::set_name(const char* name, Status* s) { | 3545 inline bool OneofDef::set_name(const char* name, Status* s) { |
| 2921 return upb_oneofdef_setname(this, name, s); | 3546 return upb_oneofdef_setname(this, name, s); |
| 2922 } | 3547 } |
| 3548 inline bool OneofDef::set_name(const std::string& name, Status* s) { |
| 3549 return upb_oneofdef_setname(this, upb_safecstr(name), s); |
| 3550 } |
| 2923 inline int OneofDef::field_count() const { | 3551 inline int OneofDef::field_count() const { |
| 2924 return upb_oneofdef_numfields(this); | 3552 return upb_oneofdef_numfields(this); |
| 2925 } | 3553 } |
| 2926 inline bool OneofDef::AddField(FieldDef* field, Status* s) { | 3554 inline bool OneofDef::AddField(FieldDef* field, Status* s) { |
| 2927 return upb_oneofdef_addfield(this, field, NULL, s); | 3555 return upb_oneofdef_addfield(this, field, NULL, s); |
| 2928 } | 3556 } |
| 2929 inline bool OneofDef::AddField(const reffed_ptr<FieldDef>& field, Status* s) { | 3557 inline bool OneofDef::AddField(const reffed_ptr<FieldDef>& field, Status* s) { |
| 2930 return upb_oneofdef_addfield(this, field.get(), NULL, s); | 3558 return upb_oneofdef_addfield(this, field.get(), NULL, s); |
| 2931 } | 3559 } |
| 2932 inline const FieldDef* OneofDef::FindFieldByName(const char* name, | 3560 inline const FieldDef* OneofDef::FindFieldByName(const char* name, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2981 } | 3609 } |
| 2982 inline bool OneofDef::const_iterator::operator==( | 3610 inline bool OneofDef::const_iterator::operator==( |
| 2983 const const_iterator &other) const { | 3611 const const_iterator &other) const { |
| 2984 return upb_inttable_iter_isequal(&iter_, &other.iter_); | 3612 return upb_inttable_iter_isequal(&iter_, &other.iter_); |
| 2985 } | 3613 } |
| 2986 inline bool OneofDef::const_iterator::operator!=( | 3614 inline bool OneofDef::const_iterator::operator!=( |
| 2987 const const_iterator &other) const { | 3615 const const_iterator &other) const { |
| 2988 return !(*this == other); | 3616 return !(*this == other); |
| 2989 } | 3617 } |
| 2990 | 3618 |
| 3619 inline reffed_ptr<FileDef> FileDef::New() { |
| 3620 upb_filedef *f = upb_filedef_new(&f); |
| 3621 return reffed_ptr<FileDef>(f, &f); |
| 3622 } |
| 3623 |
| 3624 inline const char* FileDef::name() const { |
| 3625 return upb_filedef_name(this); |
| 3626 } |
| 3627 inline bool FileDef::set_name(const char* name, Status* s) { |
| 3628 return upb_filedef_setname(this, name, s); |
| 3629 } |
| 3630 inline bool FileDef::set_name(const std::string& name, Status* s) { |
| 3631 return upb_filedef_setname(this, upb_safecstr(name), s); |
| 3632 } |
| 3633 inline const char* FileDef::package() const { |
| 3634 return upb_filedef_package(this); |
| 3635 } |
| 3636 inline bool FileDef::set_package(const char* package, Status* s) { |
| 3637 return upb_filedef_setpackage(this, package, s); |
| 3638 } |
| 3639 inline int FileDef::def_count() const { |
| 3640 return upb_filedef_defcount(this); |
| 3641 } |
| 3642 inline const Def* FileDef::def(int index) const { |
| 3643 return upb_filedef_def(this, index); |
| 3644 } |
| 3645 inline Def* FileDef::def(int index) { |
| 3646 return const_cast<Def*>(upb_filedef_def(this, index)); |
| 3647 } |
| 3648 inline int FileDef::dependency_count() const { |
| 3649 return upb_filedef_depcount(this); |
| 3650 } |
| 3651 inline const FileDef* FileDef::dependency(int index) const { |
| 3652 return upb_filedef_dep(this, index); |
| 3653 } |
| 3654 inline bool FileDef::AddDef(Def* def, Status* s) { |
| 3655 return upb_filedef_adddef(this, def, NULL, s); |
| 3656 } |
| 3657 inline bool FileDef::AddMessage(MessageDef* m, Status* s) { |
| 3658 return upb_filedef_addmsg(this, m, NULL, s); |
| 3659 } |
| 3660 inline bool FileDef::AddEnum(EnumDef* e, Status* s) { |
| 3661 return upb_filedef_addenum(this, e, NULL, s); |
| 3662 } |
| 3663 inline bool FileDef::AddExtension(FieldDef* f, Status* s) { |
| 3664 return upb_filedef_addext(this, f, NULL, s); |
| 3665 } |
| 3666 inline bool FileDef::AddDependency(const FileDef* file) { |
| 3667 return upb_filedef_adddep(this, file); |
| 3668 } |
| 3669 |
| 2991 } /* namespace upb */ | 3670 } /* namespace upb */ |
| 2992 #endif | 3671 #endif |
| 2993 | 3672 |
| 2994 #endif /* UPB_DEF_H_ */ | 3673 #endif /* UPB_DEF_H_ */ |
| 2995 /* | 3674 /* |
| 2996 ** This file contains definitions of structs that should be considered private | 3675 ** This file contains definitions of structs that should be considered private |
| 2997 ** and NOT stable across versions of upb. | 3676 ** and NOT stable across versions of upb. |
| 2998 ** | 3677 ** |
| 2999 ** The only reason they are declared here and not in .c files is to allow upb | 3678 ** The only reason they are declared here and not in .c files is to allow upb |
| 3000 ** and the application (if desired) to embed statically-initialized instances | 3679 ** and the application (if desired) to embed statically-initialized instances |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3019 | 3698 |
| 3020 /* upb_refcounted *************************************************************/ | 3699 /* upb_refcounted *************************************************************/ |
| 3021 | 3700 |
| 3022 | 3701 |
| 3023 /* upb_def ********************************************************************/ | 3702 /* upb_def ********************************************************************/ |
| 3024 | 3703 |
| 3025 struct upb_def { | 3704 struct upb_def { |
| 3026 upb_refcounted base; | 3705 upb_refcounted base; |
| 3027 | 3706 |
| 3028 const char *fullname; | 3707 const char *fullname; |
| 3708 const upb_filedef* file; |
| 3029 char type; /* A upb_deftype_t (char to save space) */ | 3709 char type; /* A upb_deftype_t (char to save space) */ |
| 3030 | 3710 |
| 3031 /* Used as a flag during the def's mutable stage. Must be false unless | 3711 /* Used as a flag during the def's mutable stage. Must be false unless |
| 3032 * it is currently being used by a function on the stack. This allows | 3712 * it is currently being used by a function on the stack. This allows |
| 3033 * us to easily determine which defs were passed into the function's | 3713 * us to easily determine which defs were passed into the function's |
| 3034 * current invocation. */ | 3714 * current invocation. */ |
| 3035 bool came_from_user; | 3715 bool came_from_user; |
| 3036 }; | 3716 }; |
| 3037 | 3717 |
| 3038 #define UPB_DEF_INIT(name, type, refs, ref2s) \ | 3718 #define UPB_DEF_INIT(name, type, vtbl, refs, ref2s) \ |
| 3039 { UPB_REFCOUNT_INIT(refs, ref2s), name, type, false } | 3719 { UPB_REFCOUNT_INIT(vtbl, refs, ref2s), name, NULL, type, false } |
| 3040 | 3720 |
| 3041 | 3721 |
| 3042 /* upb_fielddef ***************************************************************/ | 3722 /* upb_fielddef ***************************************************************/ |
| 3043 | 3723 |
| 3044 struct upb_fielddef { | 3724 struct upb_fielddef { |
| 3045 upb_def base; | 3725 upb_def base; |
| 3046 | 3726 |
| 3047 union { | 3727 union { |
| 3048 int64_t sint; | 3728 int64_t sint; |
| 3049 uint64_t uint; | 3729 uint64_t uint; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3069 bool packed_; | 3749 bool packed_; |
| 3070 upb_intfmt_t intfmt; | 3750 upb_intfmt_t intfmt; |
| 3071 bool tagdelim; | 3751 bool tagdelim; |
| 3072 upb_fieldtype_t type_; | 3752 upb_fieldtype_t type_; |
| 3073 upb_label_t label_; | 3753 upb_label_t label_; |
| 3074 uint32_t number_; | 3754 uint32_t number_; |
| 3075 uint32_t selector_base; /* Used to index into a upb::Handlers table. */ | 3755 uint32_t selector_base; /* Used to index into a upb::Handlers table. */ |
| 3076 uint32_t index_; | 3756 uint32_t index_; |
| 3077 }; | 3757 }; |
| 3078 | 3758 |
| 3759 extern const struct upb_refcounted_vtbl upb_fielddef_vtbl; |
| 3760 |
| 3079 #define UPB_FIELDDEF_INIT(label, type, intfmt, tagdelim, is_extension, lazy, \ | 3761 #define UPB_FIELDDEF_INIT(label, type, intfmt, tagdelim, is_extension, lazy, \ |
| 3080 packed, name, num, msgdef, subdef, selector_base, \ | 3762 packed, name, num, msgdef, subdef, selector_base, \ |
| 3081 index, defaultval, refs, ref2s) \ | 3763 index, defaultval, refs, ref2s) \ |
| 3082 { \ | 3764 { \ |
| 3083 UPB_DEF_INIT(name, UPB_DEF_FIELD, refs, ref2s), defaultval, {msgdef}, \ | 3765 UPB_DEF_INIT(name, UPB_DEF_FIELD, &upb_fielddef_vtbl, refs, ref2s), \ |
| 3084 {subdef}, NULL, false, false, \ | 3766 defaultval, {msgdef}, {subdef}, NULL, false, false, \ |
| 3085 type == UPB_TYPE_STRING || type == UPB_TYPE_BYTES, true, is_extension, \ | 3767 type == UPB_TYPE_STRING || type == UPB_TYPE_BYTES, true, is_extension, \ |
| 3086 lazy, packed, intfmt, tagdelim, type, label, num, selector_base, index \ | 3768 lazy, packed, intfmt, tagdelim, type, label, num, selector_base, index \ |
| 3087 } | 3769 } |
| 3088 | 3770 |
| 3089 | 3771 |
| 3090 /* upb_msgdef *****************************************************************/ | 3772 /* upb_msgdef *****************************************************************/ |
| 3091 | 3773 |
| 3092 struct upb_msgdef { | 3774 struct upb_msgdef { |
| 3093 upb_def base; | 3775 upb_def base; |
| 3094 | 3776 |
| 3095 size_t selector_count; | 3777 size_t selector_count; |
| 3096 uint32_t submsg_field_count; | 3778 uint32_t submsg_field_count; |
| 3097 | 3779 |
| 3098 /* Tables for looking up fields by number and name. */ | 3780 /* Tables for looking up fields by number and name. */ |
| 3099 upb_inttable itof; /* int to field */ | 3781 upb_inttable itof; /* int to field */ |
| 3100 upb_strtable ntof; /* name to field */ | 3782 upb_strtable ntof; /* name to field/oneof */ |
| 3101 | 3783 |
| 3102 /* Tables for looking up oneofs by name. */ | 3784 /* Is this a map-entry message? */ |
| 3103 upb_strtable ntoo; /* name to oneof */ | 3785 bool map_entry; |
| 3104 | 3786 |
| 3105 /* Is this a map-entry message? | 3787 /* Whether this message has proto2 or proto3 semantics. */ |
| 3106 * TODO: set this flag properly for static descriptors; regenerate | 3788 upb_syntax_t syntax; |
| 3107 * descriptor.upb.c. */ | |
| 3108 bool map_entry; | |
| 3109 | 3789 |
| 3110 /* TODO(haberman): proper extension ranges (there can be multiple). */ | 3790 /* TODO(haberman): proper extension ranges (there can be multiple). */ |
| 3111 }; | 3791 }; |
| 3112 | 3792 |
| 3793 extern const struct upb_refcounted_vtbl upb_msgdef_vtbl; |
| 3794 |
| 3113 /* TODO: also support static initialization of the oneofs table. This will be | 3795 /* TODO: also support static initialization of the oneofs table. This will be |
| 3114 * needed if we compile in descriptors that contain oneofs. */ | 3796 * needed if we compile in descriptors that contain oneofs. */ |
| 3115 #define UPB_MSGDEF_INIT(name, selector_count, submsg_field_count, itof, ntof, \ | 3797 #define UPB_MSGDEF_INIT(name, selector_count, submsg_field_count, itof, ntof, \ |
| 3116 refs, ref2s) \ | 3798 map_entry, syntax, refs, ref2s) \ |
| 3117 { \ | 3799 { \ |
| 3118 UPB_DEF_INIT(name, UPB_DEF_MSG, refs, ref2s), selector_count, \ | 3800 UPB_DEF_INIT(name, UPB_DEF_MSG, &upb_fielddef_vtbl, refs, ref2s), \ |
| 3119 submsg_field_count, itof, ntof, \ | 3801 selector_count, submsg_field_count, itof, ntof, map_entry, syntax \ |
| 3120 UPB_EMPTY_STRTABLE_INIT(UPB_CTYPE_PTR), false \ | |
| 3121 } | 3802 } |
| 3122 | 3803 |
| 3123 | 3804 |
| 3124 /* upb_enumdef ****************************************************************/ | 3805 /* upb_enumdef ****************************************************************/ |
| 3125 | 3806 |
| 3126 struct upb_enumdef { | 3807 struct upb_enumdef { |
| 3127 upb_def base; | 3808 upb_def base; |
| 3128 | 3809 |
| 3129 upb_strtable ntoi; | 3810 upb_strtable ntoi; |
| 3130 upb_inttable iton; | 3811 upb_inttable iton; |
| 3131 int32_t defaultval; | 3812 int32_t defaultval; |
| 3132 }; | 3813 }; |
| 3133 | 3814 |
| 3815 extern const struct upb_refcounted_vtbl upb_enumdef_vtbl; |
| 3816 |
| 3134 #define UPB_ENUMDEF_INIT(name, ntoi, iton, defaultval, refs, ref2s) \ | 3817 #define UPB_ENUMDEF_INIT(name, ntoi, iton, defaultval, refs, ref2s) \ |
| 3135 { UPB_DEF_INIT(name, UPB_DEF_ENUM, refs, ref2s), ntoi, iton, defaultval } | 3818 { UPB_DEF_INIT(name, UPB_DEF_ENUM, &upb_enumdef_vtbl, refs, ref2s), ntoi, \ |
| 3819 iton, defaultval } |
| 3136 | 3820 |
| 3137 | 3821 |
| 3138 /* upb_oneofdef ***************************************************************/ | 3822 /* upb_oneofdef ***************************************************************/ |
| 3139 | 3823 |
| 3140 struct upb_oneofdef { | 3824 struct upb_oneofdef { |
| 3141 upb_def base; | 3825 upb_refcounted base; |
| 3142 | 3826 |
| 3827 const char *name; |
| 3143 upb_strtable ntof; | 3828 upb_strtable ntof; |
| 3144 upb_inttable itof; | 3829 upb_inttable itof; |
| 3145 const upb_msgdef *parent; | 3830 const upb_msgdef *parent; |
| 3146 }; | 3831 }; |
| 3147 | 3832 |
| 3833 extern const struct upb_refcounted_vtbl upb_oneofdef_vtbl; |
| 3834 |
| 3148 #define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \ | 3835 #define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \ |
| 3149 { UPB_DEF_INIT(name, UPB_DEF_ENUM, refs, ref2s), ntof, itof } | 3836 { UPB_REFCOUNT_INIT(&upb_oneofdef_vtbl, refs, ref2s), name, ntof, itof } |
| 3150 | 3837 |
| 3151 | 3838 |
| 3152 /* upb_symtab *****************************************************************/ | 3839 /* upb_symtab *****************************************************************/ |
| 3153 | 3840 |
| 3154 struct upb_symtab { | 3841 struct upb_symtab { |
| 3155 upb_refcounted base; | 3842 upb_refcounted base; |
| 3156 | 3843 |
| 3157 upb_strtable symtab; | 3844 upb_strtable symtab; |
| 3158 }; | 3845 }; |
| 3159 | 3846 |
| 3160 #define UPB_SYMTAB_INIT(symtab, refs, ref2s) \ | 3847 struct upb_filedef { |
| 3161 { UPB_REFCOUNT_INIT(refs, ref2s), symtab } | 3848 upb_refcounted base; |
| 3162 | 3849 |
| 3850 const char *name; |
| 3851 const char *package; |
| 3852 upb_syntax_t syntax; |
| 3853 |
| 3854 upb_inttable defs; |
| 3855 upb_inttable deps; |
| 3856 }; |
| 3857 |
| 3858 extern const struct upb_refcounted_vtbl upb_filedef_vtbl; |
| 3163 | 3859 |
| 3164 #endif /* UPB_STATICINIT_H_ */ | 3860 #endif /* UPB_STATICINIT_H_ */ |
| 3165 /* | 3861 /* |
| 3166 ** upb::Handlers (upb_handlers) | 3862 ** upb::Handlers (upb_handlers) |
| 3167 ** | 3863 ** |
| 3168 ** A upb_handlers is like a virtual table for a upb_msgdef. Each field of the | 3864 ** A upb_handlers is like a virtual table for a upb_msgdef. Each field of the |
| 3169 ** message can have associated functions that will be called when we are | 3865 ** message can have associated functions that will be called when we are |
| 3170 ** parsing or visiting a stream of data. This is similar to how handlers work | 3866 ** parsing or visiting a stream of data. This is similar to how handlers work |
| 3171 ** in SAX (the Simple API for XML). | 3867 ** in SAX (the Simple API for XML). |
| 3172 ** | 3868 ** |
| (...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5095 #undef UPB_UINT32ALT_T | 5791 #undef UPB_UINT32ALT_T |
| 5096 #undef UPB_INT64_T | 5792 #undef UPB_INT64_T |
| 5097 #undef UPB_UINT64_T | 5793 #undef UPB_UINT64_T |
| 5098 #undef UPB_INT64ALT_T | 5794 #undef UPB_INT64ALT_T |
| 5099 #undef UPB_UINT64ALT_T | 5795 #undef UPB_UINT64ALT_T |
| 5100 | 5796 |
| 5101 #endif /* UPB_HANDLERS_INL_H_ */ | 5797 #endif /* UPB_HANDLERS_INL_H_ */ |
| 5102 | 5798 |
| 5103 #endif /* UPB_HANDLERS_H */ | 5799 #endif /* UPB_HANDLERS_H */ |
| 5104 /* | 5800 /* |
| 5105 ** upb::Environment (upb_env) | |
| 5106 ** | |
| 5107 ** A upb::Environment provides a means for injecting malloc and an | |
| 5108 ** error-reporting callback into encoders/decoders. This allows them to be | |
| 5109 ** independent of nearly all assumptions about their actual environment. | |
| 5110 ** | |
| 5111 ** It is also a container for allocating the encoders/decoders themselves that | |
| 5112 ** insulates clients from knowing their actual size. This provides ABI | |
| 5113 ** compatibility even if the size of the objects change. And this allows the | |
| 5114 ** structure definitions to be in the .c files instead of the .h files, making | |
| 5115 ** the .h files smaller and more readable. | |
| 5116 */ | |
| 5117 | |
| 5118 | |
| 5119 #ifndef UPB_ENV_H_ | |
| 5120 #define UPB_ENV_H_ | |
| 5121 | |
| 5122 #ifdef __cplusplus | |
| 5123 namespace upb { | |
| 5124 class Environment; | |
| 5125 class SeededAllocator; | |
| 5126 } | |
| 5127 #endif | |
| 5128 | |
| 5129 UPB_DECLARE_TYPE(upb::Environment, upb_env) | |
| 5130 UPB_DECLARE_TYPE(upb::SeededAllocator, upb_seededalloc) | |
| 5131 | |
| 5132 typedef void *upb_alloc_func(void *ud, void *ptr, size_t oldsize, size_t size); | |
| 5133 typedef void upb_cleanup_func(void *ud); | |
| 5134 typedef bool upb_error_func(void *ud, const upb_status *status); | |
| 5135 | |
| 5136 #ifdef __cplusplus | |
| 5137 | |
| 5138 /* An environment is *not* thread-safe. */ | |
| 5139 class upb::Environment { | |
| 5140 public: | |
| 5141 Environment(); | |
| 5142 ~Environment(); | |
| 5143 | |
| 5144 /* Set a custom memory allocation function for the environment. May ONLY | |
| 5145 * be called before any calls to Malloc()/Realloc()/AddCleanup() below. | |
| 5146 * If this is not called, the system realloc() function will be used. | |
| 5147 * The given user pointer "ud" will be passed to the allocation function. | |
| 5148 * | |
| 5149 * The allocation function will not receive corresponding "free" calls. it | |
| 5150 * must ensure that the memory is valid for the lifetime of the Environment, | |
| 5151 * but it may be reclaimed any time thereafter. The likely usage is that | |
| 5152 * "ud" points to a stateful allocator, and that the allocator frees all | |
| 5153 * memory, arena-style, when it is destroyed. In this case the allocator must | |
| 5154 * outlive the Environment. Another possibility is that the allocation | |
| 5155 * function returns GC-able memory that is guaranteed to be GC-rooted for the | |
| 5156 * life of the Environment. */ | |
| 5157 void SetAllocationFunction(upb_alloc_func* alloc, void* ud); | |
| 5158 | |
| 5159 template<class T> | |
| 5160 void SetAllocator(T* allocator) { | |
| 5161 SetAllocationFunction(allocator->GetAllocationFunction(), allocator); | |
| 5162 } | |
| 5163 | |
| 5164 /* Set a custom error reporting function. */ | |
| 5165 void SetErrorFunction(upb_error_func* func, void* ud); | |
| 5166 | |
| 5167 /* Set the error reporting function to simply copy the status to the given | |
| 5168 * status and abort. */ | |
| 5169 void ReportErrorsTo(Status* status); | |
| 5170 | |
| 5171 /* Returns true if all allocations and AddCleanup() calls have succeeded, | |
| 5172 * and no errors were reported with ReportError() (except ones that recovered | |
| 5173 * successfully). */ | |
| 5174 bool ok() const; | |
| 5175 | |
| 5176 /* Functions for use by encoders/decoders. **********************************/ | |
| 5177 | |
| 5178 /* Reports an error to this environment's callback, returning true if | |
| 5179 * the caller should try to recover. */ | |
| 5180 bool ReportError(const Status* status); | |
| 5181 | |
| 5182 /* Allocate memory. Uses the environment's allocation function. | |
| 5183 * | |
| 5184 * There is no need to free(). All memory will be freed automatically, but is | |
| 5185 * guaranteed to outlive the Environment. */ | |
| 5186 void* Malloc(size_t size); | |
| 5187 | |
| 5188 /* Reallocate memory. Preserves "oldsize" bytes from the existing buffer | |
| 5189 * Requires: oldsize <= existing_size. | |
| 5190 * | |
| 5191 * TODO(haberman): should we also enforce that oldsize <= size? */ | |
| 5192 void* Realloc(void* ptr, size_t oldsize, size_t size); | |
| 5193 | |
| 5194 /* Add a cleanup function to run when the environment is destroyed. | |
| 5195 * Returns false on out-of-memory. | |
| 5196 * | |
| 5197 * The first call to AddCleanup() after SetAllocationFunction() is guaranteed | |
| 5198 * to return true -- this makes it possible to robustly set a cleanup handler | |
| 5199 * for a custom allocation function. */ | |
| 5200 bool AddCleanup(upb_cleanup_func* func, void* ud); | |
| 5201 | |
| 5202 /* Total number of bytes that have been allocated. It is undefined what | |
| 5203 * Realloc() does to this counter. */ | |
| 5204 size_t BytesAllocated() const; | |
| 5205 | |
| 5206 private: | |
| 5207 UPB_DISALLOW_COPY_AND_ASSIGN(Environment) | |
| 5208 | |
| 5209 #else | |
| 5210 struct upb_env { | |
| 5211 #endif /* __cplusplus */ | |
| 5212 | |
| 5213 bool ok_; | |
| 5214 size_t bytes_allocated; | |
| 5215 | |
| 5216 /* Alloc function. */ | |
| 5217 upb_alloc_func *alloc; | |
| 5218 void *alloc_ud; | |
| 5219 | |
| 5220 /* Error-reporting function. */ | |
| 5221 upb_error_func *err; | |
| 5222 void *err_ud; | |
| 5223 | |
| 5224 /* Userdata for default alloc func. */ | |
| 5225 void *default_alloc_ud; | |
| 5226 | |
| 5227 /* Cleanup entries. Pointer to a cleanup_ent, defined in env.c */ | |
| 5228 void *cleanup_head; | |
| 5229 | |
| 5230 /* For future expansion, since the size of this struct is exposed to users. */ | |
| 5231 void *future1; | |
| 5232 void *future2; | |
| 5233 }; | |
| 5234 | |
| 5235 UPB_BEGIN_EXTERN_C | |
| 5236 | |
| 5237 void upb_env_init(upb_env *e); | |
| 5238 void upb_env_uninit(upb_env *e); | |
| 5239 void upb_env_setallocfunc(upb_env *e, upb_alloc_func *func, void *ud); | |
| 5240 void upb_env_seterrorfunc(upb_env *e, upb_error_func *func, void *ud); | |
| 5241 void upb_env_reporterrorsto(upb_env *e, upb_status *status); | |
| 5242 bool upb_env_ok(const upb_env *e); | |
| 5243 bool upb_env_reporterror(upb_env *e, const upb_status *status); | |
| 5244 void *upb_env_malloc(upb_env *e, size_t size); | |
| 5245 void *upb_env_realloc(upb_env *e, void *ptr, size_t oldsize, size_t size); | |
| 5246 bool upb_env_addcleanup(upb_env *e, upb_cleanup_func *func, void *ud); | |
| 5247 size_t upb_env_bytesallocated(const upb_env *e); | |
| 5248 | |
| 5249 UPB_END_EXTERN_C | |
| 5250 | |
| 5251 #ifdef __cplusplus | |
| 5252 | |
| 5253 /* An allocator that allocates from an initial memory region (likely the stack) | |
| 5254 * before falling back to another allocator. */ | |
| 5255 class upb::SeededAllocator { | |
| 5256 public: | |
| 5257 SeededAllocator(void *mem, size_t len); | |
| 5258 ~SeededAllocator(); | |
| 5259 | |
| 5260 /* Set a custom fallback memory allocation function for the allocator, to use | |
| 5261 * once the initial region runs out. | |
| 5262 * | |
| 5263 * May ONLY be called before GetAllocationFunction(). If this is not | |
| 5264 * called, the system realloc() will be the fallback allocator. */ | |
| 5265 void SetFallbackAllocator(upb_alloc_func *alloc, void *ud); | |
| 5266 | |
| 5267 /* Gets the allocation function for this allocator. */ | |
| 5268 upb_alloc_func* GetAllocationFunction(); | |
| 5269 | |
| 5270 private: | |
| 5271 UPB_DISALLOW_COPY_AND_ASSIGN(SeededAllocator) | |
| 5272 | |
| 5273 #else | |
| 5274 struct upb_seededalloc { | |
| 5275 #endif /* __cplusplus */ | |
| 5276 | |
| 5277 /* Fallback alloc function. */ | |
| 5278 upb_alloc_func *alloc; | |
| 5279 upb_cleanup_func *alloc_cleanup; | |
| 5280 void *alloc_ud; | |
| 5281 bool need_cleanup; | |
| 5282 bool returned_allocfunc; | |
| 5283 | |
| 5284 /* Userdata for default alloc func. */ | |
| 5285 void *default_alloc_ud; | |
| 5286 | |
| 5287 /* Pointers for the initial memory region. */ | |
| 5288 char *mem_base; | |
| 5289 char *mem_ptr; | |
| 5290 char *mem_limit; | |
| 5291 | |
| 5292 /* For future expansion, since the size of this struct is exposed to users. */ | |
| 5293 void *future1; | |
| 5294 void *future2; | |
| 5295 }; | |
| 5296 | |
| 5297 UPB_BEGIN_EXTERN_C | |
| 5298 | |
| 5299 void upb_seededalloc_init(upb_seededalloc *a, void *mem, size_t len); | |
| 5300 void upb_seededalloc_uninit(upb_seededalloc *a); | |
| 5301 void upb_seededalloc_setfallbackalloc(upb_seededalloc *a, upb_alloc_func *func, | |
| 5302 void *ud); | |
| 5303 upb_alloc_func *upb_seededalloc_getallocfunc(upb_seededalloc *a); | |
| 5304 | |
| 5305 UPB_END_EXTERN_C | |
| 5306 | |
| 5307 #ifdef __cplusplus | |
| 5308 | |
| 5309 namespace upb { | |
| 5310 | |
| 5311 inline Environment::Environment() { | |
| 5312 upb_env_init(this); | |
| 5313 } | |
| 5314 inline Environment::~Environment() { | |
| 5315 upb_env_uninit(this); | |
| 5316 } | |
| 5317 inline void Environment::SetAllocationFunction(upb_alloc_func *alloc, | |
| 5318 void *ud) { | |
| 5319 upb_env_setallocfunc(this, alloc, ud); | |
| 5320 } | |
| 5321 inline void Environment::SetErrorFunction(upb_error_func *func, void *ud) { | |
| 5322 upb_env_seterrorfunc(this, func, ud); | |
| 5323 } | |
| 5324 inline void Environment::ReportErrorsTo(Status* status) { | |
| 5325 upb_env_reporterrorsto(this, status); | |
| 5326 } | |
| 5327 inline bool Environment::ok() const { | |
| 5328 return upb_env_ok(this); | |
| 5329 } | |
| 5330 inline bool Environment::ReportError(const Status* status) { | |
| 5331 return upb_env_reporterror(this, status); | |
| 5332 } | |
| 5333 inline void *Environment::Malloc(size_t size) { | |
| 5334 return upb_env_malloc(this, size); | |
| 5335 } | |
| 5336 inline void *Environment::Realloc(void *ptr, size_t oldsize, size_t size) { | |
| 5337 return upb_env_realloc(this, ptr, oldsize, size); | |
| 5338 } | |
| 5339 inline bool Environment::AddCleanup(upb_cleanup_func *func, void *ud) { | |
| 5340 return upb_env_addcleanup(this, func, ud); | |
| 5341 } | |
| 5342 inline size_t Environment::BytesAllocated() const { | |
| 5343 return upb_env_bytesallocated(this); | |
| 5344 } | |
| 5345 | |
| 5346 inline SeededAllocator::SeededAllocator(void *mem, size_t len) { | |
| 5347 upb_seededalloc_init(this, mem, len); | |
| 5348 } | |
| 5349 inline SeededAllocator::~SeededAllocator() { | |
| 5350 upb_seededalloc_uninit(this); | |
| 5351 } | |
| 5352 inline void SeededAllocator::SetFallbackAllocator(upb_alloc_func *alloc, | |
| 5353 void *ud) { | |
| 5354 upb_seededalloc_setfallbackalloc(this, alloc, ud); | |
| 5355 } | |
| 5356 inline upb_alloc_func *SeededAllocator::GetAllocationFunction() { | |
| 5357 return upb_seededalloc_getallocfunc(this); | |
| 5358 } | |
| 5359 | |
| 5360 } /* namespace upb */ | |
| 5361 | |
| 5362 #endif /* __cplusplus */ | |
| 5363 | |
| 5364 #endif /* UPB_ENV_H_ */ | |
| 5365 /* | |
| 5366 ** upb::Sink (upb_sink) | 5801 ** upb::Sink (upb_sink) |
| 5367 ** upb::BytesSink (upb_bytessink) | 5802 ** upb::BytesSink (upb_bytessink) |
| 5368 ** | 5803 ** |
| 5369 ** A upb_sink is an object that binds a upb_handlers object to some runtime | 5804 ** A upb_sink is an object that binds a upb_handlers object to some runtime |
| 5370 ** state. It is the object that can actually receive data via the upb_handlers | 5805 ** state. It is the object that can actually receive data via the upb_handlers |
| 5371 ** interface. | 5806 ** interface. |
| 5372 ** | 5807 ** |
| 5373 ** Unlike upb_def and upb_handlers, upb_sink is never frozen, immutable, or | 5808 ** Unlike upb_def and upb_handlers, upb_sink is never frozen, immutable, or |
| 5374 ** thread-safe. You can create as many of them as you want, but each one may | 5809 ** thread-safe. You can create as many of them as you want, but each one may |
| 5375 ** only be used in a single thread at a time. | 5810 ** only be used in a single thread at a time. |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6059 * leave the defs themselves partially resolved. Does this matter? If so we | 6494 * leave the defs themselves partially resolved. Does this matter? If so we |
| 6060 * could do a prepass that ensures that all symbols are resolvable and bail | 6495 * could do a prepass that ensures that all symbols are resolvable and bail |
| 6061 * if not, so we don't mutate anything until we know the operation will | 6496 * if not, so we don't mutate anything until we know the operation will |
| 6062 * succeed. | 6497 * succeed. |
| 6063 * | 6498 * |
| 6064 * TODO(haberman): since the defs must be mutable, refining a frozen def | 6499 * TODO(haberman): since the defs must be mutable, refining a frozen def |
| 6065 * requires making mutable copies of the entire tree. This is wasteful if | 6500 * requires making mutable copies of the entire tree. This is wasteful if |
| 6066 * only a few messages are changing. We may want to add a way of adding a | 6501 * only a few messages are changing. We may want to add a way of adding a |
| 6067 * tree of frozen defs to the symtab (perhaps an alternate constructor where | 6502 * tree of frozen defs to the symtab (perhaps an alternate constructor where |
| 6068 * you pass the root of the tree?) */ | 6503 * you pass the root of the tree?) */ |
| 6069 bool Add(Def*const* defs, int n, void* ref_donor, upb_status* status); | 6504 bool Add(Def*const* defs, size_t n, void* ref_donor, Status* status); |
| 6070 | 6505 |
| 6071 bool Add(const std::vector<Def*>& defs, void *owner, Status* status) { | 6506 bool Add(const std::vector<Def*>& defs, void *owner, Status* status) { |
| 6072 return Add((Def*const*)&defs[0], defs.size(), owner, status); | 6507 return Add((Def*const*)&defs[0], defs.size(), owner, status); |
| 6073 } | 6508 } |
| 6074 | 6509 |
| 6510 /* Resolves all subdefs for messages in this file and attempts to freeze the |
| 6511 * file. If this succeeds, adds all the symbols to this SymbolTable |
| 6512 * (replacing any existing ones with the same names). */ |
| 6513 bool AddFile(FileDef* file, Status* s); |
| 6514 |
| 6075 private: | 6515 private: |
| 6076 UPB_DISALLOW_POD_OPS(SymbolTable, upb::SymbolTable) | 6516 UPB_DISALLOW_POD_OPS(SymbolTable, upb::SymbolTable) |
| 6077 }; | 6517 }; |
| 6078 | 6518 |
| 6079 #endif /* __cplusplus */ | 6519 #endif /* __cplusplus */ |
| 6080 | 6520 |
| 6081 UPB_BEGIN_EXTERN_C | 6521 UPB_BEGIN_EXTERN_C |
| 6082 | 6522 |
| 6083 /* Native C API. */ | 6523 /* Native C API. */ |
| 6084 | 6524 |
| 6085 /* Include refcounted methods like upb_symtab_ref(). */ | 6525 /* Include refcounted methods like upb_symtab_ref(). */ |
| 6086 UPB_REFCOUNTED_CMETHODS(upb_symtab, upb_symtab_upcast) | 6526 UPB_REFCOUNTED_CMETHODS(upb_symtab, upb_symtab_upcast) |
| 6087 | 6527 |
| 6088 upb_symtab *upb_symtab_new(const void *owner); | 6528 upb_symtab *upb_symtab_new(const void *owner); |
| 6089 void upb_symtab_freeze(upb_symtab *s); | 6529 void upb_symtab_freeze(upb_symtab *s); |
| 6090 const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base, | 6530 const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base, |
| 6091 const char *sym); | 6531 const char *sym); |
| 6092 const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym); | 6532 const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym); |
| 6093 const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym); | 6533 const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym); |
| 6094 const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym); | 6534 const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym); |
| 6095 bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, int n, void *ref_donor, | 6535 bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, |
| 6096 upb_status *status); | 6536 void *ref_donor, upb_status *status); |
| 6537 bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status* status); |
| 6097 | 6538 |
| 6098 /* upb_symtab_iter i; | 6539 /* upb_symtab_iter i; |
| 6099 * for(upb_symtab_begin(&i, s, type); !upb_symtab_done(&i); | 6540 * for(upb_symtab_begin(&i, s, type); !upb_symtab_done(&i); |
| 6100 * upb_symtab_next(&i)) { | 6541 * upb_symtab_next(&i)) { |
| 6101 * const upb_def *def = upb_symtab_iter_def(&i); | 6542 * const upb_def *def = upb_symtab_iter_def(&i); |
| 6102 * // ... | 6543 * // ... |
| 6103 * } | 6544 * } |
| 6104 * | 6545 * |
| 6105 * For C we don't have separate iterators for const and non-const. | 6546 * For C we don't have separate iterators for const and non-const. |
| 6106 * It is the caller's responsibility to cast the upb_fielddef* to | 6547 * It is the caller's responsibility to cast the upb_fielddef* to |
| (...skipping 21 matching lines...) Expand all Loading... |
| 6128 const char *sym) const { | 6569 const char *sym) const { |
| 6129 return upb_symtab_resolve(this, base, sym); | 6570 return upb_symtab_resolve(this, base, sym); |
| 6130 } | 6571 } |
| 6131 inline const Def* SymbolTable::Lookup(const char *sym) const { | 6572 inline const Def* SymbolTable::Lookup(const char *sym) const { |
| 6132 return upb_symtab_lookup(this, sym); | 6573 return upb_symtab_lookup(this, sym); |
| 6133 } | 6574 } |
| 6134 inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const { | 6575 inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const { |
| 6135 return upb_symtab_lookupmsg(this, sym); | 6576 return upb_symtab_lookupmsg(this, sym); |
| 6136 } | 6577 } |
| 6137 inline bool SymbolTable::Add( | 6578 inline bool SymbolTable::Add( |
| 6138 Def*const* defs, int n, void* ref_donor, upb_status* status) { | 6579 Def*const* defs, size_t n, void* ref_donor, Status* status) { |
| 6139 return upb_symtab_add(this, (upb_def*const*)defs, n, ref_donor, status); | 6580 return upb_symtab_add(this, (upb_def*const*)defs, n, ref_donor, status); |
| 6140 } | 6581 } |
| 6582 inline bool SymbolTable::AddFile(FileDef* file, Status* s) { |
| 6583 return upb_symtab_addfile(this, file, s); |
| 6584 } |
| 6141 } /* namespace upb */ | 6585 } /* namespace upb */ |
| 6142 #endif | 6586 #endif |
| 6143 | 6587 |
| 6144 #endif /* UPB_SYMTAB_H_ */ | 6588 #endif /* UPB_SYMTAB_H_ */ |
| 6145 /* | 6589 /* |
| 6146 ** upb::descriptor::Reader (upb_descreader) | 6590 ** upb::descriptor::Reader (upb_descreader) |
| 6147 ** | 6591 ** |
| 6148 ** Provides a way of building upb::Defs from data in descriptor.proto format. | 6592 ** Provides a way of building upb::Defs from data in descriptor.proto format. |
| 6149 */ | 6593 */ |
| 6150 | 6594 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 6174 * TODO: generate the handlers statically (like we do with the | 6618 * TODO: generate the handlers statically (like we do with the |
| 6175 * descriptor.proto defs) so that there is no need to pass this parameter (or | 6619 * descriptor.proto defs) so that there is no need to pass this parameter (or |
| 6176 * to build/memory-manage the handlers at runtime at all). Unfortunately this | 6620 * to build/memory-manage the handlers at runtime at all). Unfortunately this |
| 6177 * is a bit tricky to implement for Handlers, but necessary to simplify this | 6621 * is a bit tricky to implement for Handlers, but necessary to simplify this |
| 6178 * interface. */ | 6622 * interface. */ |
| 6179 static Reader* Create(Environment* env, const Handlers* handlers); | 6623 static Reader* Create(Environment* env, const Handlers* handlers); |
| 6180 | 6624 |
| 6181 /* The reader's input; this is where descriptor.proto data should be sent. */ | 6625 /* The reader's input; this is where descriptor.proto data should be sent. */ |
| 6182 Sink* input(); | 6626 Sink* input(); |
| 6183 | 6627 |
| 6184 /* Returns an array of all defs that have been parsed, and transfers ownership | 6628 /* Use to get the FileDefs that have been parsed. */ |
| 6185 * of them to "owner". The number of defs is stored in *n. Ownership of the | 6629 size_t file_count() const; |
| 6186 * returned array is retained and is invalidated by any other call into | 6630 FileDef* file(size_t i) const; |
| 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); | |
| 6192 | 6631 |
| 6193 /* Builds and returns handlers for the reader, owned by "owner." */ | 6632 /* Builds and returns handlers for the reader, owned by "owner." */ |
| 6194 static Handlers* NewHandlers(const void* owner); | 6633 static Handlers* NewHandlers(const void* owner); |
| 6195 | 6634 |
| 6196 private: | 6635 private: |
| 6197 UPB_DISALLOW_POD_OPS(Reader, upb::descriptor::Reader) | 6636 UPB_DISALLOW_POD_OPS(Reader, upb::descriptor::Reader) |
| 6198 }; | 6637 }; |
| 6199 | 6638 |
| 6200 #endif | 6639 #endif |
| 6201 | 6640 |
| 6202 UPB_BEGIN_EXTERN_C | 6641 UPB_BEGIN_EXTERN_C |
| 6203 | 6642 |
| 6204 /* C API. */ | 6643 /* C API. */ |
| 6205 upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h); | 6644 upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h); |
| 6206 upb_sink *upb_descreader_input(upb_descreader *r); | 6645 upb_sink *upb_descreader_input(upb_descreader *r); |
| 6207 upb_def **upb_descreader_getdefs(upb_descreader *r, void *owner, int *n); | 6646 size_t upb_descreader_filecount(const upb_descreader *r); |
| 6647 upb_filedef *upb_descreader_file(const upb_descreader *r, size_t i); |
| 6208 const upb_handlers *upb_descreader_newhandlers(const void *owner); | 6648 const upb_handlers *upb_descreader_newhandlers(const void *owner); |
| 6209 | 6649 |
| 6210 UPB_END_EXTERN_C | 6650 UPB_END_EXTERN_C |
| 6211 | 6651 |
| 6212 #ifdef __cplusplus | 6652 #ifdef __cplusplus |
| 6213 /* C++ implementation details. ************************************************/ | 6653 /* C++ implementation details. ************************************************/ |
| 6214 namespace upb { | 6654 namespace upb { |
| 6215 namespace descriptor { | 6655 namespace descriptor { |
| 6216 inline Reader* Reader::Create(Environment* e, const Handlers *h) { | 6656 inline Reader* Reader::Create(Environment* e, const Handlers *h) { |
| 6217 return upb_descreader_create(e, h); | 6657 return upb_descreader_create(e, h); |
| 6218 } | 6658 } |
| 6219 inline Sink* Reader::input() { return upb_descreader_input(this); } | 6659 inline Sink* Reader::input() { return upb_descreader_input(this); } |
| 6220 inline upb::Def** Reader::GetDefs(void* owner, int* n) { | 6660 inline size_t Reader::file_count() const { |
| 6221 return upb_descreader_getdefs(this, owner, n); | 6661 return upb_descreader_filecount(this); |
| 6662 } |
| 6663 inline FileDef* Reader::file(size_t i) const { |
| 6664 return upb_descreader_file(this, i); |
| 6222 } | 6665 } |
| 6223 } /* namespace descriptor */ | 6666 } /* namespace descriptor */ |
| 6224 } /* namespace upb */ | 6667 } /* namespace upb */ |
| 6225 #endif | 6668 #endif |
| 6226 | 6669 |
| 6227 #endif /* UPB_DESCRIPTOR_H */ | 6670 #endif /* UPB_DESCRIPTOR_H */ |
| 6228 /* This file contains accessors for a set of compiled-in defs. | 6671 /* This file contains accessors for a set of compiled-in defs. |
| 6229 * Note that unlike Google's protobuf, it does *not* define | 6672 * Note that unlike Google's protobuf, it does *not* define |
| 6230 * generated classes or any other kind of data structure for | 6673 * generated classes or any other kind of data structure for |
| 6231 * actually storing protobufs. It only contains *defs* which | 6674 * actually storing protobufs. It only contains *defs* which |
| 6232 * let you reflect over a protobuf *schema*. | 6675 * let you reflect over a protobuf *schema*. |
| 6233 */ | 6676 */ |
| 6234 /* This file was generated by upbc (the upb compiler). | 6677 /* This file was generated by upbc (the upb compiler) from the input |
| 6678 * file: |
| 6679 * |
| 6680 * upb/descriptor/descriptor.proto |
| 6681 * |
| 6235 * Do not edit -- your changes will be discarded when the file is | 6682 * Do not edit -- your changes will be discarded when the file is |
| 6236 * regenerated. */ | 6683 * regenerated. */ |
| 6237 | 6684 |
| 6238 #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_UPB_H_ | 6685 #ifndef UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_ |
| 6239 #define GOOGLE_PROTOBUF_DESCRIPTOR_UPB_H_ | 6686 #define UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_ |
| 6240 | 6687 |
| 6241 | 6688 |
| 6242 #ifdef __cplusplus | |
| 6243 UPB_BEGIN_EXTERN_C | 6689 UPB_BEGIN_EXTERN_C |
| 6244 #endif | |
| 6245 | 6690 |
| 6246 /* Enums */ | 6691 /* Enums */ |
| 6247 | 6692 |
| 6248 typedef enum { | 6693 typedef enum { |
| 6249 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_OPTIONAL = 1, | 6694 google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1, |
| 6250 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_REQUIRED = 2, | 6695 google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2, |
| 6251 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_REPEATED = 3 | 6696 google_protobuf_FieldDescriptorProto_LABEL_REPEATED = 3 |
| 6252 } google_protobuf_FieldDescriptorProto_Label; | 6697 } google_protobuf_FieldDescriptorProto_Label; |
| 6253 | 6698 |
| 6254 typedef enum { | 6699 typedef enum { |
| 6255 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_DOUBLE = 1, | 6700 google_protobuf_FieldDescriptorProto_TYPE_DOUBLE = 1, |
| 6256 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_FLOAT = 2, | 6701 google_protobuf_FieldDescriptorProto_TYPE_FLOAT = 2, |
| 6257 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT64 = 3, | 6702 google_protobuf_FieldDescriptorProto_TYPE_INT64 = 3, |
| 6258 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_UINT64 = 4, | 6703 google_protobuf_FieldDescriptorProto_TYPE_UINT64 = 4, |
| 6259 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT32 = 5, | 6704 google_protobuf_FieldDescriptorProto_TYPE_INT32 = 5, |
| 6260 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_FIXED64 = 6, | 6705 google_protobuf_FieldDescriptorProto_TYPE_FIXED64 = 6, |
| 6261 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_FIXED32 = 7, | 6706 google_protobuf_FieldDescriptorProto_TYPE_FIXED32 = 7, |
| 6262 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_BOOL = 8, | 6707 google_protobuf_FieldDescriptorProto_TYPE_BOOL = 8, |
| 6263 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_STRING = 9, | 6708 google_protobuf_FieldDescriptorProto_TYPE_STRING = 9, |
| 6264 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_GROUP = 10, | 6709 google_protobuf_FieldDescriptorProto_TYPE_GROUP = 10, |
| 6265 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_MESSAGE = 11, | 6710 google_protobuf_FieldDescriptorProto_TYPE_MESSAGE = 11, |
| 6266 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_BYTES = 12, | 6711 google_protobuf_FieldDescriptorProto_TYPE_BYTES = 12, |
| 6267 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_UINT32 = 13, | 6712 google_protobuf_FieldDescriptorProto_TYPE_UINT32 = 13, |
| 6268 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_ENUM = 14, | 6713 google_protobuf_FieldDescriptorProto_TYPE_ENUM = 14, |
| 6269 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SFIXED32 = 15, | 6714 google_protobuf_FieldDescriptorProto_TYPE_SFIXED32 = 15, |
| 6270 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SFIXED64 = 16, | 6715 google_protobuf_FieldDescriptorProto_TYPE_SFIXED64 = 16, |
| 6271 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SINT32 = 17, | 6716 google_protobuf_FieldDescriptorProto_TYPE_SINT32 = 17, |
| 6272 GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SINT64 = 18 | 6717 google_protobuf_FieldDescriptorProto_TYPE_SINT64 = 18 |
| 6273 } google_protobuf_FieldDescriptorProto_Type; | 6718 } google_protobuf_FieldDescriptorProto_Type; |
| 6274 | 6719 |
| 6275 typedef enum { | 6720 typedef enum { |
| 6276 GOOGLE_PROTOBUF_FIELDOPTIONS_STRING = 0, | 6721 google_protobuf_FieldOptions_STRING = 0, |
| 6277 GOOGLE_PROTOBUF_FIELDOPTIONS_CORD = 1, | 6722 google_protobuf_FieldOptions_CORD = 1, |
| 6278 GOOGLE_PROTOBUF_FIELDOPTIONS_STRING_PIECE = 2 | 6723 google_protobuf_FieldOptions_STRING_PIECE = 2 |
| 6279 } google_protobuf_FieldOptions_CType; | 6724 } google_protobuf_FieldOptions_CType; |
| 6280 | 6725 |
| 6281 typedef enum { | 6726 typedef enum { |
| 6282 GOOGLE_PROTOBUF_FILEOPTIONS_SPEED = 1, | 6727 google_protobuf_FieldOptions_JS_NORMAL = 0, |
| 6283 GOOGLE_PROTOBUF_FILEOPTIONS_CODE_SIZE = 2, | 6728 google_protobuf_FieldOptions_JS_STRING = 1, |
| 6284 GOOGLE_PROTOBUF_FILEOPTIONS_LITE_RUNTIME = 3 | 6729 google_protobuf_FieldOptions_JS_NUMBER = 2 |
| 6730 } google_protobuf_FieldOptions_JSType; |
| 6731 |
| 6732 typedef enum { |
| 6733 google_protobuf_FileOptions_SPEED = 1, |
| 6734 google_protobuf_FileOptions_CODE_SIZE = 2, |
| 6735 google_protobuf_FileOptions_LITE_RUNTIME = 3 |
| 6285 } google_protobuf_FileOptions_OptimizeMode; | 6736 } google_protobuf_FileOptions_OptimizeMode; |
| 6286 | 6737 |
| 6287 /* Selectors */ | 6738 /* MessageDefs: call these functions to get a ref to a msgdef. */ |
| 6288 | 6739 const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_get(const void *owner)
; |
| 6289 /* google.protobuf.DescriptorProto */ | 6740 const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_get(con
st void *owner); |
| 6290 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSUBMSG 2 | 6741 const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_get(cons
t void *owner); |
| 6291 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSUBMSG 3 | 6742 const upb_msgdef *upbdefs_google_protobuf_EnumDescriptorProto_get(const void *ow
ner); |
| 6292 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSUBMSG 4 | 6743 const upb_msgdef *upbdefs_google_protobuf_EnumOptions_get(const void *owner); |
| 6293 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSUBMSG 5 | 6744 const upb_msgdef *upbdefs_google_protobuf_EnumValueDescriptorProto_get(const voi
d *owner); |
| 6294 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSUBMSG 6 | 6745 const upb_msgdef *upbdefs_google_protobuf_EnumValueOptions_get(const void *owner
); |
| 6295 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_STARTSUBMSG 7 | 6746 const upb_msgdef *upbdefs_google_protobuf_FieldDescriptorProto_get(const void *o
wner); |
| 6296 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSEQ 8 | 6747 const upb_msgdef *upbdefs_google_protobuf_FieldOptions_get(const void *owner); |
| 6297 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSEQ 9 | 6748 const upb_msgdef *upbdefs_google_protobuf_FileDescriptorProto_get(const void *ow
ner); |
| 6298 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSUBMSG 10 | 6749 const upb_msgdef *upbdefs_google_protobuf_FileDescriptorSet_get(const void *owne
r); |
| 6299 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSEQ 11 | 6750 const upb_msgdef *upbdefs_google_protobuf_FileOptions_get(const void *owner); |
| 6300 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSEQ 12 | 6751 const upb_msgdef *upbdefs_google_protobuf_MessageOptions_get(const void *owner); |
| 6301 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSUBMSG 13 | 6752 const upb_msgdef *upbdefs_google_protobuf_MethodDescriptorProto_get(const void *
owner); |
| 6302 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 14 | 6753 const upb_msgdef *upbdefs_google_protobuf_MethodOptions_get(const void *owner); |
| 6303 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 15 | 6754 const upb_msgdef *upbdefs_google_protobuf_OneofDescriptorProto_get(const void *o
wner); |
| 6304 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 16 | 6755 const upb_msgdef *upbdefs_google_protobuf_ServiceDescriptorProto_get(const void
*owner); |
| 6305 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSEQ 17 | 6756 const upb_msgdef *upbdefs_google_protobuf_ServiceOptions_get(const void *owner); |
| 6306 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSEQ 18 | 6757 const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_get(const void *owner); |
| 6307 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSUBMSG 19 | 6758 const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_Location_get(const void
*owner); |
| 6308 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSEQ 20 | 6759 const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_get(const void *ow
ner); |
| 6309 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSEQ 21 | 6760 const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_NamePart_get(const
void *owner); |
| 6310 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSUBMSG 22 | 6761 |
| 6311 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_ENDSUBMSG 23 | 6762 /* EnumDefs: call these functions to get a ref to an enumdef. */ |
| 6312 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STRING 24 | 6763 const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Label_get(const
void *owner); |
| 6313 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STARTSTR 25 | 6764 const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Type_get(const v
oid *owner); |
| 6314 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_ENDSTR 26 | 6765 const upb_enumdef *upbdefs_google_protobuf_FieldOptions_CType_get(const void *ow
ner); |
| 6315 | 6766 const upb_enumdef *upbdefs_google_protobuf_FieldOptions_JSType_get(const void *o
wner); |
| 6316 /* google.protobuf.DescriptorProto.ExtensionRange */ | 6767 const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode_get(const vo
id *owner); |
| 6317 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_START_INT32 2 | 6768 |
| 6318 #define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_END_INT32 3 | 6769 /* Functions to test whether this message is of a certain type. */ |
| 6319 | 6770 UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_is(const upb_msgdef *m)
{ |
| 6320 /* google.protobuf.EnumDescriptorProto */ | 6771 return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto") == 0; |
| 6321 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSUBMSG 2 | 6772 } |
| 6322 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 3 | 6773 UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(const
upb_msgdef *m) { |
| 6323 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSEQ 4 | 6774 return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto.Extensi
onRange") == 0; |
| 6324 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_ENDSEQ 5 | 6775 } |
| 6325 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_ENDSUBMSG 6 | 6776 UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(const u
pb_msgdef *m) { |
| 6326 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 7 | 6777 return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto.Reserve
dRange") == 0; |
| 6327 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_STRING 8 | 6778 } |
| 6328 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_STARTSTR 9 | 6779 UPB_INLINE bool upbdefs_google_protobuf_EnumDescriptorProto_is(const upb_msgdef
*m) { |
| 6329 #define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_ENDSTR 10 | 6780 return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumDescriptorProto") =
= 0; |
| 6330 | 6781 } |
| 6331 /* google.protobuf.EnumOptions */ | 6782 UPB_INLINE bool upbdefs_google_protobuf_EnumOptions_is(const upb_msgdef *m) { |
| 6332 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2 | 6783 return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumOptions") == 0; |
| 6333 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3 | 6784 } |
| 6334 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4 | 6785 UPB_INLINE bool upbdefs_google_protobuf_EnumValueDescriptorProto_is(const upb_ms
gdef *m) { |
| 6335 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5 | 6786 return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumValueDescriptorProt
o") == 0; |
| 6336 #define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_ALLOW_ALIAS_BOOL 6 | 6787 } |
| 6337 | 6788 UPB_INLINE bool upbdefs_google_protobuf_EnumValueOptions_is(const upb_msgdef *m)
{ |
| 6338 /* google.protobuf.EnumValueDescriptorProto */ | 6789 return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumValueOptions") == 0
; |
| 6339 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2 | 6790 } |
| 6340 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 3 | 6791 UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_is(const upb_msgdef
*m) { |
| 6341 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_STRING 4 | 6792 return strcmp(upb_msgdef_fullname(m), "google.protobuf.FieldDescriptorProto")
== 0; |
| 6342 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_STARTSTR 5 | 6793 } |
| 6343 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_ENDSTR 6 | 6794 UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_is(const upb_msgdef *m) { |
| 6344 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NUMBER_INT32 7 | 6795 return strcmp(upb_msgdef_fullname(m), "google.protobuf.FieldOptions") == 0; |
| 6345 | 6796 } |
| 6346 /* google.protobuf.EnumValueOptions */ | 6797 UPB_INLINE bool upbdefs_google_protobuf_FileDescriptorProto_is(const upb_msgdef
*m) { |
| 6347 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2 | 6798 return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileDescriptorProto") =
= 0; |
| 6348 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3 | 6799 } |
| 6349 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4 | 6800 UPB_INLINE bool upbdefs_google_protobuf_FileDescriptorSet_is(const upb_msgdef *m
) { |
| 6350 #define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5 | 6801 return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileDescriptorSet") ==
0; |
| 6351 | 6802 } |
| 6352 /* google.protobuf.FieldDescriptorProto */ | 6803 UPB_INLINE bool upbdefs_google_protobuf_FileOptions_is(const upb_msgdef *m) { |
| 6353 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2 | 6804 return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileOptions") == 0; |
| 6354 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 3 | 6805 } |
| 6355 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_STRING 4 | 6806 UPB_INLINE bool upbdefs_google_protobuf_MessageOptions_is(const upb_msgdef *m) { |
| 6356 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_STARTSTR 5 | 6807 return strcmp(upb_msgdef_fullname(m), "google.protobuf.MessageOptions") == 0; |
| 6357 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_ENDSTR 6 | 6808 } |
| 6358 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_STRING 7 | 6809 UPB_INLINE bool upbdefs_google_protobuf_MethodDescriptorProto_is(const upb_msgde
f *m) { |
| 6359 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_STARTSTR 8 | 6810 return strcmp(upb_msgdef_fullname(m), "google.protobuf.MethodDescriptorProto")
== 0; |
| 6360 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_ENDSTR 9 | 6811 } |
| 6361 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NUMBER_INT32 10 | 6812 UPB_INLINE bool upbdefs_google_protobuf_MethodOptions_is(const upb_msgdef *m) { |
| 6362 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_INT32 11 | 6813 return strcmp(upb_msgdef_fullname(m), "google.protobuf.MethodOptions") == 0; |
| 6363 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT32 12 | 6814 } |
| 6364 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_STRING 13 | 6815 UPB_INLINE bool upbdefs_google_protobuf_OneofDescriptorProto_is(const upb_msgdef
*m) { |
| 6365 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_STARTSTR 14 | 6816 return strcmp(upb_msgdef_fullname(m), "google.protobuf.OneofDescriptorProto")
== 0; |
| 6366 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_ENDSTR 15 | 6817 } |
| 6367 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STRING 16 | 6818 UPB_INLINE bool upbdefs_google_protobuf_ServiceDescriptorProto_is(const upb_msgd
ef *m) { |
| 6368 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STARTSTR 17 | 6819 return strcmp(upb_msgdef_fullname(m), "google.protobuf.ServiceDescriptorProto"
) == 0; |
| 6369 #define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_ENDSTR 18 | 6820 } |
| 6370 | 6821 UPB_INLINE bool upbdefs_google_protobuf_ServiceOptions_is(const upb_msgdef *m) { |
| 6371 /* google.protobuf.FieldOptions */ | 6822 return strcmp(upb_msgdef_fullname(m), "google.protobuf.ServiceOptions") == 0; |
| 6372 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2 | 6823 } |
| 6373 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3 | 6824 UPB_INLINE bool upbdefs_google_protobuf_SourceCodeInfo_is(const upb_msgdef *m) { |
| 6374 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4 | 6825 return strcmp(upb_msgdef_fullname(m), "google.protobuf.SourceCodeInfo") == 0; |
| 6375 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5 | 6826 } |
| 6376 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_CTYPE_INT32 6 | 6827 UPB_INLINE bool upbdefs_google_protobuf_SourceCodeInfo_Location_is(const upb_msg
def *m) { |
| 6377 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_PACKED_BOOL 7 | 6828 return strcmp(upb_msgdef_fullname(m), "google.protobuf.SourceCodeInfo.Location
") == 0; |
| 6378 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_DEPRECATED_BOOL 8 | 6829 } |
| 6379 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_LAZY_BOOL 9 | 6830 UPB_INLINE bool upbdefs_google_protobuf_UninterpretedOption_is(const upb_msgdef
*m) { |
| 6380 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_STRING 10 | 6831 return strcmp(upb_msgdef_fullname(m), "google.protobuf.UninterpretedOption") =
= 0; |
| 6381 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_STARTSTR 11 | 6832 } |
| 6382 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_EXPERIMENTAL_MAP_KEY_ENDSTR 12 | 6833 UPB_INLINE bool upbdefs_google_protobuf_UninterpretedOption_NamePart_is(const up
b_msgdef *m) { |
| 6383 #define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_WEAK_BOOL 13 | 6834 return strcmp(upb_msgdef_fullname(m), "google.protobuf.UninterpretedOption.Nam
ePart") == 0; |
| 6384 | 6835 } |
| 6385 /* google.protobuf.FileDescriptorProto */ | 6836 |
| 6386 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSUBMSG 2 | 6837 /* Functions to test whether this enum is of a certain type. */ |
| 6387 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_STARTSUBMSG 3 | 6838 UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_Label_is(const upb_
enumdef *e) { |
| 6388 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_STARTSUBMSG 4 | 6839 return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldDescriptorProto.L
abel") == 0; |
| 6389 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_STARTSUBMSG 5 | 6840 } |
| 6390 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 6 | 6841 UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_Type_is(const upb_e
numdef *e) { |
| 6391 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SOURCE_CODE_INFO_STARTSUBMSG 7 | 6842 return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldDescriptorProto.T
ype") == 0; |
| 6392 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSEQ 8 | 6843 } |
| 6393 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_ENDSEQ 9 | 6844 UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_CType_is(const upb_enumdef
*e) { |
| 6394 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_ENDSUBMSG 10 | 6845 return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldOptions.CType") =
= 0; |
| 6395 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 11 | 6846 } |
| 6396 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 12 | 6847 UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_JSType_is(const upb_enumdef
*e) { |
| 6397 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 13 | 6848 return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldOptions.JSType")
== 0; |
| 6398 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_STARTSEQ 14 | 6849 } |
| 6399 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_ENDSEQ 15 | 6850 UPB_INLINE bool upbdefs_google_protobuf_FileOptions_OptimizeMode_is(const upb_en
umdef *e) { |
| 6400 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_ENDSUBMSG 16 | 6851 return strcmp(upb_enumdef_fullname(e), "google.protobuf.FileOptions.OptimizeMo
de") == 0; |
| 6401 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_STARTSEQ 17 | 6852 } |
| 6402 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_ENDSEQ 18 | 6853 |
| 6403 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_ENDSUBMSG 19 | 6854 |
| 6404 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 20 | 6855 /* Functions to get a fielddef from a msgdef reference. */ |
| 6405 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SOURCE_CODE_INFO_ENDSUBMSG 21 | 6856 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_Extension
Range_f_end(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProt
o_ExtensionRange_is(m)); return upb_msgdef_itof(m, 2); } |
| 6406 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_STRING 22 | 6857 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_Extension
Range_f_start(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorPr
oto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 1); } |
| 6407 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_STARTSTR 23 | 6858 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedR
ange_f_end(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto
_ReservedRange_is(m)); return upb_msgdef_itof(m, 2); } |
| 6408 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_ENDSTR 24 | 6859 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedR
ange_f_start(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorPro
to_ReservedRange_is(m)); return upb_msgdef_itof(m, 1); } |
| 6409 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_STRING 25 | 6860 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_ty
pe(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m));
return upb_msgdef_itof(m, 4); } |
| 6410 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_STARTSTR 26 | 6861 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extensi
on(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m));
return upb_msgdef_itof(m, 6); } |
| 6411 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_ENDSTR 27 | 6862 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extensi
on_range(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_i
s(m)); return upb_msgdef_itof(m, 5); } |
| 6412 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STARTSEQ 28 | 6863 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(c
onst upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); ret
urn upb_msgdef_itof(m, 2); } |
| 6413 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_ENDSEQ 29 | 6864 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(co
nst upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); retu
rn upb_msgdef_itof(m, 1); } |
| 6414 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STRING 30 | 6865 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_
type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)
); return upb_msgdef_itof(m, 3); } |
| 6415 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STARTSTR 31 | 6866 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_d
ecl(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m))
; return upb_msgdef_itof(m, 8); } |
| 6416 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_ENDSTR 32 | 6867 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options
(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); r
eturn upb_msgdef_itof(m, 7); } |
| 6417 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PUBLIC_DEPENDENCY_STARTSEQ 33 | 6868 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserve
d_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(
m)); return upb_msgdef_itof(m, 10); } |
| 6418 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PUBLIC_DEPENDENCY_ENDSEQ 34 | 6869 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserve
d_range(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is
(m)); return upb_msgdef_itof(m, 9); } |
| 6419 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PUBLIC_DEPENDENCY_INT32 35 | 6870 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_nam
e(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m
)); return upb_msgdef_itof(m, 1); } |
| 6420 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_STARTSEQ 36 | 6871 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_opt
ions(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_i
s(m)); return upb_msgdef_itof(m, 3); } |
| 6421 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_ENDSEQ 37 | 6872 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_val
ue(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(
m)); return upb_msgdef_itof(m, 2); } |
| 6422 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_INT32 38 | 6873 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias
(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); retur
n upb_msgdef_itof(m, 2); } |
| 6423 | 6874 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated(
const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return
upb_msgdef_itof(m, 3); } |
| 6424 /* google.protobuf.FileDescriptorSet */ | 6875 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpret
ed_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m
)); return upb_msgdef_itof(m, 999); } |
| 6425 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSUBMSG 2 | 6876 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_
f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptor
Proto_is(m)); return upb_msgdef_itof(m, 1); } |
| 6426 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSEQ 3 | 6877 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_
f_number(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescript
orProto_is(m)); return upb_msgdef_itof(m, 2); } |
| 6427 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_ENDSEQ 4 | 6878 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_
f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescrip
torProto_is(m)); return upb_msgdef_itof(m, 3); } |
| 6428 #define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_ENDSUBMSG 5 | 6879 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprec
ated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueOptions_is(m
)); return upb_msgdef_itof(m, 1); } |
| 6429 | 6880 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninte
rpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueOp
tions_is(m)); return upb_msgdef_itof(m, 999); } |
| 6430 /* google.protobuf.FileOptions */ | 6881 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_de
fault_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescripto
rProto_is(m)); return upb_msgdef_itof(m, 7); } |
| 6431 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2 | 6882 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_ex
tendee(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProt
o_is(m)); return upb_msgdef_itof(m, 2); } |
| 6432 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3 | 6883 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_js
on_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorPro
to_is(m)); return upb_msgdef_itof(m, 10); } |
| 6433 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4 | 6884 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_la
bel(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_i
s(m)); return upb_msgdef_itof(m, 4); } |
| 6434 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5 | 6885 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_na
me(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is
(m)); return upb_msgdef_itof(m, 1); } |
| 6435 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_STRING 6 | 6886 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_nu
mber(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_
is(m)); return upb_msgdef_itof(m, 3); } |
| 6436 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_STARTSTR 7 | 6887 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_on
eof_index(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorP
roto_is(m)); return upb_msgdef_itof(m, 9); } |
| 6437 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_ENDSTR 8 | 6888 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_op
tions(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto
_is(m)); return upb_msgdef_itof(m, 8); } |
| 6438 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_STRING 9 | 6889 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_ty
pe(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is
(m)); return upb_msgdef_itof(m, 5); } |
| 6439 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_STARTSTR 10 | 6890 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_ty
pe_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorPro
to_is(m)); return upb_msgdef_itof(m, 6); } |
| 6440 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_ENDSTR 11 | 6891 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(cons
t upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return up
b_msgdef_itof(m, 1); } |
| 6441 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_OPTIMIZE_FOR_INT32 12 | 6892 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated
(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); retu
rn upb_msgdef_itof(m, 3); } |
| 6442 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_MULTIPLE_FILES_BOOL 13 | 6893 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(con
st upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return u
pb_msgdef_itof(m, 6); } |
| 6443 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_GO_PACKAGE_STRING 14 | 6894 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const
upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb
_msgdef_itof(m, 5); } |
| 6444 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_GO_PACKAGE_STARTSTR 15 | 6895 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(con
st upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return u
pb_msgdef_itof(m, 2); } |
| 6445 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_GO_PACKAGE_ENDSTR 16 | 6896 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpre
ted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is
(m)); return upb_msgdef_itof(m, 999); } |
| 6446 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_CC_GENERIC_SERVICES_BOOL 17 | 6897 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const
upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb
_msgdef_itof(m, 10); } |
| 6447 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERIC_SERVICES_BOOL 18 | 6898 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dep
endency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProt
o_is(m)); return upb_msgdef_itof(m, 3); } |
| 6448 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_PY_GENERIC_SERVICES_BOOL 19 | 6899 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enu
m_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto
_is(m)); return upb_msgdef_itof(m, 5); } |
| 6449 #define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERATE_EQUALS_AND_HASH_BOOL 20 | 6900 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_ext
ension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto
_is(m)); return upb_msgdef_itof(m, 7); } |
| 6450 | 6901 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_mes
sage_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorPr
oto_is(m)); return upb_msgdef_itof(m, 4); } |
| 6451 /* google.protobuf.MessageOptions */ | 6902 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_nam
e(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m
)); return upb_msgdef_itof(m, 1); } |
| 6452 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2 | 6903 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_opt
ions(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_i
s(m)); return upb_msgdef_itof(m, 8); } |
| 6453 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3 | 6904 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_pac
kage(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_i
s(m)); return upb_msgdef_itof(m, 2); } |
| 6454 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4 | 6905 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_pub
lic_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescrip
torProto_is(m)); return upb_msgdef_itof(m, 10); } |
| 6455 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5 | 6906 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_ser
vice(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_i
s(m)); return upb_msgdef_itof(m, 6); } |
| 6456 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_MESSAGE_SET_WIRE_FORMAT_BOOL 6 | 6907 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_sou
rce_code_info(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescript
orProto_is(m)); return upb_msgdef_itof(m, 9); } |
| 6457 #define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_NO_STANDARD_DESCRIPTOR_ACCESSOR_BOOL
7 | 6908 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syn
tax(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is
(m)); return upb_msgdef_itof(m, 12); } |
| 6458 | 6909 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_wea
k_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescripto
rProto_is(m)); return upb_msgdef_itof(m, 11); } |
| 6459 /* google.protobuf.MethodDescriptorProto */ | 6910 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file(
const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorSet_is(m));
return upb_msgdef_itof(m, 1); } |
| 6460 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2 | 6911 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_a
renas(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m));
return upb_msgdef_itof(m, 31); } |
| 6461 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 3 | 6912 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_
services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)
); return upb_msgdef_itof(m, 16); } |
| 6462 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_STRING 4 | 6913 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_name
space(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m));
return upb_msgdef_itof(m, 37); } |
| 6463 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_STARTSTR 5 | 6914 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated(
const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return
upb_msgdef_itof(m, 23); } |
| 6464 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_ENDSTR 6 | 6915 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package(
const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return
upb_msgdef_itof(m, 11); } |
| 6465 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_STRING 7 | 6916 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_genera
te_equals_and_hash(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOpt
ions_is(m)); return upb_msgdef_itof(m, 20); } |
| 6466 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_STARTSTR 8 | 6917 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generi
c_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(
m)); return upb_msgdef_itof(m, 17); } |
| 6467 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_ENDSTR 9 | 6918 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multip
le_files(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)
); return upb_msgdef_itof(m, 10); } |
| 6468 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STRING 10 | 6919 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_
classname(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m
)); return upb_msgdef_itof(m, 8); } |
| 6469 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STARTSTR 11 | 6920 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_packag
e(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); retu
rn upb_msgdef_itof(m, 1); } |
| 6470 #define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_ENDSTR 12 | 6921 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string
_check_utf8(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is
(m)); return upb_msgdef_itof(m, 27); } |
| 6471 | 6922 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_us
e_deprecated_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileO
ptions_is(m)); return upb_msgdef_itof(m, 38); } |
| 6472 /* google.protobuf.MethodOptions */ | 6923 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_
prefix(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m));
return upb_msgdef_itof(m, 36); } |
| 6473 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2 | 6924 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_fo
r(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); retu
rn upb_msgdef_itof(m, 9); } |
| 6474 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3 | 6925 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_
services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)
); return upb_msgdef_itof(m, 18); } |
| 6475 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4 | 6926 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpret
ed_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m
)); return upb_msgdef_itof(m, 999); } |
| 6476 #define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5 | 6927 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecat
ed(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m));
return upb_msgdef_itof(m, 3); } |
| 6477 | 6928 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entr
y(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); r
eturn upb_msgdef_itof(m, 7); } |
| 6478 /* google.protobuf.ServiceDescriptorProto */ | 6929 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_
set_wire_format(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOpt
ions_is(m)); return upb_msgdef_itof(m, 1); } |
| 6479 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSUBMSG 2 | 6930 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_stand
ard_descriptor_accessor(const upb_msgdef *m) { assert(upbdefs_google_protobuf_Me
ssageOptions_is(m)); return upb_msgdef_itof(m, 2); } |
| 6480 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 3 | 6931 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterp
reted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOption
s_is(m)); return upb_msgdef_itof(m, 999); } |
| 6481 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSEQ 4 | 6932 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_c
lient_streaming(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDesc
riptorProto_is(m)); return upb_msgdef_itof(m, 5); } |
| 6482 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_ENDSEQ 5 | 6933 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_i
nput_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptor
Proto_is(m)); return upb_msgdef_itof(m, 2); } |
| 6483 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_ENDSUBMSG 6 | 6934 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_n
ame(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_
is(m)); return upb_msgdef_itof(m, 1); } |
| 6484 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 7 | 6935 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_o
ptions(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorPro
to_is(m)); return upb_msgdef_itof(m, 4); } |
| 6485 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_STRING 8 | 6936 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_o
utput_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescripto
rProto_is(m)); return upb_msgdef_itof(m, 3); } |
| 6486 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_STARTSTR 9 | 6937 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_s
erver_streaming(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDesc
riptorProto_is(m)); return upb_msgdef_itof(m, 6); } |
| 6487 #define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_ENDSTR 10 | 6938 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecate
d(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodOptions_is(m)); re
turn upb_msgdef_itof(m, 33); } |
| 6488 | 6939 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpr
eted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodOptions_
is(m)); return upb_msgdef_itof(m, 999); } |
| 6489 /* google.protobuf.ServiceOptions */ | 6940 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_na
me(const upb_msgdef *m) { assert(upbdefs_google_protobuf_OneofDescriptorProto_is
(m)); return upb_msgdef_itof(m, 1); } |
| 6490 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2 | 6941 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_
method(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorPr
oto_is(m)); return upb_msgdef_itof(m, 2); } |
| 6491 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3 | 6942 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_
name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProt
o_is(m)); return upb_msgdef_itof(m, 1); } |
| 6492 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4 | 6943 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_
options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorP
roto_is(m)); return upb_msgdef_itof(m, 3); } |
| 6493 #define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5 | 6944 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecat
ed(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceOptions_is(m));
return upb_msgdef_itof(m, 33); } |
| 6494 | 6945 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterp
reted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceOption
s_is(m)); return upb_msgdef_itof(m, 999); } |
| 6495 /* google.protobuf.SourceCodeInfo */ | 6946 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f
_leading_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCo
deInfo_Location_is(m)); return upb_msgdef_itof(m, 3); } |
| 6496 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSUBMSG 2 | 6947 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f
_leading_detached_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf
_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 6); } |
| 6497 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSEQ 3 | 6948 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f
_path(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Locat
ion_is(m)); return upb_msgdef_itof(m, 1); } |
| 6498 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_ENDSEQ 4 | 6949 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f
_span(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Locat
ion_is(m)); return upb_msgdef_itof(m, 2); } |
| 6499 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_ENDSUBMSG 5 | 6950 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f
_trailing_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceC
odeInfo_Location_is(m)); return upb_msgdef_itof(m, 4); } |
| 6500 | 6951 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location
(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_is(m)); re
turn upb_msgdef_itof(m, 1); } |
| 6501 /* google.protobuf.SourceCodeInfo.Location */ | 6952 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NameP
art_f_is_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_Uninter
pretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 2); } |
| 6502 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_STARTSEQ 2 | 6953 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NameP
art_f_name_part(const upb_msgdef *m) { assert(upbdefs_google_protobuf_Uninterpre
tedOption_NamePart_is(m)); return upb_msgdef_itof(m, 1); } |
| 6503 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_ENDSEQ 3 | 6954 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_agg
regate_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_Uninterpreted
Option_is(m)); return upb_msgdef_itof(m, 8); } |
| 6504 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_INT32 4 | 6955 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_dou
ble_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOpt
ion_is(m)); return upb_msgdef_itof(m, 6); } |
| 6505 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_STARTSEQ 5 | 6956 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_ide
ntifier_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_Uninterprete
dOption_is(m)); return upb_msgdef_itof(m, 3); } |
| 6506 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_ENDSEQ 6 | 6957 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_nam
e(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m
)); return upb_msgdef_itof(m, 2); } |
| 6507 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_INT32 7 | 6958 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_neg
ative_int_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_Uninterpre
tedOption_is(m)); return upb_msgdef_itof(m, 5); } |
| 6508 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_COMMENTS_STRING 8 | 6959 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_pos
itive_int_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_Uninterpre
tedOption_is(m)); return upb_msgdef_itof(m, 4); } |
| 6509 #define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_COMMENTS_STARTSTR 9 | 6960 UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_str
ing_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOpt
ion_is(m)); return upb_msgdef_itof(m, 7); } |
| 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); } | |
| 6747 | 6961 |
| 6748 UPB_END_EXTERN_C | 6962 UPB_END_EXTERN_C |
| 6749 | 6963 |
| 6750 #ifdef __cplusplus | 6964 #ifdef __cplusplus |
| 6751 | 6965 |
| 6752 namespace upbdefs { | 6966 namespace upbdefs { |
| 6753 namespace google { | 6967 namespace google { |
| 6754 namespace protobuf { | 6968 namespace protobuf { |
| 6755 namespace descriptor { | 6969 |
| 6756 inline upb::reffed_ptr<const upb::SymbolTable> SymbolTable() { | 6970 class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 6757 const upb::SymbolTable* s = upbdefs_google_protobuf_descriptor(&s); | 6971 public: |
| 6758 return upb::reffed_ptr<const upb::SymbolTable>(s, &s); | 6972 DescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 6759 } | 6973 : reffed_ptr(m, ref_donor) { |
| 6760 } /* namespace descriptor */ | 6974 assert(upbdefs_google_protobuf_DescriptorProto_is(m)); |
| 6975 } |
| 6976 |
| 6977 static DescriptorProto get() { |
| 6978 const ::upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_get(&m)
; |
| 6979 return DescriptorProto(m, &m); |
| 6980 } |
| 6981 |
| 6982 class ExtensionRange : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 6983 public: |
| 6984 ExtensionRange(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 6985 : reffed_ptr(m, ref_donor) { |
| 6986 assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); |
| 6987 } |
| 6988 |
| 6989 static ExtensionRange get() { |
| 6990 const ::upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_Exten
sionRange_get(&m); |
| 6991 return ExtensionRange(m, &m); |
| 6992 } |
| 6993 }; |
| 6994 |
| 6995 class ReservedRange : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 6996 public: |
| 6997 ReservedRange(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 6998 : reffed_ptr(m, ref_donor) { |
| 6999 assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); |
| 7000 } |
| 7001 |
| 7002 static ReservedRange get() { |
| 7003 const ::upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_Reser
vedRange_get(&m); |
| 7004 return ReservedRange(m, &m); |
| 7005 } |
| 7006 }; |
| 7007 }; |
| 7008 |
| 7009 class EnumDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7010 public: |
| 7011 EnumDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7012 : reffed_ptr(m, ref_donor) { |
| 7013 assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); |
| 7014 } |
| 7015 |
| 7016 static EnumDescriptorProto get() { |
| 7017 const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumDescriptorProto_get
(&m); |
| 7018 return EnumDescriptorProto(m, &m); |
| 7019 } |
| 7020 }; |
| 7021 |
| 7022 class EnumOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7023 public: |
| 7024 EnumOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7025 : reffed_ptr(m, ref_donor) { |
| 7026 assert(upbdefs_google_protobuf_EnumOptions_is(m)); |
| 7027 } |
| 7028 |
| 7029 static EnumOptions get() { |
| 7030 const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumOptions_get(&m); |
| 7031 return EnumOptions(m, &m); |
| 7032 } |
| 7033 }; |
| 7034 |
| 7035 class EnumValueDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDe
f> { |
| 7036 public: |
| 7037 EnumValueDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = N
ULL) |
| 7038 : reffed_ptr(m, ref_donor) { |
| 7039 assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); |
| 7040 } |
| 7041 |
| 7042 static EnumValueDescriptorProto get() { |
| 7043 const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumValueDescriptorProt
o_get(&m); |
| 7044 return EnumValueDescriptorProto(m, &m); |
| 7045 } |
| 7046 }; |
| 7047 |
| 7048 class EnumValueOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7049 public: |
| 7050 EnumValueOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7051 : reffed_ptr(m, ref_donor) { |
| 7052 assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); |
| 7053 } |
| 7054 |
| 7055 static EnumValueOptions get() { |
| 7056 const ::upb::MessageDef* m = upbdefs_google_protobuf_EnumValueOptions_get(&m
); |
| 7057 return EnumValueOptions(m, &m); |
| 7058 } |
| 7059 }; |
| 7060 |
| 7061 class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7062 public: |
| 7063 FieldDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7064 : reffed_ptr(m, ref_donor) { |
| 7065 assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); |
| 7066 } |
| 7067 |
| 7068 static FieldDescriptorProto get() { |
| 7069 const ::upb::MessageDef* m = upbdefs_google_protobuf_FieldDescriptorProto_ge
t(&m); |
| 7070 return FieldDescriptorProto(m, &m); |
| 7071 } |
| 7072 |
| 7073 class Label : public ::upb::reffed_ptr<const ::upb::EnumDef> { |
| 7074 public: |
| 7075 Label(const ::upb::EnumDef* e, const void *ref_donor = NULL) |
| 7076 : reffed_ptr(e, ref_donor) { |
| 7077 assert(upbdefs_google_protobuf_FieldDescriptorProto_Label_is(e)); |
| 7078 } |
| 7079 static Label get() { |
| 7080 const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Lab
el_get(&e); |
| 7081 return Label(e, &e); |
| 7082 } |
| 7083 }; |
| 7084 |
| 7085 class Type : public ::upb::reffed_ptr<const ::upb::EnumDef> { |
| 7086 public: |
| 7087 Type(const ::upb::EnumDef* e, const void *ref_donor = NULL) |
| 7088 : reffed_ptr(e, ref_donor) { |
| 7089 assert(upbdefs_google_protobuf_FieldDescriptorProto_Type_is(e)); |
| 7090 } |
| 7091 static Type get() { |
| 7092 const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Typ
e_get(&e); |
| 7093 return Type(e, &e); |
| 7094 } |
| 7095 }; |
| 7096 }; |
| 7097 |
| 7098 class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7099 public: |
| 7100 FieldOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7101 : reffed_ptr(m, ref_donor) { |
| 7102 assert(upbdefs_google_protobuf_FieldOptions_is(m)); |
| 7103 } |
| 7104 |
| 7105 static FieldOptions get() { |
| 7106 const ::upb::MessageDef* m = upbdefs_google_protobuf_FieldOptions_get(&m); |
| 7107 return FieldOptions(m, &m); |
| 7108 } |
| 7109 |
| 7110 class CType : public ::upb::reffed_ptr<const ::upb::EnumDef> { |
| 7111 public: |
| 7112 CType(const ::upb::EnumDef* e, const void *ref_donor = NULL) |
| 7113 : reffed_ptr(e, ref_donor) { |
| 7114 assert(upbdefs_google_protobuf_FieldOptions_CType_is(e)); |
| 7115 } |
| 7116 static CType get() { |
| 7117 const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_CType_get(&
e); |
| 7118 return CType(e, &e); |
| 7119 } |
| 7120 }; |
| 7121 |
| 7122 class JSType : public ::upb::reffed_ptr<const ::upb::EnumDef> { |
| 7123 public: |
| 7124 JSType(const ::upb::EnumDef* e, const void *ref_donor = NULL) |
| 7125 : reffed_ptr(e, ref_donor) { |
| 7126 assert(upbdefs_google_protobuf_FieldOptions_JSType_is(e)); |
| 7127 } |
| 7128 static JSType get() { |
| 7129 const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_JSType_get(
&e); |
| 7130 return JSType(e, &e); |
| 7131 } |
| 7132 }; |
| 7133 }; |
| 7134 |
| 7135 class FileDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7136 public: |
| 7137 FileDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7138 : reffed_ptr(m, ref_donor) { |
| 7139 assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); |
| 7140 } |
| 7141 |
| 7142 static FileDescriptorProto get() { |
| 7143 const ::upb::MessageDef* m = upbdefs_google_protobuf_FileDescriptorProto_get
(&m); |
| 7144 return FileDescriptorProto(m, &m); |
| 7145 } |
| 7146 }; |
| 7147 |
| 7148 class FileDescriptorSet : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7149 public: |
| 7150 FileDescriptorSet(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7151 : reffed_ptr(m, ref_donor) { |
| 7152 assert(upbdefs_google_protobuf_FileDescriptorSet_is(m)); |
| 7153 } |
| 7154 |
| 7155 static FileDescriptorSet get() { |
| 7156 const ::upb::MessageDef* m = upbdefs_google_protobuf_FileDescriptorSet_get(&
m); |
| 7157 return FileDescriptorSet(m, &m); |
| 7158 } |
| 7159 }; |
| 7160 |
| 7161 class FileOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7162 public: |
| 7163 FileOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7164 : reffed_ptr(m, ref_donor) { |
| 7165 assert(upbdefs_google_protobuf_FileOptions_is(m)); |
| 7166 } |
| 7167 |
| 7168 static FileOptions get() { |
| 7169 const ::upb::MessageDef* m = upbdefs_google_protobuf_FileOptions_get(&m); |
| 7170 return FileOptions(m, &m); |
| 7171 } |
| 7172 |
| 7173 class OptimizeMode : public ::upb::reffed_ptr<const ::upb::EnumDef> { |
| 7174 public: |
| 7175 OptimizeMode(const ::upb::EnumDef* e, const void *ref_donor = NULL) |
| 7176 : reffed_ptr(e, ref_donor) { |
| 7177 assert(upbdefs_google_protobuf_FileOptions_OptimizeMode_is(e)); |
| 7178 } |
| 7179 static OptimizeMode get() { |
| 7180 const ::upb::EnumDef* e = upbdefs_google_protobuf_FileOptions_OptimizeMode
_get(&e); |
| 7181 return OptimizeMode(e, &e); |
| 7182 } |
| 7183 }; |
| 7184 }; |
| 7185 |
| 7186 class MessageOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7187 public: |
| 7188 MessageOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7189 : reffed_ptr(m, ref_donor) { |
| 7190 assert(upbdefs_google_protobuf_MessageOptions_is(m)); |
| 7191 } |
| 7192 |
| 7193 static MessageOptions get() { |
| 7194 const ::upb::MessageDef* m = upbdefs_google_protobuf_MessageOptions_get(&m); |
| 7195 return MessageOptions(m, &m); |
| 7196 } |
| 7197 }; |
| 7198 |
| 7199 class MethodDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef>
{ |
| 7200 public: |
| 7201 MethodDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL
) |
| 7202 : reffed_ptr(m, ref_donor) { |
| 7203 assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); |
| 7204 } |
| 7205 |
| 7206 static MethodDescriptorProto get() { |
| 7207 const ::upb::MessageDef* m = upbdefs_google_protobuf_MethodDescriptorProto_g
et(&m); |
| 7208 return MethodDescriptorProto(m, &m); |
| 7209 } |
| 7210 }; |
| 7211 |
| 7212 class MethodOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7213 public: |
| 7214 MethodOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7215 : reffed_ptr(m, ref_donor) { |
| 7216 assert(upbdefs_google_protobuf_MethodOptions_is(m)); |
| 7217 } |
| 7218 |
| 7219 static MethodOptions get() { |
| 7220 const ::upb::MessageDef* m = upbdefs_google_protobuf_MethodOptions_get(&m); |
| 7221 return MethodOptions(m, &m); |
| 7222 } |
| 7223 }; |
| 7224 |
| 7225 class OneofDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7226 public: |
| 7227 OneofDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7228 : reffed_ptr(m, ref_donor) { |
| 7229 assert(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); |
| 7230 } |
| 7231 |
| 7232 static OneofDescriptorProto get() { |
| 7233 const ::upb::MessageDef* m = upbdefs_google_protobuf_OneofDescriptorProto_ge
t(&m); |
| 7234 return OneofDescriptorProto(m, &m); |
| 7235 } |
| 7236 }; |
| 7237 |
| 7238 class ServiceDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef>
{ |
| 7239 public: |
| 7240 ServiceDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NUL
L) |
| 7241 : reffed_ptr(m, ref_donor) { |
| 7242 assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); |
| 7243 } |
| 7244 |
| 7245 static ServiceDescriptorProto get() { |
| 7246 const ::upb::MessageDef* m = upbdefs_google_protobuf_ServiceDescriptorProto_
get(&m); |
| 7247 return ServiceDescriptorProto(m, &m); |
| 7248 } |
| 7249 }; |
| 7250 |
| 7251 class ServiceOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7252 public: |
| 7253 ServiceOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7254 : reffed_ptr(m, ref_donor) { |
| 7255 assert(upbdefs_google_protobuf_ServiceOptions_is(m)); |
| 7256 } |
| 7257 |
| 7258 static ServiceOptions get() { |
| 7259 const ::upb::MessageDef* m = upbdefs_google_protobuf_ServiceOptions_get(&m); |
| 7260 return ServiceOptions(m, &m); |
| 7261 } |
| 7262 }; |
| 7263 |
| 7264 class SourceCodeInfo : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7265 public: |
| 7266 SourceCodeInfo(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7267 : reffed_ptr(m, ref_donor) { |
| 7268 assert(upbdefs_google_protobuf_SourceCodeInfo_is(m)); |
| 7269 } |
| 7270 |
| 7271 static SourceCodeInfo get() { |
| 7272 const ::upb::MessageDef* m = upbdefs_google_protobuf_SourceCodeInfo_get(&m); |
| 7273 return SourceCodeInfo(m, &m); |
| 7274 } |
| 7275 |
| 7276 class Location : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7277 public: |
| 7278 Location(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7279 : reffed_ptr(m, ref_donor) { |
| 7280 assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); |
| 7281 } |
| 7282 |
| 7283 static Location get() { |
| 7284 const ::upb::MessageDef* m = upbdefs_google_protobuf_SourceCodeInfo_Locati
on_get(&m); |
| 7285 return Location(m, &m); |
| 7286 } |
| 7287 }; |
| 7288 }; |
| 7289 |
| 7290 class UninterpretedOption : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7291 public: |
| 7292 UninterpretedOption(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7293 : reffed_ptr(m, ref_donor) { |
| 7294 assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); |
| 7295 } |
| 7296 |
| 7297 static UninterpretedOption get() { |
| 7298 const ::upb::MessageDef* m = upbdefs_google_protobuf_UninterpretedOption_get
(&m); |
| 7299 return UninterpretedOption(m, &m); |
| 7300 } |
| 7301 |
| 7302 class NamePart : public ::upb::reffed_ptr<const ::upb::MessageDef> { |
| 7303 public: |
| 7304 NamePart(const ::upb::MessageDef* m, const void *ref_donor = NULL) |
| 7305 : reffed_ptr(m, ref_donor) { |
| 7306 assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); |
| 7307 } |
| 7308 |
| 7309 static NamePart get() { |
| 7310 const ::upb::MessageDef* m = upbdefs_google_protobuf_UninterpretedOption_N
amePart_get(&m); |
| 7311 return NamePart(m, &m); |
| 7312 } |
| 7313 }; |
| 7314 }; |
| 7315 |
| 6761 } /* namespace protobuf */ | 7316 } /* namespace protobuf */ |
| 6762 } /* namespace google */ | 7317 } /* namespace google */ |
| 6763 | |
| 6764 #define RETURN_REFFED(type, func) \ | |
| 6765 const type* obj = func(upbdefs::google::protobuf::descriptor::SymbolTable().
get()); \ | |
| 6766 return upb::reffed_ptr<const type>(obj); | |
| 6767 | |
| 6768 namespace google { | |
| 6769 namespace protobuf { | |
| 6770 namespace DescriptorProto { | |
| 6771 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_DescriptorProto) } | |
| 6772 inline upb::reffed_ptr<const upb::FieldDef> enum_type() { RETURN_REFFED(upb::Fie
ldDef, upbdefs_google_protobuf_DescriptorProto_enum_type) } | |
| 6773 inline upb::reffed_ptr<const upb::FieldDef> extension() { RETURN_REFFED(upb::Fie
ldDef, upbdefs_google_protobuf_DescriptorProto_extension) } | |
| 6774 inline upb::reffed_ptr<const upb::FieldDef> extension_range() { RETURN_REFFED(up
b::FieldDef, upbdefs_google_protobuf_DescriptorProto_extension_range) } | |
| 6775 inline upb::reffed_ptr<const upb::FieldDef> field() { RETURN_REFFED(upb::FieldDe
f, upbdefs_google_protobuf_DescriptorProto_field) } | |
| 6776 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_DescriptorProto_name) } | |
| 6777 inline upb::reffed_ptr<const upb::FieldDef> nested_type() { RETURN_REFFED(upb::F
ieldDef, upbdefs_google_protobuf_DescriptorProto_nested_type) } | |
| 6778 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field
Def, upbdefs_google_protobuf_DescriptorProto_options) } | |
| 6779 } /* namespace DescriptorProto */ | |
| 6780 } /* namespace protobuf */ | |
| 6781 } /* namespace google */ | |
| 6782 | |
| 6783 namespace google { | |
| 6784 namespace protobuf { | |
| 6785 namespace DescriptorProto { | |
| 6786 namespace ExtensionRange { | |
| 6787 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_DescriptorProto_ExtensionRange) } | |
| 6788 inline upb::reffed_ptr<const upb::FieldDef> end() { RETURN_REFFED(upb::FieldDef,
upbdefs_google_protobuf_DescriptorProto_ExtensionRange_end) } | |
| 6789 inline upb::reffed_ptr<const upb::FieldDef> start() { RETURN_REFFED(upb::FieldDe
f, upbdefs_google_protobuf_DescriptorProto_ExtensionRange_start) } | |
| 6790 } /* namespace ExtensionRange */ | |
| 6791 } /* namespace DescriptorProto */ | |
| 6792 } /* namespace protobuf */ | |
| 6793 } /* namespace google */ | |
| 6794 | |
| 6795 namespace google { | |
| 6796 namespace protobuf { | |
| 6797 namespace EnumDescriptorProto { | |
| 6798 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_EnumDescriptorProto) } | |
| 6799 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_EnumDescriptorProto_name) } | |
| 6800 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field
Def, upbdefs_google_protobuf_EnumDescriptorProto_options) } | |
| 6801 inline upb::reffed_ptr<const upb::FieldDef> value() { RETURN_REFFED(upb::FieldDe
f, upbdefs_google_protobuf_EnumDescriptorProto_value) } | |
| 6802 } /* namespace EnumDescriptorProto */ | |
| 6803 } /* namespace protobuf */ | |
| 6804 } /* namespace google */ | |
| 6805 | |
| 6806 namespace google { | |
| 6807 namespace protobuf { | |
| 6808 namespace EnumOptions { | |
| 6809 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_EnumOptions) } | |
| 6810 inline upb::reffed_ptr<const upb::FieldDef> allow_alias() { RETURN_REFFED(upb::F
ieldDef, upbdefs_google_protobuf_EnumOptions_allow_alias) } | |
| 6811 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF
ED(upb::FieldDef, upbdefs_google_protobuf_EnumOptions_uninterpreted_option) } | |
| 6812 } /* namespace EnumOptions */ | |
| 6813 } /* namespace protobuf */ | |
| 6814 } /* namespace google */ | |
| 6815 | |
| 6816 namespace google { | |
| 6817 namespace protobuf { | |
| 6818 namespace EnumValueDescriptorProto { | |
| 6819 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_EnumValueDescriptorProto) } | |
| 6820 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_EnumValueDescriptorProto_name) } | |
| 6821 inline upb::reffed_ptr<const upb::FieldDef> number() { RETURN_REFFED(upb::FieldD
ef, upbdefs_google_protobuf_EnumValueDescriptorProto_number) } | |
| 6822 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field
Def, upbdefs_google_protobuf_EnumValueDescriptorProto_options) } | |
| 6823 } /* namespace EnumValueDescriptorProto */ | |
| 6824 } /* namespace protobuf */ | |
| 6825 } /* namespace google */ | |
| 6826 | |
| 6827 namespace google { | |
| 6828 namespace protobuf { | |
| 6829 namespace EnumValueOptions { | |
| 6830 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_EnumValueOptions) } | |
| 6831 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF
ED(upb::FieldDef, upbdefs_google_protobuf_EnumValueOptions_uninterpreted_option)
} | |
| 6832 } /* namespace EnumValueOptions */ | |
| 6833 } /* namespace protobuf */ | |
| 6834 } /* namespace google */ | |
| 6835 | |
| 6836 namespace google { | |
| 6837 namespace protobuf { | |
| 6838 namespace FieldDescriptorProto { | |
| 6839 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_FieldDescriptorProto) } | |
| 6840 inline upb::reffed_ptr<const upb::FieldDef> default_value() { RETURN_REFFED(upb:
:FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_default_value) } | |
| 6841 inline upb::reffed_ptr<const upb::FieldDef> extendee() { RETURN_REFFED(upb::Fiel
dDef, upbdefs_google_protobuf_FieldDescriptorProto_extendee) } | |
| 6842 inline upb::reffed_ptr<const upb::FieldDef> label() { RETURN_REFFED(upb::FieldDe
f, upbdefs_google_protobuf_FieldDescriptorProto_label) } | |
| 6843 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_FieldDescriptorProto_name) } | |
| 6844 inline upb::reffed_ptr<const upb::FieldDef> number() { RETURN_REFFED(upb::FieldD
ef, upbdefs_google_protobuf_FieldDescriptorProto_number) } | |
| 6845 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field
Def, upbdefs_google_protobuf_FieldDescriptorProto_options) } | |
| 6846 inline upb::reffed_ptr<const upb::FieldDef> type() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_FieldDescriptorProto_type) } | |
| 6847 inline upb::reffed_ptr<const upb::FieldDef> type_name() { RETURN_REFFED(upb::Fie
ldDef, upbdefs_google_protobuf_FieldDescriptorProto_type_name) } | |
| 6848 inline upb::reffed_ptr<const upb::EnumDef> Label() { RETURN_REFFED(upb::EnumDef,
upbdefs_google_protobuf_FieldDescriptorProto_Label) } | |
| 6849 inline upb::reffed_ptr<const upb::EnumDef> Type() { RETURN_REFFED(upb::EnumDef,
upbdefs_google_protobuf_FieldDescriptorProto_Type) } | |
| 6850 } /* namespace FieldDescriptorProto */ | |
| 6851 } /* namespace protobuf */ | |
| 6852 } /* namespace google */ | |
| 6853 | |
| 6854 namespace google { | |
| 6855 namespace protobuf { | |
| 6856 namespace FieldOptions { | |
| 6857 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_FieldOptions) } | |
| 6858 inline upb::reffed_ptr<const upb::FieldDef> ctype() { RETURN_REFFED(upb::FieldDe
f, upbdefs_google_protobuf_FieldOptions_ctype) } | |
| 6859 inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::Fi
eldDef, upbdefs_google_protobuf_FieldOptions_deprecated) } | |
| 6860 inline upb::reffed_ptr<const upb::FieldDef> experimental_map_key() { RETURN_REFF
ED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_experimental_map_key) } | |
| 6861 inline upb::reffed_ptr<const upb::FieldDef> lazy() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_FieldOptions_lazy) } | |
| 6862 inline upb::reffed_ptr<const upb::FieldDef> packed() { RETURN_REFFED(upb::FieldD
ef, upbdefs_google_protobuf_FieldOptions_packed) } | |
| 6863 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF
ED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_uninterpreted_option) } | |
| 6864 inline upb::reffed_ptr<const upb::FieldDef> weak() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_FieldOptions_weak) } | |
| 6865 inline upb::reffed_ptr<const upb::EnumDef> CType() { RETURN_REFFED(upb::EnumDef,
upbdefs_google_protobuf_FieldOptions_CType) } | |
| 6866 } /* namespace FieldOptions */ | |
| 6867 } /* namespace protobuf */ | |
| 6868 } /* namespace google */ | |
| 6869 | |
| 6870 namespace google { | |
| 6871 namespace protobuf { | |
| 6872 namespace FileDescriptorProto { | |
| 6873 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_FileDescriptorProto) } | |
| 6874 inline upb::reffed_ptr<const upb::FieldDef> dependency() { RETURN_REFFED(upb::Fi
eldDef, upbdefs_google_protobuf_FileDescriptorProto_dependency) } | |
| 6875 inline upb::reffed_ptr<const upb::FieldDef> enum_type() { RETURN_REFFED(upb::Fie
ldDef, upbdefs_google_protobuf_FileDescriptorProto_enum_type) } | |
| 6876 inline upb::reffed_ptr<const upb::FieldDef> extension() { RETURN_REFFED(upb::Fie
ldDef, upbdefs_google_protobuf_FileDescriptorProto_extension) } | |
| 6877 inline upb::reffed_ptr<const upb::FieldDef> message_type() { RETURN_REFFED(upb::
FieldDef, upbdefs_google_protobuf_FileDescriptorProto_message_type) } | |
| 6878 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_FileDescriptorProto_name) } | |
| 6879 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field
Def, upbdefs_google_protobuf_FileDescriptorProto_options) } | |
| 6880 inline upb::reffed_ptr<const upb::FieldDef> package() { RETURN_REFFED(upb::Field
Def, upbdefs_google_protobuf_FileDescriptorProto_package) } | |
| 6881 inline upb::reffed_ptr<const upb::FieldDef> public_dependency() { RETURN_REFFED(
upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_public_dependency) } | |
| 6882 inline upb::reffed_ptr<const upb::FieldDef> service() { RETURN_REFFED(upb::Field
Def, upbdefs_google_protobuf_FileDescriptorProto_service) } | |
| 6883 inline upb::reffed_ptr<const upb::FieldDef> source_code_info() { RETURN_REFFED(u
pb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_source_code_info) } | |
| 6884 inline upb::reffed_ptr<const upb::FieldDef> weak_dependency() { RETURN_REFFED(up
b::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_weak_dependency) } | |
| 6885 } /* namespace FileDescriptorProto */ | |
| 6886 } /* namespace protobuf */ | |
| 6887 } /* namespace google */ | |
| 6888 | |
| 6889 namespace google { | |
| 6890 namespace protobuf { | |
| 6891 namespace FileDescriptorSet { | |
| 6892 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_FileDescriptorSet) } | |
| 6893 inline upb::reffed_ptr<const upb::FieldDef> file() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_FileDescriptorSet_file) } | |
| 6894 } /* namespace FileDescriptorSet */ | |
| 6895 } /* namespace protobuf */ | |
| 6896 } /* namespace google */ | |
| 6897 | |
| 6898 namespace google { | |
| 6899 namespace protobuf { | |
| 6900 namespace FileOptions { | |
| 6901 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_FileOptions) } | |
| 6902 inline upb::reffed_ptr<const upb::FieldDef> cc_generic_services() { RETURN_REFFE
D(upb::FieldDef, upbdefs_google_protobuf_FileOptions_cc_generic_services) } | |
| 6903 inline upb::reffed_ptr<const upb::FieldDef> go_package() { RETURN_REFFED(upb::Fi
eldDef, upbdefs_google_protobuf_FileOptions_go_package) } | |
| 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) } | |
| 6905 inline upb::reffed_ptr<const upb::FieldDef> java_generic_services() { RETURN_REF
FED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_generic_services) } | |
| 6906 inline upb::reffed_ptr<const upb::FieldDef> java_multiple_files() { RETURN_REFFE
D(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_multiple_files) } | |
| 6907 inline upb::reffed_ptr<const upb::FieldDef> java_outer_classname() { RETURN_REFF
ED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_outer_classname) } | |
| 6908 inline upb::reffed_ptr<const upb::FieldDef> java_package() { RETURN_REFFED(upb::
FieldDef, upbdefs_google_protobuf_FileOptions_java_package) } | |
| 6909 inline upb::reffed_ptr<const upb::FieldDef> optimize_for() { RETURN_REFFED(upb::
FieldDef, upbdefs_google_protobuf_FileOptions_optimize_for) } | |
| 6910 inline upb::reffed_ptr<const upb::FieldDef> py_generic_services() { RETURN_REFFE
D(upb::FieldDef, upbdefs_google_protobuf_FileOptions_py_generic_services) } | |
| 6911 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF
ED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_uninterpreted_option) } | |
| 6912 inline upb::reffed_ptr<const upb::EnumDef> OptimizeMode() { RETURN_REFFED(upb::E
numDef, upbdefs_google_protobuf_FileOptions_OptimizeMode) } | |
| 6913 } /* namespace FileOptions */ | |
| 6914 } /* namespace protobuf */ | |
| 6915 } /* namespace google */ | |
| 6916 | |
| 6917 namespace google { | |
| 6918 namespace protobuf { | |
| 6919 namespace MessageOptions { | |
| 6920 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_MessageOptions) } | |
| 6921 inline upb::reffed_ptr<const upb::FieldDef> message_set_wire_format() { RETURN_R
EFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_message_set_wire_for
mat) } | |
| 6922 inline upb::reffed_ptr<const upb::FieldDef> no_standard_descriptor_accessor() {
RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_no_standard_
descriptor_accessor) } | |
| 6923 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF
ED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_uninterpreted_option) } | |
| 6924 } /* namespace MessageOptions */ | |
| 6925 } /* namespace protobuf */ | |
| 6926 } /* namespace google */ | |
| 6927 | |
| 6928 namespace google { | |
| 6929 namespace protobuf { | |
| 6930 namespace MethodDescriptorProto { | |
| 6931 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_MethodDescriptorProto) } | |
| 6932 inline upb::reffed_ptr<const upb::FieldDef> input_type() { RETURN_REFFED(upb::Fi
eldDef, upbdefs_google_protobuf_MethodDescriptorProto_input_type) } | |
| 6933 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_MethodDescriptorProto_name) } | |
| 6934 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field
Def, upbdefs_google_protobuf_MethodDescriptorProto_options) } | |
| 6935 inline upb::reffed_ptr<const upb::FieldDef> output_type() { RETURN_REFFED(upb::F
ieldDef, upbdefs_google_protobuf_MethodDescriptorProto_output_type) } | |
| 6936 } /* namespace MethodDescriptorProto */ | |
| 6937 } /* namespace protobuf */ | |
| 6938 } /* namespace google */ | |
| 6939 | |
| 6940 namespace google { | |
| 6941 namespace protobuf { | |
| 6942 namespace MethodOptions { | |
| 6943 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_MethodOptions) } | |
| 6944 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF
ED(upb::FieldDef, upbdefs_google_protobuf_MethodOptions_uninterpreted_option) } | |
| 6945 } /* namespace MethodOptions */ | |
| 6946 } /* namespace protobuf */ | |
| 6947 } /* namespace google */ | |
| 6948 | |
| 6949 namespace google { | |
| 6950 namespace protobuf { | |
| 6951 namespace ServiceDescriptorProto { | |
| 6952 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_ServiceDescriptorProto) } | |
| 6953 inline upb::reffed_ptr<const upb::FieldDef> method() { RETURN_REFFED(upb::FieldD
ef, upbdefs_google_protobuf_ServiceDescriptorProto_method) } | |
| 6954 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_ServiceDescriptorProto_name) } | |
| 6955 inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::Field
Def, upbdefs_google_protobuf_ServiceDescriptorProto_options) } | |
| 6956 } /* namespace ServiceDescriptorProto */ | |
| 6957 } /* namespace protobuf */ | |
| 6958 } /* namespace google */ | |
| 6959 | |
| 6960 namespace google { | |
| 6961 namespace protobuf { | |
| 6962 namespace ServiceOptions { | |
| 6963 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_ServiceOptions) } | |
| 6964 inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFF
ED(upb::FieldDef, upbdefs_google_protobuf_ServiceOptions_uninterpreted_option) } | |
| 6965 } /* namespace ServiceOptions */ | |
| 6966 } /* namespace protobuf */ | |
| 6967 } /* namespace google */ | |
| 6968 | |
| 6969 namespace google { | |
| 6970 namespace protobuf { | |
| 6971 namespace SourceCodeInfo { | |
| 6972 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_SourceCodeInfo) } | |
| 6973 inline upb::reffed_ptr<const upb::FieldDef> location() { RETURN_REFFED(upb::Fiel
dDef, upbdefs_google_protobuf_SourceCodeInfo_location) } | |
| 6974 } /* namespace SourceCodeInfo */ | |
| 6975 } /* namespace protobuf */ | |
| 6976 } /* namespace google */ | |
| 6977 | |
| 6978 namespace google { | |
| 6979 namespace protobuf { | |
| 6980 namespace SourceCodeInfo { | |
| 6981 namespace Location { | |
| 6982 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_SourceCodeInfo_Location) } | |
| 6983 inline upb::reffed_ptr<const upb::FieldDef> leading_comments() { RETURN_REFFED(u
pb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_leading_comments)
} | |
| 6984 inline upb::reffed_ptr<const upb::FieldDef> path() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_SourceCodeInfo_Location_path) } | |
| 6985 inline upb::reffed_ptr<const upb::FieldDef> span() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_SourceCodeInfo_Location_span) } | |
| 6986 inline upb::reffed_ptr<const upb::FieldDef> trailing_comments() { RETURN_REFFED(
upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_trailing_comments
) } | |
| 6987 } /* namespace Location */ | |
| 6988 } /* namespace SourceCodeInfo */ | |
| 6989 } /* namespace protobuf */ | |
| 6990 } /* namespace google */ | |
| 6991 | |
| 6992 namespace google { | |
| 6993 namespace protobuf { | |
| 6994 namespace UninterpretedOption { | |
| 6995 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_UninterpretedOption) } | |
| 6996 inline upb::reffed_ptr<const upb::FieldDef> aggregate_value() { RETURN_REFFED(up
b::FieldDef, upbdefs_google_protobuf_UninterpretedOption_aggregate_value) } | |
| 6997 inline upb::reffed_ptr<const upb::FieldDef> double_value() { RETURN_REFFED(upb::
FieldDef, upbdefs_google_protobuf_UninterpretedOption_double_value) } | |
| 6998 inline upb::reffed_ptr<const upb::FieldDef> identifier_value() { RETURN_REFFED(u
pb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_identifier_value) } | |
| 6999 inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef
, upbdefs_google_protobuf_UninterpretedOption_name) } | |
| 7000 inline upb::reffed_ptr<const upb::FieldDef> negative_int_value() { RETURN_REFFED
(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_negative_int_value)
} | |
| 7001 inline upb::reffed_ptr<const upb::FieldDef> positive_int_value() { RETURN_REFFED
(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_positive_int_value)
} | |
| 7002 inline upb::reffed_ptr<const upb::FieldDef> string_value() { RETURN_REFFED(upb::
FieldDef, upbdefs_google_protobuf_UninterpretedOption_string_value) } | |
| 7003 } /* namespace UninterpretedOption */ | |
| 7004 } /* namespace protobuf */ | |
| 7005 } /* namespace google */ | |
| 7006 | |
| 7007 namespace google { | |
| 7008 namespace protobuf { | |
| 7009 namespace UninterpretedOption { | |
| 7010 namespace NamePart { | |
| 7011 inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::
MessageDef, upbdefs_google_protobuf_UninterpretedOption_NamePart) } | |
| 7012 inline upb::reffed_ptr<const upb::FieldDef> is_extension() { RETURN_REFFED(upb::
FieldDef, upbdefs_google_protobuf_UninterpretedOption_NamePart_is_extension) } | |
| 7013 inline upb::reffed_ptr<const upb::FieldDef> name_part() { RETURN_REFFED(upb::Fie
ldDef, upbdefs_google_protobuf_UninterpretedOption_NamePart_name_part) } | |
| 7014 } /* namespace NamePart */ | |
| 7015 } /* namespace UninterpretedOption */ | |
| 7016 } /* namespace protobuf */ | |
| 7017 } /* namespace google */ | |
| 7018 | |
| 7019 } /* namespace upbdefs */ | 7318 } /* namespace upbdefs */ |
| 7020 | 7319 |
| 7021 | 7320 #endif /* __cplusplus */ |
| 7022 #undef RETURN_REFFED | 7321 |
| 7023 #endif /* __cplusplus */ | 7322 #endif /* UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_ */ |
| 7024 | |
| 7025 #endif /* GOOGLE_PROTOBUF_DESCRIPTOR_UPB_H_ */ | |
| 7026 /* | 7323 /* |
| 7027 ** Internal-only definitions for the decoder. | 7324 ** Internal-only definitions for the decoder. |
| 7028 */ | 7325 */ |
| 7029 | 7326 |
| 7030 #ifndef UPB_DECODER_INT_H_ | 7327 #ifndef UPB_DECODER_INT_H_ |
| 7031 #define UPB_DECODER_INT_H_ | 7328 #define UPB_DECODER_INT_H_ |
| 7032 | 7329 |
| 7033 #include <stdlib.h> | |
| 7034 /* | 7330 /* |
| 7035 ** upb::pb::Decoder | 7331 ** upb::pb::Decoder |
| 7036 ** | 7332 ** |
| 7037 ** A high performance, streaming, resumable decoder for the binary protobuf | 7333 ** A high performance, streaming, resumable decoder for the binary protobuf |
| 7038 ** format. | 7334 ** format. |
| 7039 ** | 7335 ** |
| 7040 ** This interface works the same regardless of what decoder backend is being | 7336 ** This interface works the same regardless of what decoder backend is being |
| 7041 ** used. A client of this class does not need to know whether decoding is using | 7337 ** used. A client of this class does not need to know whether decoding is using |
| 7042 ** a JITted decoder (DynASM, LLVM, etc) or an interpreted decoder. By default, | 7338 ** a JITted decoder (DynASM, LLVM, etc) or an interpreted decoder. By default, |
| 7043 ** it will always use the fastest available decoder. However, you can call | 7339 ** it will always use the fastest available decoder. However, you can call |
| (...skipping 16 matching lines...) Expand all Loading... |
| 7060 } /* namespace upb */ | 7356 } /* namespace upb */ |
| 7061 #endif | 7357 #endif |
| 7062 | 7358 |
| 7063 UPB_DECLARE_TYPE(upb::pb::CodeCache, upb_pbcodecache) | 7359 UPB_DECLARE_TYPE(upb::pb::CodeCache, upb_pbcodecache) |
| 7064 UPB_DECLARE_TYPE(upb::pb::Decoder, upb_pbdecoder) | 7360 UPB_DECLARE_TYPE(upb::pb::Decoder, upb_pbdecoder) |
| 7065 UPB_DECLARE_TYPE(upb::pb::DecoderMethodOptions, upb_pbdecodermethodopts) | 7361 UPB_DECLARE_TYPE(upb::pb::DecoderMethodOptions, upb_pbdecodermethodopts) |
| 7066 | 7362 |
| 7067 UPB_DECLARE_DERIVED_TYPE(upb::pb::DecoderMethod, upb::RefCounted, | 7363 UPB_DECLARE_DERIVED_TYPE(upb::pb::DecoderMethod, upb::RefCounted, |
| 7068 upb_pbdecodermethod, upb_refcounted) | 7364 upb_pbdecodermethod, upb_refcounted) |
| 7069 | 7365 |
| 7366 /* The maximum number of bytes we are required to buffer internally between |
| 7367 * calls to the decoder. The value is 14: a 5 byte unknown tag plus ten-byte |
| 7368 * varint, less one because we are buffering an incomplete value. |
| 7369 * |
| 7370 * Should only be used by unit tests. */ |
| 7371 #define UPB_DECODER_MAX_RESIDUAL_BYTES 14 |
| 7372 |
| 7070 #ifdef __cplusplus | 7373 #ifdef __cplusplus |
| 7071 | 7374 |
| 7072 /* The parameters one uses to construct a DecoderMethod. | 7375 /* The parameters one uses to construct a DecoderMethod. |
| 7073 * TODO(haberman): move allowjit here? Seems more convenient for users. | 7376 * TODO(haberman): move allowjit here? Seems more convenient for users. |
| 7074 * TODO(haberman): move this to be heap allocated for ABI stability. */ | 7377 * TODO(haberman): move this to be heap allocated for ABI stability. */ |
| 7075 class upb::pb::DecoderMethodOptions { | 7378 class upb::pb::DecoderMethodOptions { |
| 7076 public: | 7379 public: |
| 7077 /* Parameter represents the destination handlers that this method will push | 7380 /* Parameter represents the destination handlers that this method will push |
| 7078 * to. */ | 7381 * to. */ |
| 7079 explicit DecoderMethodOptions(const Handlers* dest_handlers); | 7382 explicit DecoderMethodOptions(const Handlers* dest_handlers); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7116 private: | 7419 private: |
| 7117 UPB_DISALLOW_POD_OPS(DecoderMethod, upb::pb::DecoderMethod) | 7420 UPB_DISALLOW_POD_OPS(DecoderMethod, upb::pb::DecoderMethod) |
| 7118 }; | 7421 }; |
| 7119 | 7422 |
| 7120 #endif | 7423 #endif |
| 7121 | 7424 |
| 7122 /* Preallocation hint: decoder won't allocate more bytes than this when first | 7425 /* Preallocation hint: decoder won't allocate more bytes than this when first |
| 7123 * constructed. This hint may be an overestimate for some build configurations. | 7426 * constructed. This hint may be an overestimate for some build configurations. |
| 7124 * But if the decoder library is upgraded without recompiling the application, | 7427 * But if the decoder library is upgraded without recompiling the application, |
| 7125 * it may be an underestimate. */ | 7428 * it may be an underestimate. */ |
| 7126 #define UPB_PB_DECODER_SIZE 4408 | 7429 #define UPB_PB_DECODER_SIZE 4416 |
| 7127 | 7430 |
| 7128 #ifdef __cplusplus | 7431 #ifdef __cplusplus |
| 7129 | 7432 |
| 7130 /* A Decoder receives binary protobuf data on its input sink and pushes the | 7433 /* A Decoder receives binary protobuf data on its input sink and pushes the |
| 7131 * decoded data to its output sink. */ | 7434 * decoded data to its output sink. */ |
| 7132 class upb::pb::Decoder { | 7435 class upb::pb::Decoder { |
| 7133 public: | 7436 public: |
| 7134 /* Constructs a decoder instance for the given method, which must outlive this | 7437 /* Constructs a decoder instance for the given method, which must outlive this |
| 7135 * decoder. Any errors during parsing will be set on the given status, which | 7438 * decoder. Any errors during parsing will be set on the given status, which |
| 7136 * must also outlive this decoder. | 7439 * must also outlive this decoder. |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7534 | 7837 |
| 7535 /* End of the delimited region, relative to ptr, NULL if not in this buf. */ | 7838 /* End of the delimited region, relative to ptr, NULL if not in this buf. */ |
| 7536 const char *delim_end; | 7839 const char *delim_end; |
| 7537 | 7840 |
| 7538 /* End of the delimited region, relative to ptr, end if not in this buf. */ | 7841 /* End of the delimited region, relative to ptr, end if not in this buf. */ |
| 7539 const char *data_end; | 7842 const char *data_end; |
| 7540 | 7843 |
| 7541 /* Overall stream offset of "buf." */ | 7844 /* Overall stream offset of "buf." */ |
| 7542 uint64_t bufstart_ofs; | 7845 uint64_t bufstart_ofs; |
| 7543 | 7846 |
| 7544 /* Buffer for residual bytes not parsed from the previous buffer. | 7847 /* Buffer for residual bytes not parsed from the previous buffer. */ |
| 7545 * The maximum number of residual bytes we require is 12; a five-byte | 7848 char residual[UPB_DECODER_MAX_RESIDUAL_BYTES]; |
| 7546 * unknown tag plus an eight-byte value, less one because the value | |
| 7547 * is only a partial value. */ | |
| 7548 char residual[12]; | |
| 7549 char *residual_end; | 7849 char *residual_end; |
| 7550 | 7850 |
| 7551 /* Bytes of data that should be discarded from the input beore we start | 7851 /* Bytes of data that should be discarded from the input beore we start |
| 7552 * parsing again. We set this when we internally determine that we can | 7852 * parsing again. We set this when we internally determine that we can |
| 7553 * safely skip the next N bytes, but this region extends past the current | 7853 * safely skip the next N bytes, but this region extends past the current |
| 7554 * user buffer. */ | 7854 * user buffer. */ |
| 7555 size_t skip; | 7855 size_t skip; |
| 7556 | 7856 |
| 7557 /* Stores the user buffer passed to our decode function. */ | 7857 /* Stores the user buffer passed to our decode function. */ |
| 7558 const char *buf_param; | 7858 const char *buf_param; |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7932 ** of data and efficiency is an issue, these may not be the best functions to | 8232 ** of data and efficiency is an issue, these may not be the best functions to |
| 7933 ** use (though they are useful for prototyping, before optimizing). | 8233 ** use (though they are useful for prototyping, before optimizing). |
| 7934 */ | 8234 */ |
| 7935 | 8235 |
| 7936 #ifndef UPB_GLUE_H | 8236 #ifndef UPB_GLUE_H |
| 7937 #define UPB_GLUE_H | 8237 #define UPB_GLUE_H |
| 7938 | 8238 |
| 7939 #include <stdbool.h> | 8239 #include <stdbool.h> |
| 7940 | 8240 |
| 7941 #ifdef __cplusplus | 8241 #ifdef __cplusplus |
| 8242 #include <vector> |
| 8243 |
| 7942 extern "C" { | 8244 extern "C" { |
| 7943 #endif | 8245 #endif |
| 7944 | 8246 |
| 7945 /* Loads all defs from the given protobuf binary descriptor, setting default | 8247 /* Loads a binary descriptor and returns a NULL-terminated array of unfrozen |
| 7946 * accessors and a default layout on all messages. The caller owns the | 8248 * filedefs. The caller owns the returned array, which must be freed with |
| 7947 * returned array of defs, which will be of length *n. On error NULL is | 8249 * upb_gfree(). */ |
| 7948 * returned and status is set (if non-NULL). */ | 8250 upb_filedef **upb_loaddescriptor(const char *buf, size_t n, const void *owner, |
| 7949 upb_def **upb_load_defs_from_descriptor(const char *str, size_t len, int *n, | 8251 upb_status *status); |
| 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); | |
| 7963 | 8252 |
| 7964 #ifdef __cplusplus | 8253 #ifdef __cplusplus |
| 7965 } /* extern "C" */ | 8254 } /* extern "C" */ |
| 7966 | 8255 |
| 7967 namespace upb { | 8256 namespace upb { |
| 7968 | 8257 |
| 7969 /* All routines that load descriptors expect the descriptor to be a | 8258 inline bool LoadDescriptor(const char* buf, size_t n, Status* status, |
| 7970 * FileDescriptorSet. */ | 8259 std::vector<reffed_ptr<FileDef> >* files) { |
| 7971 inline bool LoadDescriptorFileIntoSymtab(SymbolTable* s, const char *fname, | 8260 FileDef** parsed_files = upb_loaddescriptor(buf, n, &parsed_files, status); |
| 7972 Status* status) { | |
| 7973 return upb_load_descriptor_file_into_symtab(s, fname, status); | |
| 7974 } | |
| 7975 | 8261 |
| 7976 inline bool LoadDescriptorIntoSymtab(SymbolTable* s, const char* str, | 8262 if (parsed_files) { |
| 7977 size_t len, Status* status) { | 8263 FileDef** p = parsed_files; |
| 7978 return upb_load_descriptor_into_symtab(s, str, len, status); | 8264 while (*p) { |
| 8265 files->push_back(reffed_ptr<FileDef>(*p, &parsed_files)); |
| 8266 ++p; |
| 8267 } |
| 8268 free(parsed_files); |
| 8269 return true; |
| 8270 } else { |
| 8271 return false; |
| 8272 } |
| 7979 } | 8273 } |
| 7980 | 8274 |
| 7981 /* Templated so it can accept both string and std::string. */ | 8275 /* Templated so it can accept both string and std::string. */ |
| 7982 template <typename T> | 8276 template <typename T> |
| 7983 bool LoadDescriptorIntoSymtab(SymbolTable* s, const T& desc, Status* status) { | 8277 bool LoadDescriptor(const T& desc, Status* status, |
| 7984 return upb_load_descriptor_into_symtab(s, desc.c_str(), desc.size(), status); | 8278 std::vector<reffed_ptr<FileDef> >* files) { |
| 8279 return LoadDescriptor(desc.c_str(), desc.size(), status, files); |
| 7985 } | 8280 } |
| 7986 | 8281 |
| 7987 } /* namespace upb */ | 8282 } /* namespace upb */ |
| 7988 | 8283 |
| 7989 #endif | 8284 #endif |
| 7990 | 8285 |
| 7991 #endif /* UPB_GLUE_H */ | 8286 #endif /* UPB_GLUE_H */ |
| 7992 /* | 8287 /* |
| 7993 ** upb::pb::TextPrinter (upb_textprinter) | 8288 ** upb::pb::TextPrinter (upb_textprinter) |
| 7994 ** | 8289 ** |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8076 */ | 8371 */ |
| 8077 | 8372 |
| 8078 #ifndef UPB_JSON_PARSER_H_ | 8373 #ifndef UPB_JSON_PARSER_H_ |
| 8079 #define UPB_JSON_PARSER_H_ | 8374 #define UPB_JSON_PARSER_H_ |
| 8080 | 8375 |
| 8081 | 8376 |
| 8082 #ifdef __cplusplus | 8377 #ifdef __cplusplus |
| 8083 namespace upb { | 8378 namespace upb { |
| 8084 namespace json { | 8379 namespace json { |
| 8085 class Parser; | 8380 class Parser; |
| 8381 class ParserMethod; |
| 8086 } /* namespace json */ | 8382 } /* namespace json */ |
| 8087 } /* namespace upb */ | 8383 } /* namespace upb */ |
| 8088 #endif | 8384 #endif |
| 8089 | 8385 |
| 8090 UPB_DECLARE_TYPE(upb::json::Parser, upb_json_parser) | 8386 UPB_DECLARE_TYPE(upb::json::Parser, upb_json_parser) |
| 8387 UPB_DECLARE_DERIVED_TYPE(upb::json::ParserMethod, upb::RefCounted, |
| 8388 upb_json_parsermethod, upb_refcounted) |
| 8091 | 8389 |
| 8092 /* upb::json::Parser **********************************************************/ | 8390 /* upb::json::Parser **********************************************************/ |
| 8093 | 8391 |
| 8094 /* Preallocation hint: parser won't allocate more bytes than this when first | 8392 /* Preallocation hint: parser won't allocate more bytes than this when first |
| 8095 * constructed. This hint may be an overestimate for some build configurations. | 8393 * constructed. This hint may be an overestimate for some build configurations. |
| 8096 * But if the parser library is upgraded without recompiling the application, | 8394 * But if the parser library is upgraded without recompiling the application, |
| 8097 * it may be an underestimate. */ | 8395 * it may be an underestimate. */ |
| 8098 #define UPB_JSON_PARSER_SIZE 3704 | 8396 #define UPB_JSON_PARSER_SIZE 4112 |
| 8099 | 8397 |
| 8100 #ifdef __cplusplus | 8398 #ifdef __cplusplus |
| 8101 | 8399 |
| 8102 /* Parses an incoming BytesStream, pushing the results to the destination | 8400 /* Parses an incoming BytesStream, pushing the results to the destination |
| 8103 * sink. */ | 8401 * sink. */ |
| 8104 class upb::json::Parser { | 8402 class upb::json::Parser { |
| 8105 public: | 8403 public: |
| 8106 static Parser* Create(Environment* env, Sink* output); | 8404 static Parser* Create(Environment* env, const ParserMethod* method, |
| 8405 Sink* output); |
| 8107 | 8406 |
| 8108 BytesSink* input(); | 8407 BytesSink* input(); |
| 8109 | 8408 |
| 8110 private: | 8409 private: |
| 8111 UPB_DISALLOW_POD_OPS(Parser, upb::json::Parser) | 8410 UPB_DISALLOW_POD_OPS(Parser, upb::json::Parser) |
| 8112 }; | 8411 }; |
| 8113 | 8412 |
| 8413 class upb::json::ParserMethod { |
| 8414 public: |
| 8415 /* Include base methods from upb::ReferenceCounted. */ |
| 8416 UPB_REFCOUNTED_CPPMETHODS |
| 8417 |
| 8418 /* Returns handlers for parsing according to the specified schema. */ |
| 8419 static reffed_ptr<const ParserMethod> New(const upb::MessageDef* md); |
| 8420 |
| 8421 /* The destination handlers that are statically bound to this method. |
| 8422 * This method is only capable of outputting to a sink that uses these |
| 8423 * handlers. */ |
| 8424 const Handlers* dest_handlers() const; |
| 8425 |
| 8426 /* The input handlers for this decoder method. */ |
| 8427 const BytesHandler* input_handler() const; |
| 8428 |
| 8429 private: |
| 8430 UPB_DISALLOW_POD_OPS(ParserMethod, upb::json::ParserMethod) |
| 8431 }; |
| 8432 |
| 8114 #endif | 8433 #endif |
| 8115 | 8434 |
| 8116 UPB_BEGIN_EXTERN_C | 8435 UPB_BEGIN_EXTERN_C |
| 8117 | 8436 |
| 8118 upb_json_parser *upb_json_parser_create(upb_env *e, upb_sink *output); | 8437 upb_json_parser* upb_json_parser_create(upb_env* e, |
| 8438 const upb_json_parsermethod* m, |
| 8439 upb_sink* output); |
| 8119 upb_bytessink *upb_json_parser_input(upb_json_parser *p); | 8440 upb_bytessink *upb_json_parser_input(upb_json_parser *p); |
| 8120 | 8441 |
| 8442 upb_json_parsermethod* upb_json_parsermethod_new(const upb_msgdef* md, |
| 8443 const void* owner); |
| 8444 const upb_handlers *upb_json_parsermethod_desthandlers( |
| 8445 const upb_json_parsermethod *m); |
| 8446 const upb_byteshandler *upb_json_parsermethod_inputhandler( |
| 8447 const upb_json_parsermethod *m); |
| 8448 |
| 8449 /* Include refcounted methods like upb_json_parsermethod_ref(). */ |
| 8450 UPB_REFCOUNTED_CMETHODS(upb_json_parsermethod, upb_json_parsermethod_upcast) |
| 8451 |
| 8121 UPB_END_EXTERN_C | 8452 UPB_END_EXTERN_C |
| 8122 | 8453 |
| 8123 #ifdef __cplusplus | 8454 #ifdef __cplusplus |
| 8124 | 8455 |
| 8125 namespace upb { | 8456 namespace upb { |
| 8126 namespace json { | 8457 namespace json { |
| 8127 inline Parser* Parser::Create(Environment* env, Sink* output) { | 8458 inline Parser* Parser::Create(Environment* env, const ParserMethod* method, |
| 8128 return upb_json_parser_create(env, output); | 8459 Sink* output) { |
| 8460 return upb_json_parser_create(env, method, output); |
| 8129 } | 8461 } |
| 8130 inline BytesSink* Parser::input() { | 8462 inline BytesSink* Parser::input() { |
| 8131 return upb_json_parser_input(this); | 8463 return upb_json_parser_input(this); |
| 8132 } | 8464 } |
| 8465 |
| 8466 inline const Handlers* ParserMethod::dest_handlers() const { |
| 8467 return upb_json_parsermethod_desthandlers(this); |
| 8468 } |
| 8469 inline const BytesHandler* ParserMethod::input_handler() const { |
| 8470 return upb_json_parsermethod_inputhandler(this); |
| 8471 } |
| 8472 /* static */ |
| 8473 inline reffed_ptr<const ParserMethod> ParserMethod::New( |
| 8474 const MessageDef* md) { |
| 8475 const upb_json_parsermethod *m = upb_json_parsermethod_new(md, &m); |
| 8476 return reffed_ptr<const ParserMethod>(m, &m); |
| 8477 } |
| 8478 |
| 8133 } /* namespace json */ | 8479 } /* namespace json */ |
| 8134 } /* namespace upb */ | 8480 } /* namespace upb */ |
| 8135 | 8481 |
| 8136 #endif | 8482 #endif |
| 8137 | 8483 |
| 8138 | 8484 |
| 8139 #endif /* UPB_JSON_PARSER_H_ */ | 8485 #endif /* UPB_JSON_PARSER_H_ */ |
| 8140 /* | 8486 /* |
| 8141 ** upb::json::Printer | 8487 ** upb::json::Printer |
| 8142 ** | 8488 ** |
| (...skipping 10 matching lines...) Expand all Loading... |
| 8153 class Printer; | 8499 class Printer; |
| 8154 } /* namespace json */ | 8500 } /* namespace json */ |
| 8155 } /* namespace upb */ | 8501 } /* namespace upb */ |
| 8156 #endif | 8502 #endif |
| 8157 | 8503 |
| 8158 UPB_DECLARE_TYPE(upb::json::Printer, upb_json_printer) | 8504 UPB_DECLARE_TYPE(upb::json::Printer, upb_json_printer) |
| 8159 | 8505 |
| 8160 | 8506 |
| 8161 /* upb::json::Printer *********************************************************/ | 8507 /* upb::json::Printer *********************************************************/ |
| 8162 | 8508 |
| 8163 #define UPB_JSON_PRINTER_SIZE 168 | 8509 #define UPB_JSON_PRINTER_SIZE 176 |
| 8164 | 8510 |
| 8165 #ifdef __cplusplus | 8511 #ifdef __cplusplus |
| 8166 | 8512 |
| 8167 /* Prints an incoming stream of data to a BytesSink in JSON format. */ | 8513 /* Prints an incoming stream of data to a BytesSink in JSON format. */ |
| 8168 class upb::json::Printer { | 8514 class upb::json::Printer { |
| 8169 public: | 8515 public: |
| 8170 static Printer* Create(Environment* env, const upb::Handlers* handlers, | 8516 static Printer* Create(Environment* env, const upb::Handlers* handlers, |
| 8171 BytesSink* output); | 8517 BytesSink* output); |
| 8172 | 8518 |
| 8173 /* The input to the printer. */ | 8519 /* The input to the printer. */ |
| 8174 Sink* input(); | 8520 Sink* input(); |
| 8175 | 8521 |
| 8176 /* Returns handlers for printing according to the specified schema. */ | 8522 /* Returns handlers for printing according to the specified schema. |
| 8177 static reffed_ptr<const Handlers> NewHandlers(const upb::MessageDef* md); | 8523 * If preserve_proto_fieldnames is true, the output JSON will use the |
| 8524 * original .proto field names (ie. {"my_field":3}) instead of using |
| 8525 * camelCased names, which is the default: (eg. {"myField":3}). */ |
| 8526 static reffed_ptr<const Handlers> NewHandlers(const upb::MessageDef* md, |
| 8527 bool preserve_proto_fieldnames); |
| 8178 | 8528 |
| 8179 static const size_t kSize = UPB_JSON_PRINTER_SIZE; | 8529 static const size_t kSize = UPB_JSON_PRINTER_SIZE; |
| 8180 | 8530 |
| 8181 private: | 8531 private: |
| 8182 UPB_DISALLOW_POD_OPS(Printer, upb::json::Printer) | 8532 UPB_DISALLOW_POD_OPS(Printer, upb::json::Printer) |
| 8183 }; | 8533 }; |
| 8184 | 8534 |
| 8185 #endif | 8535 #endif |
| 8186 | 8536 |
| 8187 UPB_BEGIN_EXTERN_C | 8537 UPB_BEGIN_EXTERN_C |
| 8188 | 8538 |
| 8189 /* Native C API. */ | 8539 /* Native C API. */ |
| 8190 upb_json_printer *upb_json_printer_create(upb_env *e, const upb_handlers *h, | 8540 upb_json_printer *upb_json_printer_create(upb_env *e, const upb_handlers *h, |
| 8191 upb_bytessink *output); | 8541 upb_bytessink *output); |
| 8192 upb_sink *upb_json_printer_input(upb_json_printer *p); | 8542 upb_sink *upb_json_printer_input(upb_json_printer *p); |
| 8193 const upb_handlers *upb_json_printer_newhandlers(const upb_msgdef *md, | 8543 const upb_handlers *upb_json_printer_newhandlers(const upb_msgdef *md, |
| 8544 bool preserve_fieldnames, |
| 8194 const void *owner); | 8545 const void *owner); |
| 8195 | 8546 |
| 8196 UPB_END_EXTERN_C | 8547 UPB_END_EXTERN_C |
| 8197 | 8548 |
| 8198 #ifdef __cplusplus | 8549 #ifdef __cplusplus |
| 8199 | 8550 |
| 8200 namespace upb { | 8551 namespace upb { |
| 8201 namespace json { | 8552 namespace json { |
| 8202 inline Printer* Printer::Create(Environment* env, const upb::Handlers* handlers, | 8553 inline Printer* Printer::Create(Environment* env, const upb::Handlers* handlers, |
| 8203 BytesSink* output) { | 8554 BytesSink* output) { |
| 8204 return upb_json_printer_create(env, handlers, output); | 8555 return upb_json_printer_create(env, handlers, output); |
| 8205 } | 8556 } |
| 8206 inline Sink* Printer::input() { return upb_json_printer_input(this); } | 8557 inline Sink* Printer::input() { return upb_json_printer_input(this); } |
| 8207 inline reffed_ptr<const Handlers> Printer::NewHandlers( | 8558 inline reffed_ptr<const Handlers> Printer::NewHandlers( |
| 8208 const upb::MessageDef *md) { | 8559 const upb::MessageDef *md, bool preserve_proto_fieldnames) { |
| 8209 const Handlers* h = upb_json_printer_newhandlers(md, &h); | 8560 const Handlers* h = upb_json_printer_newhandlers( |
| 8561 md, preserve_proto_fieldnames, &h); |
| 8210 return reffed_ptr<const Handlers>(h, &h); | 8562 return reffed_ptr<const Handlers>(h, &h); |
| 8211 } | 8563 } |
| 8212 } /* namespace json */ | 8564 } /* namespace json */ |
| 8213 } /* namespace upb */ | 8565 } /* namespace upb */ |
| 8214 | 8566 |
| 8215 #endif | 8567 #endif |
| 8216 | 8568 |
| 8217 #endif /* UPB_JSON_TYPED_PRINTER_H_ */ | 8569 #endif /* UPB_JSON_TYPED_PRINTER_H_ */ |
| OLD | NEW |