php-upb.c
Go to the documentation of this file.
1 /* Amalgamated source file */
2 #include "php-upb.h"
3 /*
4  * Copyright (c) 2009-2021, Google LLC
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of Google LLC nor the
15  * names of its contributors may be used to endorse or promote products
16  * derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 /*
31  * This is where we define macros used across upb.
32  *
33  * All of these macros are undef'd in port_undef.inc to avoid leaking them to
34  * users.
35  *
36  * The correct usage is:
37  *
38  * #include "upb/foobar.h"
39  * #include "upb/baz.h"
40  *
41  * // MUST be last included header.
42  * #include "upb/port_def.inc"
43  *
44  * // Code for this file.
45  * // <...>
46  *
47  * // Can be omitted for .c files, required for .h.
48  * #include "upb/port_undef.inc"
49  *
50  * This file is private and must not be included by users!
51  */
52 
53 #if !((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
54  (defined(__cplusplus) && __cplusplus >= 201103L) || \
55  (defined(_MSC_VER) && _MSC_VER >= 1900))
56 #error upb requires C99 or C++11 or MSVC >= 2015.
57 #endif
58 
59 #include <stdint.h>
60 #include <stddef.h>
61 
62 #if UINTPTR_MAX == 0xffffffff
63 #define UPB_SIZE(size32, size64) size32
64 #else
65 #define UPB_SIZE(size32, size64) size64
66 #endif
67 
68 /* If we always read/write as a consistent type to each address, this shouldn't
69  * violate aliasing.
70  */
71 #define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs)))
72 
73 #define UPB_READ_ONEOF(msg, fieldtype, offset, case_offset, case_val, default) \
74  *UPB_PTR_AT(msg, case_offset, int) == case_val \
75  ? *UPB_PTR_AT(msg, offset, fieldtype) \
76  : default
77 
78 #define UPB_WRITE_ONEOF(msg, fieldtype, offset, value, case_offset, case_val) \
79  *UPB_PTR_AT(msg, case_offset, int) = case_val; \
80  *UPB_PTR_AT(msg, offset, fieldtype) = value;
81 
82 #define UPB_MAPTYPE_STRING 0
83 
84 /* UPB_INLINE: inline if possible, emit standalone code if required. */
85 #ifdef __cplusplus
86 #define UPB_INLINE inline
87 #elif defined (__GNUC__) || defined(__clang__)
88 #define UPB_INLINE static __inline__
89 #else
90 #define UPB_INLINE static
91 #endif
92 
93 #define UPB_ALIGN_UP(size, align) (((size) + (align) - 1) / (align) * (align))
94 #define UPB_ALIGN_DOWN(size, align) ((size) / (align) * (align))
95 #define UPB_ALIGN_MALLOC(size) UPB_ALIGN_UP(size, 16)
96 #define UPB_ALIGN_OF(type) offsetof (struct { char c; type member; }, member)
97 
98 /* Hints to the compiler about likely/unlikely branches. */
99 #if defined (__GNUC__) || defined(__clang__)
100 #define UPB_LIKELY(x) __builtin_expect((x),1)
101 #define UPB_UNLIKELY(x) __builtin_expect((x),0)
102 #else
103 #define UPB_LIKELY(x) (x)
104 #define UPB_UNLIKELY(x) (x)
105 #endif
106 
107 /* Macros for function attributes on compilers that support them. */
108 #ifdef __GNUC__
109 #define UPB_FORCEINLINE __inline__ __attribute__((always_inline))
110 #define UPB_NOINLINE __attribute__((noinline))
111 #define UPB_NORETURN __attribute__((__noreturn__))
112 #define UPB_PRINTF(str, first_vararg) __attribute__((format (printf, str, first_vararg)))
113 #elif defined(_MSC_VER)
114 #define UPB_NOINLINE
115 #define UPB_FORCEINLINE
116 #define UPB_NORETURN __declspec(noreturn)
117 #define UPB_PRINTF(str, first_vararg)
118 #else /* !defined(__GNUC__) */
119 #define UPB_FORCEINLINE
120 #define UPB_NOINLINE
121 #define UPB_NORETURN
122 #define UPB_PRINTF(str, first_vararg)
123 #endif
124 
125 #define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
126 #define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
127 
128 #define UPB_UNUSED(var) (void)var
129 
130 /* UPB_ASSUME(): in release mode, we tell the compiler to assume this is true.
131  */
132 #ifdef NDEBUG
133 #ifdef __GNUC__
134 #define UPB_ASSUME(expr) if (!(expr)) __builtin_unreachable()
135 #elif defined _MSC_VER
136 #define UPB_ASSUME(expr) if (!(expr)) __assume(0)
137 #else
138 #define UPB_ASSUME(expr) do {} while (false && (expr))
139 #endif
140 #else
141 #define UPB_ASSUME(expr) assert(expr)
142 #endif
143 
144 /* UPB_ASSERT(): in release mode, we use the expression without letting it be
145  * evaluated. This prevents "unused variable" warnings. */
146 #ifdef NDEBUG
147 #define UPB_ASSERT(expr) do {} while (false && (expr))
148 #else
149 #define UPB_ASSERT(expr) assert(expr)
150 #endif
151 
152 #if defined(__GNUC__) || defined(__clang__)
153 #define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0)
154 #else
155 #define UPB_UNREACHABLE() do { assert(0); } while(0)
156 #endif
157 
158 /* UPB_SETJMP() / UPB_LONGJMP(): avoid setting/restoring signal mask. */
159 #ifdef __APPLE__
160 #define UPB_SETJMP(buf) _setjmp(buf)
161 #define UPB_LONGJMP(buf, val) _longjmp(buf, val)
162 #else
163 #define UPB_SETJMP(buf) setjmp(buf)
164 #define UPB_LONGJMP(buf, val) longjmp(buf, val)
165 #endif
166 
167 /* UPB_PTRADD(ptr, ofs): add pointer while avoiding "NULL + 0" UB */
168 #define UPB_PTRADD(ptr, ofs) ((ofs) ? (ptr) + (ofs) : (ptr))
169 
170 /* Configure whether fasttable is switched on or not. *************************/
171 
172 #ifdef __has_attribute
173 #define UPB_HAS_ATTRIBUTE(x) __has_attribute(x)
174 #else
175 #define UPB_HAS_ATTRIBUTE(x) 0
176 #endif
177 
178 #if UPB_HAS_ATTRIBUTE(musttail)
179 #define UPB_MUSTTAIL __attribute__((musttail))
180 #else
181 #define UPB_MUSTTAIL
182 #endif
183 
184 #undef UPB_HAS_ATTRIBUTE
185 
186 /* This check is not fully robust: it does not require that we have "musttail"
187  * support available. We need tail calls to avoid consuming arbitrary amounts
188  * of stack space.
189  *
190  * GCC/Clang can mostly be trusted to generate tail calls as long as
191  * optimization is enabled, but, debug builds will not generate tail calls
192  * unless "musttail" is available.
193  *
194  * We should probably either:
195  * 1. require that the compiler supports musttail.
196  * 2. add some fallback code for when musttail isn't available (ie. return
197  * instead of tail calling). This is safe and portable, but this comes at
198  * a CPU cost.
199  */
200 #if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__)
201 #define UPB_FASTTABLE_SUPPORTED 1
202 #else
203 #define UPB_FASTTABLE_SUPPORTED 0
204 #endif
205 
206 /* define UPB_ENABLE_FASTTABLE to force fast table support.
207  * This is useful when we want to ensure we are really getting fasttable,
208  * for example for testing or benchmarking. */
209 #if defined(UPB_ENABLE_FASTTABLE)
210 #if !UPB_FASTTABLE_SUPPORTED
211 #error fasttable is x86-64/ARM64 only and requires GCC or Clang.
212 #endif
213 #define UPB_FASTTABLE 1
214 /* Define UPB_TRY_ENABLE_FASTTABLE to use fasttable if possible.
215  * This is useful for releasing code that might be used on multiple platforms,
216  * for example the PHP or Ruby C extensions. */
217 #elif defined(UPB_TRY_ENABLE_FASTTABLE)
218 #define UPB_FASTTABLE UPB_FASTTABLE_SUPPORTED
219 #else
220 #define UPB_FASTTABLE 0
221 #endif
222 
223 /* UPB_FASTTABLE_INIT() allows protos compiled for fasttable to gracefully
224  * degrade to non-fasttable if we are using UPB_TRY_ENABLE_FASTTABLE. */
225 #if !UPB_FASTTABLE && defined(UPB_TRY_ENABLE_FASTTABLE)
226 #define UPB_FASTTABLE_INIT(...)
227 #else
228 #define UPB_FASTTABLE_INIT(...) __VA_ARGS__
229 #endif
230 
231 #undef UPB_FASTTABLE_SUPPORTED
232 
233 /* ASAN poisoning (for arena) *************************************************/
234 
235 #if defined(__SANITIZE_ADDRESS__)
236 #define UPB_ASAN 1
237 #ifdef __cplusplus
238 extern "C" {
239 #endif
240 void __asan_poison_memory_region(void const volatile *addr, size_t size);
241 void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
242 #ifdef __cplusplus
243 } /* extern "C" */
244 #endif
245 #define UPB_POISON_MEMORY_REGION(addr, size) \
246  __asan_poison_memory_region((addr), (size))
247 #define UPB_UNPOISON_MEMORY_REGION(addr, size) \
248  __asan_unpoison_memory_region((addr), (size))
249 #else
250 #define UPB_ASAN 0
251 #define UPB_POISON_MEMORY_REGION(addr, size) \
252  ((void)(addr), (void)(size))
253 #define UPB_UNPOISON_MEMORY_REGION(addr, size) \
254  ((void)(addr), (void)(size))
255 #endif
256 
259 #include <setjmp.h>
260 #include <string.h>
261 
262 
263 /* Must be last. */
264 
265 /* Maps descriptor type -> elem_size_lg2. */
267  -1, /* invalid descriptor type */
268  3, /* DOUBLE */
269  2, /* FLOAT */
270  3, /* INT64 */
271  3, /* UINT64 */
272  2, /* INT32 */
273  3, /* FIXED64 */
274  2, /* FIXED32 */
275  0, /* BOOL */
276  UPB_SIZE(3, 4), /* STRING */
277  UPB_SIZE(2, 3), /* GROUP */
278  UPB_SIZE(2, 3), /* MESSAGE */
279  UPB_SIZE(3, 4), /* BYTES */
280  2, /* UINT32 */
281  2, /* ENUM */
282  2, /* SFIXED32 */
283  3, /* SFIXED64 */
284  2, /* SINT32 */
285  3, /* SINT64 */
286 };
287 
288 /* Maps descriptor type -> upb map size. */
289 static const uint8_t desctype_to_mapsize[] = {
290  -1, /* invalid descriptor type */
291  8, /* DOUBLE */
292  4, /* FLOAT */
293  8, /* INT64 */
294  8, /* UINT64 */
295  4, /* INT32 */
296  8, /* FIXED64 */
297  4, /* FIXED32 */
298  1, /* BOOL */
299  UPB_MAPTYPE_STRING, /* STRING */
300  sizeof(void *), /* GROUP */
301  sizeof(void *), /* MESSAGE */
302  UPB_MAPTYPE_STRING, /* BYTES */
303  4, /* UINT32 */
304  4, /* ENUM */
305  4, /* SFIXED32 */
306  8, /* SFIXED64 */
307  4, /* SINT32 */
308  8, /* SINT64 */
309 };
310 
311 static const unsigned fixed32_ok = (1 << UPB_DTYPE_FLOAT) |
312  (1 << UPB_DTYPE_FIXED32) |
313  (1 << UPB_DTYPE_SFIXED32);
314 
315 static const unsigned fixed64_ok = (1 << UPB_DTYPE_DOUBLE) |
316  (1 << UPB_DTYPE_FIXED64) |
317  (1 << UPB_DTYPE_SFIXED64);
318 
319 /* Op: an action to be performed for a wire-type/field-type combination. */
320 #define OP_SCALAR_LG2(n) (n) /* n in [0, 2, 3] => op in [0, 2, 3] */
321 #define OP_STRING 4
322 #define OP_BYTES 5
323 #define OP_SUBMSG 6
324 /* Ops above are scalar-only. Repeated fields can use any op. */
325 #define OP_FIXPCK_LG2(n) (n + 5) /* n in [2, 3] => op in [7, 8] */
326 #define OP_VARPCK_LG2(n) (n + 9) /* n in [0, 2, 3] => op in [9, 11, 12] */
327 
328 static const int8_t varint_ops[19] = {
329  -1, /* field not found */
330  -1, /* DOUBLE */
331  -1, /* FLOAT */
332  OP_SCALAR_LG2(3), /* INT64 */
333  OP_SCALAR_LG2(3), /* UINT64 */
334  OP_SCALAR_LG2(2), /* INT32 */
335  -1, /* FIXED64 */
336  -1, /* FIXED32 */
337  OP_SCALAR_LG2(0), /* BOOL */
338  -1, /* STRING */
339  -1, /* GROUP */
340  -1, /* MESSAGE */
341  -1, /* BYTES */
342  OP_SCALAR_LG2(2), /* UINT32 */
343  OP_SCALAR_LG2(2), /* ENUM */
344  -1, /* SFIXED32 */
345  -1, /* SFIXED64 */
346  OP_SCALAR_LG2(2), /* SINT32 */
347  OP_SCALAR_LG2(3), /* SINT64 */
348 };
349 
350 static const int8_t delim_ops[37] = {
351  /* For non-repeated field type. */
352  -1, /* field not found */
353  -1, /* DOUBLE */
354  -1, /* FLOAT */
355  -1, /* INT64 */
356  -1, /* UINT64 */
357  -1, /* INT32 */
358  -1, /* FIXED64 */
359  -1, /* FIXED32 */
360  -1, /* BOOL */
361  OP_STRING, /* STRING */
362  -1, /* GROUP */
363  OP_SUBMSG, /* MESSAGE */
364  OP_BYTES, /* BYTES */
365  -1, /* UINT32 */
366  -1, /* ENUM */
367  -1, /* SFIXED32 */
368  -1, /* SFIXED64 */
369  -1, /* SINT32 */
370  -1, /* SINT64 */
371  /* For repeated field type. */
372  OP_FIXPCK_LG2(3), /* REPEATED DOUBLE */
373  OP_FIXPCK_LG2(2), /* REPEATED FLOAT */
374  OP_VARPCK_LG2(3), /* REPEATED INT64 */
375  OP_VARPCK_LG2(3), /* REPEATED UINT64 */
376  OP_VARPCK_LG2(2), /* REPEATED INT32 */
377  OP_FIXPCK_LG2(3), /* REPEATED FIXED64 */
378  OP_FIXPCK_LG2(2), /* REPEATED FIXED32 */
379  OP_VARPCK_LG2(0), /* REPEATED BOOL */
380  OP_STRING, /* REPEATED STRING */
381  OP_SUBMSG, /* REPEATED GROUP */
382  OP_SUBMSG, /* REPEATED MESSAGE */
383  OP_BYTES, /* REPEATED BYTES */
384  OP_VARPCK_LG2(2), /* REPEATED UINT32 */
385  OP_VARPCK_LG2(2), /* REPEATED ENUM */
386  OP_FIXPCK_LG2(2), /* REPEATED SFIXED32 */
387  OP_FIXPCK_LG2(3), /* REPEATED SFIXED64 */
388  OP_VARPCK_LG2(2), /* REPEATED SINT32 */
389  OP_VARPCK_LG2(3), /* REPEATED SINT64 */
390 };
391 
392 typedef union {
393  bool bool_val;
397 } wireval;
398 
399 static const char *decode_msg(upb_decstate *d, const char *ptr, upb_msg *msg,
400  const upb_msglayout *layout);
401 
402 UPB_NORETURN static void decode_err(upb_decstate *d) { UPB_LONGJMP(d->err, 1); }
403 
404 // We don't want to mark this NORETURN, see comment in .h.
405 // Unfortunately this code to suppress the warning doesn't appear to be working.
406 #ifdef __clang__
407 #pragma clang diagnostic push
408 #pragma clang diagnostic ignored "-Wunknown-warning-option"
409 #pragma clang diagnostic ignored "-Wsuggest-attribute"
410 #endif
411 
413  longjmp(d->err, 1);
414  return NULL;
415 }
416 
417 #ifdef __clang__
418 #pragma clang diagnostic pop
419 #endif
420 
422  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
424  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
425  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
426  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
427  1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
428  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
429  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
430  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431  2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
432  4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0,
433 };
434 
435 static void decode_verifyutf8(upb_decstate *d, const char *buf, int len) {
437 }
438 
439 static bool decode_reserve(upb_decstate *d, upb_array *arr, size_t elem) {
440  bool need_realloc = arr->size - arr->len < elem;
441  if (need_realloc && !_upb_array_realloc(arr, arr->len + elem, &d->arena)) {
442  decode_err(d);
443  }
444  return need_realloc;
445 }
446 
447 typedef struct {
448  const char *ptr;
450 } decode_vret;
451 
453 static decode_vret decode_longvarint64(const char *ptr, uint64_t val) {
454  decode_vret ret = {NULL, 0};
455  uint64_t byte;
456  int i;
457  for (i = 1; i < 10; i++) {
458  byte = (uint8_t)ptr[i];
459  val += (byte - 1) << (i * 7);
460  if (!(byte & 0x80)) {
461  ret.ptr = ptr + i + 1;
462  ret.val = val;
463  return ret;
464  }
465  }
466  return ret;
467 }
468 
470 static const char *decode_varint64(upb_decstate *d, const char *ptr,
471  uint64_t *val) {
472  uint64_t byte = (uint8_t)*ptr;
473  if (UPB_LIKELY((byte & 0x80) == 0)) {
474  *val = byte;
475  return ptr + 1;
476  } else {
477  decode_vret res = decode_longvarint64(ptr, byte);
478  if (!res.ptr) decode_err(d);
479  *val = res.val;
480  return res.ptr;
481  }
482 }
483 
485 static const char *decode_tag(upb_decstate *d, const char *ptr,
486  uint32_t *val) {
487  uint64_t byte = (uint8_t)*ptr;
488  if (UPB_LIKELY((byte & 0x80) == 0)) {
489  *val = byte;
490  return ptr + 1;
491  } else {
492  const char *start = ptr;
493  decode_vret res = decode_longvarint64(ptr, byte);
494  ptr = res.ptr;
495  *val = res.val;
496  if (!ptr || *val > UINT32_MAX || ptr - start > 5) decode_err(d);
497  return ptr;
498  }
499 }
500 
501 static void decode_munge(int type, wireval *val) {
502  switch (type) {
504  val->bool_val = val->uint64_val != 0;
505  break;
507  uint32_t n = val->uint32_val;
508  val->uint32_val = (n >> 1) ^ -(int32_t)(n & 1);
509  break;
510  }
512  uint64_t n = val->uint64_val;
513  val->uint64_val = (n >> 1) ^ -(int64_t)(n & 1);
514  break;
515  }
518  if (!_upb_isle()) {
519  /* The next stage will memcpy(dst, &val, 4) */
520  val->uint32_val = val->uint64_val;
521  }
522  break;
523  }
524 }
525 
527  uint32_t field_number,
528  int *last_field_index) {
529  static upb_msglayout_field none = {0, 0, 0, 0, 0, 0};
530 
531  if (l == NULL) return &none;
532 
533  size_t idx = ((size_t)field_number) - 1; // 0 wraps to SIZE_MAX
534  if (idx < l->dense_below) {
535  goto found;
536  }
537 
538  /* Resume scanning from last_field_index since fields are usually in order. */
539  int last = *last_field_index;
540  for (idx = last; idx < l->field_count; idx++) {
541  if (l->fields[idx].number == field_number) {
542  goto found;
543  }
544  }
545 
546  for (idx = 0; idx < last; idx++) {
547  if (l->fields[idx].number == field_number) {
548  goto found;
549  }
550  }
551 
552  return &none; /* Unknown field. */
553 
554  found:
555  UPB_ASSERT(l->fields[idx].number == field_number);
556  *last_field_index = idx;
557  return &l->fields[idx];
558 }
559 
561  upb_msglayout const *const *submsgs,
562  const upb_msglayout_field *field) {
563  const upb_msglayout *subl = submsgs[field->submsg_index];
564  return _upb_msg_new_inl(subl, &d->arena);
565 }
566 
568 const char *decode_isdonefallback(upb_decstate *d, const char *ptr,
569  int overrun) {
570  ptr = decode_isdonefallback_inl(d, ptr, overrun);
571  if (ptr == NULL) {
572  decode_err(d);
573  }
574  return ptr;
575 }
576 
577 static const char *decode_readstr(upb_decstate *d, const char *ptr, int size,
578  upb_strview *str) {
579  if (d->alias) {
580  str->data = ptr;
581  } else {
582  char *data = upb_arena_malloc(&d->arena, size);
583  if (!data) decode_err(d);
584  memcpy(data, ptr, size);
585  str->data = data;
586  }
587  str->size = size;
588  return ptr + size;
589 }
590 
592 static const char *decode_tosubmsg(upb_decstate *d, const char *ptr,
593  upb_msg *submsg,
594  upb_msglayout const *const *submsgs,
595  const upb_msglayout_field *field, int size) {
596  const upb_msglayout *subl = submsgs[field->submsg_index];
597  int saved_delta = decode_pushlimit(d, ptr, size);
598  if (--d->depth < 0) decode_err(d);
599  if (!decode_isdone(d, &ptr)) {
600  ptr = decode_msg(d, ptr, submsg, subl);
601  }
602  if (d->end_group != DECODE_NOGROUP) decode_err(d);
603  decode_poplimit(d, ptr, saved_delta);
604  d->depth++;
605  return ptr;
606 }
607 
609 static const char *decode_group(upb_decstate *d, const char *ptr,
610  upb_msg *submsg, const upb_msglayout *subl,
611  uint32_t number) {
612  if (--d->depth < 0) decode_err(d);
613  if (decode_isdone(d, &ptr)) {
614  decode_err(d);
615  }
616  ptr = decode_msg(d, ptr, submsg, subl);
617  if (d->end_group != number) decode_err(d);
618  d->end_group = DECODE_NOGROUP;
619  d->depth++;
620  return ptr;
621 }
622 
624 static const char *decode_togroup(upb_decstate *d, const char *ptr,
625  upb_msg *submsg,
626  upb_msglayout const *const *submsgs,
627  const upb_msglayout_field *field) {
628  const upb_msglayout *subl = submsgs[field->submsg_index];
629  return decode_group(d, ptr, submsg, subl, field->number);
630 }
631 
632 static const char *decode_toarray(upb_decstate *d, const char *ptr,
633  upb_msg *msg,
634  upb_msglayout const *const *submsgs,
635  const upb_msglayout_field *field, wireval *val,
636  int op) {
637  upb_array **arrp = UPB_PTR_AT(msg, field->offset, void);
638  upb_array *arr = *arrp;
639  void *mem;
640 
641  if (arr) {
642  decode_reserve(d, arr, 1);
643  } else {
644  size_t lg2 = desctype_to_elem_size_lg2[field->descriptortype];
645  arr = _upb_array_new(&d->arena, 4, lg2);
646  if (!arr) decode_err(d);
647  *arrp = arr;
648  }
649 
650  switch (op) {
651  case OP_SCALAR_LG2(0):
652  case OP_SCALAR_LG2(2):
653  case OP_SCALAR_LG2(3):
654  /* Append scalar value. */
655  mem = UPB_PTR_AT(_upb_array_ptr(arr), arr->len << op, void);
656  arr->len++;
657  memcpy(mem, val, 1 << op);
658  return ptr;
659  case OP_STRING:
660  decode_verifyutf8(d, ptr, val->size);
661  /* Fallthrough. */
662  case OP_BYTES: {
663  /* Append bytes. */
664  upb_strview *str = (upb_strview*)_upb_array_ptr(arr) + arr->len;
665  arr->len++;
666  return decode_readstr(d, ptr, val->size, str);
667  }
668  case OP_SUBMSG: {
669  /* Append submessage / group. */
670  upb_msg *submsg = decode_newsubmsg(d, submsgs, field);
671  *UPB_PTR_AT(_upb_array_ptr(arr), arr->len * sizeof(void *), upb_msg *) =
672  submsg;
673  arr->len++;
674  if (UPB_UNLIKELY(field->descriptortype == UPB_DTYPE_GROUP)) {
675  return decode_togroup(d, ptr, submsg, submsgs, field);
676  } else {
677  return decode_tosubmsg(d, ptr, submsg, submsgs, field, val->size);
678  }
679  }
680  case OP_FIXPCK_LG2(2):
681  case OP_FIXPCK_LG2(3): {
682  /* Fixed packed. */
683  int lg2 = op - OP_FIXPCK_LG2(0);
684  int mask = (1 << lg2) - 1;
685  size_t count = val->size >> lg2;
686  if ((val->size & mask) != 0) {
687  decode_err(d); /* Length isn't a round multiple of elem size. */
688  }
689  decode_reserve(d, arr, count);
690  mem = UPB_PTR_AT(_upb_array_ptr(arr), arr->len << lg2, void);
691  arr->len += count;
692  memcpy(mem, ptr, val->size); /* XXX: ptr boundary. */
693  return ptr + val->size;
694  }
695  case OP_VARPCK_LG2(0):
696  case OP_VARPCK_LG2(2):
697  case OP_VARPCK_LG2(3): {
698  /* Varint packed. */
699  int lg2 = op - OP_VARPCK_LG2(0);
700  int scale = 1 << lg2;
701  int saved_limit = decode_pushlimit(d, ptr, val->size);
702  char *out = UPB_PTR_AT(_upb_array_ptr(arr), arr->len << lg2, void);
703  while (!decode_isdone(d, &ptr)) {
704  wireval elem;
705  ptr = decode_varint64(d, ptr, &elem.uint64_val);
706  decode_munge(field->descriptortype, &elem);
707  if (decode_reserve(d, arr, 1)) {
708  out = UPB_PTR_AT(_upb_array_ptr(arr), arr->len << lg2, void);
709  }
710  arr->len++;
711  memcpy(out, &elem, scale);
712  out += scale;
713  }
714  decode_poplimit(d, ptr, saved_limit);
715  return ptr;
716  }
717  default:
718  UPB_UNREACHABLE();
719  }
720 }
721 
722 static const char *decode_tomap(upb_decstate *d, const char *ptr, upb_msg *msg,
723  upb_msglayout const *const *submsgs,
724  const upb_msglayout_field *field, wireval *val) {
725  upb_map **map_p = UPB_PTR_AT(msg, field->offset, upb_map *);
726  upb_map *map = *map_p;
727  upb_map_entry ent;
728  const upb_msglayout *entry = submsgs[field->submsg_index];
729 
730  if (!map) {
731  /* Lazily create map. */
732  const upb_msglayout_field *key_field = &entry->fields[0];
733  const upb_msglayout_field *val_field = &entry->fields[1];
734  char key_size = desctype_to_mapsize[key_field->descriptortype];
735  char val_size = desctype_to_mapsize[val_field->descriptortype];
736  UPB_ASSERT(key_field->offset == 0);
737  UPB_ASSERT(val_field->offset == sizeof(upb_strview));
738  map = _upb_map_new(&d->arena, key_size, val_size);
739  *map_p = map;
740  }
741 
742  /* Parse map entry. */
743  memset(&ent, 0, sizeof(ent));
744 
747  /* Create proactively to handle the case where it doesn't appear. */
748  ent.v.val = upb_value_ptr(_upb_msg_new(entry->submsgs[0], &d->arena));
749  }
750 
751  ptr = decode_tosubmsg(d, ptr, &ent.k, submsgs, field, val->size);
752  _upb_map_set(map, &ent.k, map->key_size, &ent.v, map->val_size, &d->arena);
753  return ptr;
754 }
755 
756 static const char *decode_tomsg(upb_decstate *d, const char *ptr, upb_msg *msg,
757  upb_msglayout const *const *submsgs,
758  const upb_msglayout_field *field, wireval *val,
759  int op) {
760  void *mem = UPB_PTR_AT(msg, field->offset, void);
761  int type = field->descriptortype;
762 
763  /* Set presence if necessary. */
764  if (field->presence > 0) {
766  } else if (field->presence < 0) {
767  /* Oneof case */
768  uint32_t *oneof_case = _upb_oneofcase_field(msg, field);
769  if (op == OP_SUBMSG && *oneof_case != field->number) {
770  memset(mem, 0, sizeof(void*));
771  }
772  *oneof_case = field->number;
773  }
774 
775  /* Store into message. */
776  switch (op) {
777  case OP_SUBMSG: {
778  upb_msg **submsgp = mem;
779  upb_msg *submsg = *submsgp;
780  if (!submsg) {
781  submsg = decode_newsubmsg(d, submsgs, field);
782  *submsgp = submsg;
783  }
785  ptr = decode_togroup(d, ptr, submsg, submsgs, field);
786  } else {
787  ptr = decode_tosubmsg(d, ptr, submsg, submsgs, field, val->size);
788  }
789  break;
790  }
791  case OP_STRING:
792  decode_verifyutf8(d, ptr, val->size);
793  /* Fallthrough. */
794  case OP_BYTES:
795  return decode_readstr(d, ptr, val->size, mem);
796  case OP_SCALAR_LG2(3):
797  memcpy(mem, val, 8);
798  break;
799  case OP_SCALAR_LG2(2):
800  memcpy(mem, val, 4);
801  break;
802  case OP_SCALAR_LG2(0):
803  memcpy(mem, val, 1);
804  break;
805  default:
806  UPB_UNREACHABLE();
807  }
808 
809  return ptr;
810 }
811 
813 static bool decode_tryfastdispatch(upb_decstate *d, const char **ptr,
814  upb_msg *msg, const upb_msglayout *layout) {
815 #if UPB_FASTTABLE
816  if (layout && layout->table_mask != (unsigned char)-1) {
819  *ptr = fastdecode_tagdispatch(d, *ptr, msg, table, 0, tag);
820  return true;
821  }
822 #endif
823  return false;
824 }
825 
827 static const char *decode_msg(upb_decstate *d, const char *ptr, upb_msg *msg,
828  const upb_msglayout *layout) {
829  int last_field_index = 0;
830  while (true) {
831  uint32_t tag;
832  const upb_msglayout_field *field;
833  int field_number;
834  int wire_type;
835  const char *field_start = ptr;
836  wireval val;
837  int op;
838 
839  UPB_ASSERT(ptr < d->limit_ptr);
840  ptr = decode_tag(d, ptr, &tag);
841  field_number = tag >> 3;
842  wire_type = tag & 7;
843 
844  field = upb_find_field(layout, field_number, &last_field_index);
845 
846  switch (wire_type) {
848  ptr = decode_varint64(d, ptr, &val.uint64_val);
849  op = varint_ops[field->descriptortype];
850  decode_munge(field->descriptortype, &val);
851  break;
852  case UPB_WIRE_TYPE_32BIT:
853  memcpy(&val.uint32_val, ptr, 4);
855  ptr += 4;
856  op = OP_SCALAR_LG2(2);
857  if (((1 << field->descriptortype) & fixed32_ok) == 0) goto unknown;
858  break;
859  case UPB_WIRE_TYPE_64BIT:
860  memcpy(&val.uint64_val, ptr, 8);
862  ptr += 8;
863  op = OP_SCALAR_LG2(3);
864  if (((1 << field->descriptortype) & fixed64_ok) == 0) goto unknown;
865  break;
867  int ndx = field->descriptortype;
868  uint64_t size;
869  if (_upb_getmode(field) == _UPB_MODE_ARRAY) ndx += 18;
870  ptr = decode_varint64(d, ptr, &size);
871  if (size >= INT32_MAX ||
872  ptr - d->end + (int32_t)size > d->limit) {
873  decode_err(d); /* Length overflow. */
874  }
875  op = delim_ops[ndx];
876  val.size = size;
877  break;
878  }
880  val.uint32_val = field_number;
881  op = OP_SUBMSG;
882  if (field->descriptortype != UPB_DTYPE_GROUP) goto unknown;
883  break;
885  d->end_group = field_number;
886  return ptr;
887  default:
888  decode_err(d);
889  }
890 
891  if (op >= 0) {
892  /* Parse, using op for dispatch. */
893  switch (_upb_getmode(field)) {
894  case _UPB_MODE_ARRAY:
895  ptr = decode_toarray(d, ptr, msg, layout->submsgs, field, &val, op);
896  break;
897  case _UPB_MODE_MAP:
898  ptr = decode_tomap(d, ptr, msg, layout->submsgs, field, &val);
899  break;
900  case _UPB_MODE_SCALAR:
901  ptr = decode_tomsg(d, ptr, msg, layout->submsgs, field, &val, op);
902  break;
903  default:
904  UPB_UNREACHABLE();
905  }
906  } else {
907  unknown:
908  /* Skip unknown field. */
909  if (field_number == 0) decode_err(d);
910  if (wire_type == UPB_WIRE_TYPE_DELIMITED) ptr += val.size;
911  if (msg) {
912  if (wire_type == UPB_WIRE_TYPE_START_GROUP) {
913  d->unknown = field_start;
914  d->unknown_msg = msg;
915  ptr = decode_group(d, ptr, NULL, NULL, field_number);
916  d->unknown_msg = NULL;
917  field_start = d->unknown;
918  }
919  if (!_upb_msg_addunknown(msg, field_start, ptr - field_start,
920  &d->arena)) {
921  decode_err(d);
922  }
923  } else if (wire_type == UPB_WIRE_TYPE_START_GROUP) {
924  ptr = decode_group(d, ptr, NULL, NULL, field_number);
925  }
926  }
927 
928  if (decode_isdone(d, &ptr)) return ptr;
929  if (decode_tryfastdispatch(d, &ptr, msg, layout)) return ptr;
930  }
931 }
932 
933 const char *fastdecode_generic(struct upb_decstate *d, const char *ptr,
934  upb_msg *msg, intptr_t table, uint64_t hasbits,
935  uint64_t data) {
936  (void)data;
937  *(uint32_t*)msg |= hasbits;
938  return decode_msg(d, ptr, msg, decode_totablep(table));
939 }
940 
941 static bool decode_top(struct upb_decstate *d, const char *buf, void *msg,
942  const upb_msglayout *l) {
943  if (!decode_tryfastdispatch(d, &buf, msg, l)) {
944  decode_msg(d, buf, msg, l);
945  }
946  return d->end_group == DECODE_NOGROUP;
947 }
948 
949 bool _upb_decode(const char *buf, size_t size, void *msg,
950  const upb_msglayout *l, const upb_extreg *extreg, int options,
951  upb_arena *arena) {
952  bool ok;
954  unsigned depth = (unsigned)options >> 16;
955 
956  if (size == 0) {
957  return true;
958  } else if (size <= 16) {
959  memset(&state.patch, 0, 32);
960  memcpy(&state.patch, buf, size);
961  buf = state.patch;
962  state.end = buf + size;
963  state.limit = 0;
964  state.alias = false;
965  } else {
966  state.end = buf + size - 16;
967  state.limit = 16;
968  state.alias = options & UPB_DECODE_ALIAS;
969  }
970 
971  state.limit_ptr = state.end;
972  state.unknown_msg = NULL;
973  state.depth = depth ? depth : 64;
974  state.end_group = DECODE_NOGROUP;
975  state.arena.head = arena->head;
976  state.arena.last_size = arena->last_size;
977  state.arena.cleanup_metadata = arena->cleanup_metadata;
978  state.arena.parent = arena;
979 
980  if (UPB_UNLIKELY(UPB_SETJMP(state.err))) {
981  ok = false;
982  } else {
983  ok = decode_top(&state, buf, msg, l);
984  }
985 
986  arena->head.ptr = state.arena.head.ptr;
987  arena->head.end = state.arena.head.end;
988  arena->cleanup_metadata = state.arena.cleanup_metadata;
989  return ok;
990 }
991 
992 #undef OP_SCALAR_LG2
993 #undef OP_FIXPCK_LG2
994 #undef OP_VARPCK_LG2
995 #undef OP_STRING
996 #undef OP_SUBMSG
997 
999 /* We encode backwards, to avoid pre-computing lengths (one-pass encode). */
1000 
1001 
1002 #include <setjmp.h>
1003 #include <string.h>
1004 
1005 
1006 /* Must be last. */
1007 
1008 #define UPB_PB_VARINT_MAX_LEN 10
1009 
1011 static size_t encode_varint64(uint64_t val, char *buf) {
1012  size_t i = 0;
1013  do {
1014  uint8_t byte = val & 0x7fU;
1015  val >>= 7;
1016  if (val) byte |= 0x80U;
1017  buf[i++] = byte;
1018  } while (val);
1019  return i;
1020 }
1021 
1022 static uint32_t encode_zz32(int32_t n) { return ((uint32_t)n << 1) ^ (n >> 31); }
1023 static uint64_t encode_zz64(int64_t n) { return ((uint64_t)n << 1) ^ (n >> 63); }
1024 
1025 typedef struct {
1026  jmp_buf err;
1027  upb_alloc *alloc;
1028  char *buf, *ptr, *limit;
1029  int options;
1030  int depth;
1032 } upb_encstate;
1033 
1034 static size_t upb_roundup_pow2(size_t bytes) {
1035  size_t ret = 128;
1036  while (ret < bytes) {
1037  ret *= 2;
1038  }
1039  return ret;
1040 }
1041 
1043  UPB_LONGJMP(e->err, 1);
1044 }
1045 
1047 static void encode_growbuffer(upb_encstate *e, size_t bytes) {
1048  size_t old_size = e->limit - e->buf;
1049  size_t new_size = upb_roundup_pow2(bytes + (e->limit - e->ptr));
1050  char *new_buf = upb_realloc(e->alloc, e->buf, old_size, new_size);
1051 
1052  if (!new_buf) encode_err(e);
1053 
1054  /* We want previous data at the end, realloc() put it at the beginning. */
1055  if (old_size > 0) {
1056  memmove(new_buf + new_size - old_size, e->buf, old_size);
1057  }
1058 
1059  e->ptr = new_buf + new_size - (e->limit - e->ptr);
1060  e->limit = new_buf + new_size;
1061  e->buf = new_buf;
1062 
1063  e->ptr -= bytes;
1064 }
1065 
1066 /* Call to ensure that at least "bytes" bytes are available for writing at
1067  * e->ptr. Returns false if the bytes could not be allocated. */
1069 static void encode_reserve(upb_encstate *e, size_t bytes) {
1070  if ((size_t)(e->ptr - e->buf) < bytes) {
1072  return;
1073  }
1074 
1075  e->ptr -= bytes;
1076 }
1077 
1078 /* Writes the given bytes to the buffer, handling reserve/advance. */
1079 static void encode_bytes(upb_encstate *e, const void *data, size_t len) {
1080  if (len == 0) return; /* memcpy() with zero size is UB */
1081  encode_reserve(e, len);
1082  memcpy(e->ptr, data, len);
1083 }
1084 
1085 static void encode_fixed64(upb_encstate *e, uint64_t val) {
1086  val = _upb_be_swap64(val);
1087  encode_bytes(e, &val, sizeof(uint64_t));
1088 }
1089 
1090 static void encode_fixed32(upb_encstate *e, uint32_t val) {
1091  val = _upb_be_swap32(val);
1092  encode_bytes(e, &val, sizeof(uint32_t));
1093 }
1094 
1097  size_t len;
1098  char *start;
1099 
1101  len = encode_varint64(val, e->ptr);
1102  start = e->ptr + UPB_PB_VARINT_MAX_LEN - len;
1103  memmove(start, e->ptr, len);
1104  e->ptr = start;
1105 }
1106 
1108 static void encode_varint(upb_encstate *e, uint64_t val) {
1109  if (val < 128 && e->ptr != e->buf) {
1110  --e->ptr;
1111  *e->ptr = val;
1112  } else {
1113  encode_longvarint(e, val);
1114  }
1115 }
1116 
1117 static void encode_double(upb_encstate *e, double d) {
1118  uint64_t u64;
1119  UPB_ASSERT(sizeof(double) == sizeof(uint64_t));
1120  memcpy(&u64, &d, sizeof(uint64_t));
1121  encode_fixed64(e, u64);
1122 }
1123 
1124 static void encode_float(upb_encstate *e, float d) {
1125  uint32_t u32;
1126  UPB_ASSERT(sizeof(float) == sizeof(uint32_t));
1127  memcpy(&u32, &d, sizeof(uint32_t));
1128  encode_fixed32(e, u32);
1129 }
1130 
1131 static void encode_tag(upb_encstate *e, uint32_t field_number,
1132  uint8_t wire_type) {
1133  encode_varint(e, (field_number << 3) | wire_type);
1134 }
1135 
1136 static void encode_fixedarray(upb_encstate *e, const upb_array *arr,
1137  size_t elem_size, uint32_t tag) {
1138  size_t bytes = arr->len * elem_size;
1139  const char* data = _upb_array_constptr(arr);
1140  const char* ptr = data + bytes - elem_size;
1141  if (tag) {
1142  while (true) {
1143  encode_bytes(e, ptr, elem_size);
1144  encode_varint(e, tag);
1145  if (ptr == data) break;
1146  ptr -= elem_size;
1147  }
1148  } else {
1149  encode_bytes(e, data, bytes);
1150  }
1151 }
1152 
1153 static void encode_message(upb_encstate *e, const upb_msg *msg,
1154  const upb_msglayout *m, size_t *size);
1155 
1156 static void encode_scalar(upb_encstate *e, const void *_field_mem,
1157  const upb_msglayout *m, const upb_msglayout_field *f,
1158  bool skip_zero_value) {
1159  const char *field_mem = _field_mem;
1160  int wire_type;
1161 
1162 #define CASE(ctype, type, wtype, encodeval) \
1163  { \
1164  ctype val = *(ctype *)field_mem; \
1165  if (skip_zero_value && val == 0) { \
1166  return; \
1167  } \
1168  encode_##type(e, encodeval); \
1169  wire_type = wtype; \
1170  break; \
1171  }
1172 
1173  switch (f->descriptortype) {
1175  CASE(double, double, UPB_WIRE_TYPE_64BIT, val);
1177  CASE(float, float, UPB_WIRE_TYPE_32BIT, val);
1180  CASE(uint64_t, varint, UPB_WIRE_TYPE_VARINT, val);
1182  CASE(uint32_t, varint, UPB_WIRE_TYPE_VARINT, val);
1185  CASE(int32_t, varint, UPB_WIRE_TYPE_VARINT, (int64_t)val);
1188  CASE(uint64_t, fixed64, UPB_WIRE_TYPE_64BIT, val);
1191  CASE(uint32_t, fixed32, UPB_WIRE_TYPE_32BIT, val);
1193  CASE(bool, varint, UPB_WIRE_TYPE_VARINT, val);
1195  CASE(int32_t, varint, UPB_WIRE_TYPE_VARINT, encode_zz32(val));
1197  CASE(int64_t, varint, UPB_WIRE_TYPE_VARINT, encode_zz64(val));
1200  upb_strview view = *(upb_strview*)field_mem;
1201  if (skip_zero_value && view.size == 0) {
1202  return;
1203  }
1204  encode_bytes(e, view.data, view.size);
1205  encode_varint(e, view.size);
1206  wire_type = UPB_WIRE_TYPE_DELIMITED;
1207  break;
1208  }
1210  size_t size;
1211  void *submsg = *(void **)field_mem;
1212  const upb_msglayout *subm = m->submsgs[f->submsg_index];
1213  if (submsg == NULL) {
1214  return;
1215  }
1216  if (--e->depth == 0) encode_err(e);
1217  encode_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP);
1218  encode_message(e, submsg, subm, &size);
1219  wire_type = UPB_WIRE_TYPE_START_GROUP;
1220  e->depth++;
1221  break;
1222  }
1224  size_t size;
1225  void *submsg = *(void **)field_mem;
1226  const upb_msglayout *subm = m->submsgs[f->submsg_index];
1227  if (submsg == NULL) {
1228  return;
1229  }
1230  if (--e->depth == 0) encode_err(e);
1231  encode_message(e, submsg, subm, &size);
1232  encode_varint(e, size);
1233  wire_type = UPB_WIRE_TYPE_DELIMITED;
1234  e->depth++;
1235  break;
1236  }
1237  default:
1238  UPB_UNREACHABLE();
1239  }
1240 #undef CASE
1241 
1242  encode_tag(e, f->number, wire_type);
1243 }
1244 
1245 static void encode_array(upb_encstate *e, const upb_msg *msg,
1246  const upb_msglayout *m, const upb_msglayout_field *f) {
1247  const upb_array *arr = *UPB_PTR_AT(msg, f->offset, upb_array*);
1248  bool packed = f->mode & _UPB_MODE_IS_PACKED;
1249  size_t pre_len = e->limit - e->ptr;
1250 
1251  if (arr == NULL || arr->len == 0) {
1252  return;
1253  }
1254 
1255 #define VARINT_CASE(ctype, encode) \
1256  { \
1257  const ctype *start = _upb_array_constptr(arr); \
1258  const ctype *ptr = start + arr->len; \
1259  uint32_t tag = packed ? 0 : (f->number << 3) | UPB_WIRE_TYPE_VARINT; \
1260  do { \
1261  ptr--; \
1262  encode_varint(e, encode); \
1263  if (tag) encode_varint(e, tag); \
1264  } while (ptr != start); \
1265  } \
1266  break;
1267 
1268 #define TAG(wire_type) (packed ? 0 : (f->number << 3 | wire_type))
1269 
1270  switch (f->descriptortype) {
1272  encode_fixedarray(e, arr, sizeof(double), TAG(UPB_WIRE_TYPE_64BIT));
1273  break;
1275  encode_fixedarray(e, arr, sizeof(float), TAG(UPB_WIRE_TYPE_32BIT));
1276  break;
1280  break;
1284  break;
1294  VARINT_CASE(bool, *ptr);
1301  const upb_strview *start = _upb_array_constptr(arr);
1302  const upb_strview *ptr = start + arr->len;
1303  do {
1304  ptr--;
1305  encode_bytes(e, ptr->data, ptr->size);
1306  encode_varint(e, ptr->size);
1307  encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED);
1308  } while (ptr != start);
1309  return;
1310  }
1312  const void *const*start = _upb_array_constptr(arr);
1313  const void *const*ptr = start + arr->len;
1314  const upb_msglayout *subm = m->submsgs[f->submsg_index];
1315  if (--e->depth == 0) encode_err(e);
1316  do {
1317  size_t size;
1318  ptr--;
1319  encode_tag(e, f->number, UPB_WIRE_TYPE_END_GROUP);
1320  encode_message(e, *ptr, subm, &size);
1321  encode_tag(e, f->number, UPB_WIRE_TYPE_START_GROUP);
1322  } while (ptr != start);
1323  e->depth++;
1324  return;
1325  }
1327  const void *const*start = _upb_array_constptr(arr);
1328  const void *const*ptr = start + arr->len;
1329  const upb_msglayout *subm = m->submsgs[f->submsg_index];
1330  if (--e->depth == 0) encode_err(e);
1331  do {
1332  size_t size;
1333  ptr--;
1334  encode_message(e, *ptr, subm, &size);
1335  encode_varint(e, size);
1336  encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED);
1337  } while (ptr != start);
1338  e->depth++;
1339  return;
1340  }
1341  }
1342 #undef VARINT_CASE
1343 
1344  if (packed) {
1345  encode_varint(e, e->limit - e->ptr - pre_len);
1346  encode_tag(e, f->number, UPB_WIRE_TYPE_DELIMITED);
1347  }
1348 }
1349 
1351  const upb_msglayout *layout,
1352  const upb_map_entry *ent) {
1353  const upb_msglayout_field *key_field = &layout->fields[0];
1354  const upb_msglayout_field *val_field = &layout->fields[1];
1355  size_t pre_len = e->limit - e->ptr;
1356  size_t size;
1357  encode_scalar(e, &ent->v, layout, val_field, false);
1358  encode_scalar(e, &ent->k, layout, key_field, false);
1359  size = (e->limit - e->ptr) - pre_len;
1360  encode_varint(e, size);
1362 }
1363 
1364 static void encode_map(upb_encstate *e, const upb_msg *msg,
1365  const upb_msglayout *m, const upb_msglayout_field *f) {
1366  const upb_map *map = *UPB_PTR_AT(msg, f->offset, const upb_map*);
1367  const upb_msglayout *layout = m->submsgs[f->submsg_index];
1368  UPB_ASSERT(layout->field_count == 2);
1369 
1370  if (map == NULL) return;
1371 
1372  if (e->options & UPB_ENCODE_DETERMINISTIC) {
1373  _upb_sortedmap sorted;
1374  _upb_mapsorter_pushmap(&e->sorter, layout->fields[0].descriptortype, map,
1375  &sorted);
1376  upb_map_entry ent;
1377  while (_upb_sortedmap_next(&e->sorter, map, &sorted, &ent)) {
1378  encode_mapentry(e, f->number, layout, &ent);
1379  }
1380  _upb_mapsorter_popmap(&e->sorter, &sorted);
1381  } else {
1383  upb_strtable_begin(&i, &map->table);
1384  for(; !upb_strtable_done(&i); upb_strtable_next(&i)) {
1386  const upb_value val = upb_strtable_iter_value(&i);
1387  upb_map_entry ent;
1388  _upb_map_fromkey(key, &ent.k, map->key_size);
1389  _upb_map_fromvalue(val, &ent.v, map->val_size);
1390  encode_mapentry(e, f->number, layout, &ent);
1391  }
1392  }
1393 }
1394 
1395 static void encode_scalarfield(upb_encstate *e, const char *msg,
1396  const upb_msglayout *m,
1397  const upb_msglayout_field *f) {
1398  bool skip_empty = false;
1399  if (f->presence == 0) {
1400  /* Proto3 presence. */
1401  skip_empty = true;
1402  } else if (f->presence > 0) {
1403  /* Proto2 presence: hasbit. */
1404  if (!_upb_hasbit_field(msg, f)) return;
1405  } else {
1406  /* Field is in a oneof. */
1407  if (_upb_getoneofcase_field(msg, f) != f->number) return;
1408  }
1409  encode_scalar(e, msg + f->offset, m, f, skip_empty);
1410 }
1411 
1412 static void encode_message(upb_encstate *e, const upb_msg *msg,
1413  const upb_msglayout *m, size_t *size) {
1414  size_t pre_len = e->limit - e->ptr;
1415  const upb_msglayout_field *f = &m->fields[m->field_count];
1416  const upb_msglayout_field *first = &m->fields[0];
1417 
1418  if ((e->options & UPB_ENCODE_SKIPUNKNOWN) == 0) {
1419  size_t unknown_size;
1420  const char *unknown = upb_msg_getunknown(msg, &unknown_size);
1421 
1422  if (unknown) {
1423  encode_bytes(e, unknown, unknown_size);
1424  }
1425  }
1426 
1427  while (f != first) {
1428  f--;
1429  switch (_upb_getmode(f)) {
1430  case _UPB_MODE_ARRAY:
1431  encode_array(e, msg, m, f);
1432  break;
1433  case _UPB_MODE_MAP:
1434  encode_map(e, msg, m, f);
1435  break;
1436  case _UPB_MODE_SCALAR:
1437  encode_scalarfield(e, msg, m, f);
1438  break;
1439  default:
1440  UPB_UNREACHABLE();
1441  }
1442  }
1443 
1444  *size = (e->limit - e->ptr) - pre_len;
1445 }
1446 
1447 char *upb_encode_ex(const void *msg, const upb_msglayout *l, int options,
1448  upb_arena *arena, size_t *size) {
1449  upb_encstate e;
1450  unsigned depth = (unsigned)options >> 16;
1451 
1452  e.alloc = upb_arena_alloc(arena);
1453  e.buf = NULL;
1454  e.limit = NULL;
1455  e.ptr = NULL;
1456  e.depth = depth ? depth : 64;
1457  e.options = options;
1458  _upb_mapsorter_init(&e.sorter);
1459  char *ret = NULL;
1460 
1461  if (UPB_SETJMP(e.err)) {
1462  *size = 0;
1463  ret = NULL;
1464  } else {
1465  encode_message(&e, msg, l, size);
1466  *size = e.limit - e.ptr;
1467  if (*size == 0) {
1468  static char ch;
1469  ret = &ch;
1470  } else {
1471  UPB_ASSERT(e.ptr);
1472  ret = e.ptr;
1473  }
1474  }
1475 
1476  _upb_mapsorter_destroy(&e.sorter);
1477  return ret;
1478 }
1479 
1485 static const size_t overhead = sizeof(upb_msg_internaldata);
1486 
1488  ptrdiff_t size = sizeof(upb_msg_internal);
1489  return (upb_msg_internal*)((char*)msg - size);
1490 }
1491 
1493  return _upb_msg_new_inl(l, a);
1494 }
1495 
1497  void *mem = UPB_PTR_AT(msg, -sizeof(upb_msg_internal), char);
1498  memset(mem, 0, upb_msg_sizeof(l));
1499 }
1500 
1501 static bool realloc_internal(upb_msg *msg, size_t need, upb_arena *arena) {
1503  if (!in->internal) {
1504  /* No internal data, allocate from scratch. */
1505  size_t size = UPB_MAX(128, _upb_lg2ceilsize(need + overhead));
1507  if (!internal) return false;
1508  internal->size = size;
1509  internal->unknown_end = overhead;
1510  internal->ext_begin = size;
1511  in->internal = internal;
1512  } else if (in->internal->ext_begin - in->internal->unknown_end < need) {
1513  /* Internal data is too small, reallocate. */
1514  size_t new_size = _upb_lg2ceilsize(in->internal->size + need);
1515  size_t ext_bytes = in->internal->size - in->internal->ext_begin;
1516  size_t new_ext_begin = new_size - ext_bytes;
1517  upb_msg_internaldata *internal =
1518  upb_arena_realloc(arena, in->internal, in->internal->size, new_size);
1519  if (!internal) return false;
1520  if (ext_bytes) {
1521  /* Need to move extension data to the end. */
1522  char *ptr = (char*)internal;
1523  memmove(ptr + new_ext_begin, ptr + internal->ext_begin, ext_bytes);
1524  }
1525  internal->ext_begin = new_ext_begin;
1526  internal->size = new_size;
1527  in->internal = internal;
1528  }
1529  UPB_ASSERT(in->internal->ext_begin - in->internal->unknown_end >= need);
1530  return true;
1531 }
1532 
1533 bool _upb_msg_addunknown(upb_msg *msg, const char *data, size_t len,
1534  upb_arena *arena) {
1535  if (!realloc_internal(msg, len, arena)) return false;
1537  memcpy(UPB_PTR_AT(in->internal, in->internal->unknown_end, char), data, len);
1538  in->internal->unknown_end += len;
1539  return true;
1540 }
1541 
1544  if (in->internal) {
1545  in->internal->unknown_end = overhead;
1546  }
1547 }
1548 
1549 const char *upb_msg_getunknown(const upb_msg *msg, size_t *len) {
1551  if (in->internal) {
1552  *len = in->internal->unknown_end - overhead;
1553  return (char*)(in->internal + 1);
1554  } else {
1555  *len = 0;
1556  return NULL;
1557  }
1558 }
1559 
1560 const upb_msg_ext *_upb_msg_getexts(const upb_msg *msg, size_t *count) {
1562  if (in->internal) {
1563  *count =
1564  (in->internal->size - in->internal->ext_begin) / sizeof(upb_msg_ext);
1565  return UPB_PTR_AT(in->internal, in->internal->ext_begin, void);
1566  } else {
1567  *count = 0;
1568  return NULL;
1569  }
1570 }
1571 
1573  const upb_msglayout_ext *e) {
1574  size_t n;
1575  const upb_msg_ext *ext = _upb_msg_getexts(msg, &n);
1576 
1577  /* For now we use linear search exclusively to find extensions. If this
1578  * becomes an issue due to messages with lots of extensions, we can introduce
1579  * a table of some sort. */
1580  for (size_t i = 0; i < n; i++) {
1581  if (ext[i].ext == e) {
1582  return &ext[i];
1583  }
1584  }
1585 
1586  return NULL;
1587 }
1588 
1590  upb_arena *arena) {
1592  if (ext) return ext;
1593  if (!realloc_internal(msg, sizeof(upb_msg_ext), arena)) return NULL;
1595  in->internal->ext_begin -= sizeof(upb_msg_ext);
1596  ext = UPB_PTR_AT(in->internal, in->internal->ext_begin, void);
1597  memset(ext, 0, sizeof(upb_msg_ext));
1598  ext->ext = e;
1599  return ext;
1600 }
1601 
1604 bool _upb_array_realloc(upb_array *arr, size_t min_size, upb_arena *arena) {
1605  size_t new_size = UPB_MAX(arr->size, 4);
1606  int elem_size_lg2 = arr->data & 7;
1607  size_t old_bytes = arr->size << elem_size_lg2;
1608  size_t new_bytes;
1609  void* ptr = _upb_array_ptr(arr);
1610 
1611  /* Log2 ceiling of size. */
1612  while (new_size < min_size) new_size *= 2;
1613 
1614  new_bytes = new_size << elem_size_lg2;
1615  ptr = upb_arena_realloc(arena, ptr, old_bytes, new_bytes);
1616 
1617  if (!ptr) {
1618  return false;
1619  }
1620 
1621  arr->data = _upb_tag_arrptr(ptr, elem_size_lg2);
1622  arr->size = new_size;
1623  return true;
1624 }
1625 
1626 static upb_array *getorcreate_array(upb_array **arr_ptr, int elem_size_lg2,
1627  upb_arena *arena) {
1628  upb_array *arr = *arr_ptr;
1629  if (!arr) {
1630  arr = _upb_array_new(arena, 4, elem_size_lg2);
1631  if (!arr) return NULL;
1632  *arr_ptr = arr;
1633  }
1634  return arr;
1635 }
1636 
1638  int elem_size_lg2, upb_arena *arena) {
1639  upb_array *arr = getorcreate_array(arr_ptr, elem_size_lg2, arena);
1640  return arr && _upb_array_resize(arr, size, arena) ? _upb_array_ptr(arr)
1641  : NULL;
1642 }
1643 
1644 bool _upb_array_append_fallback(upb_array **arr_ptr, const void *value,
1645  int elem_size_lg2, upb_arena *arena) {
1646  upb_array *arr = getorcreate_array(arr_ptr, elem_size_lg2, arena);
1647  if (!arr) return false;
1648 
1649  size_t elems = arr->len;
1650 
1651  if (!_upb_array_resize(arr, elems + 1, arena)) {
1652  return false;
1653  }
1654 
1655  char *data = _upb_array_ptr(arr);
1656  memcpy(data + (elems << elem_size_lg2), value, 1 << elem_size_lg2);
1657  return true;
1658 }
1659 
1662 upb_map *_upb_map_new(upb_arena *a, size_t key_size, size_t value_size) {
1663  upb_map *map = upb_arena_malloc(a, sizeof(upb_map));
1664 
1665  if (!map) {
1666  return NULL;
1667  }
1668 
1669  upb_strtable_init(&map->table, 4, a);
1670  map->key_size = key_size;
1671  map->val_size = value_size;
1672 
1673  return map;
1674 }
1675 
1676 static void _upb_mapsorter_getkeys(const void *_a, const void *_b, void *a_key,
1677  void *b_key, size_t size) {
1678  const upb_tabent *const*a = _a;
1679  const upb_tabent *const*b = _b;
1680  upb_strview a_tabkey = upb_tabstrview((*a)->key);
1681  upb_strview b_tabkey = upb_tabstrview((*b)->key);
1682  _upb_map_fromkey(a_tabkey, a_key, size);
1683  _upb_map_fromkey(b_tabkey, b_key, size);
1684 }
1685 
1686 static int _upb_mapsorter_cmpi64(const void *_a, const void *_b) {
1687  int64_t a, b;
1688  _upb_mapsorter_getkeys(_a, _b, &a, &b, 8);
1689  return a - b;
1690 }
1691 
1692 static int _upb_mapsorter_cmpu64(const void *_a, const void *_b) {
1693  uint64_t a, b;
1694  _upb_mapsorter_getkeys(_a, _b, &a, &b, 8);
1695  return a - b;
1696 }
1697 
1698 static int _upb_mapsorter_cmpi32(const void *_a, const void *_b) {
1699  int32_t a, b;
1700  _upb_mapsorter_getkeys(_a, _b, &a, &b, 4);
1701  return a - b;
1702 }
1703 
1704 static int _upb_mapsorter_cmpu32(const void *_a, const void *_b) {
1705  uint32_t a, b;
1706  _upb_mapsorter_getkeys(_a, _b, &a, &b, 4);
1707  return a - b;
1708 }
1709 
1710 static int _upb_mapsorter_cmpbool(const void *_a, const void *_b) {
1711  bool a, b;
1712  _upb_mapsorter_getkeys(_a, _b, &a, &b, 1);
1713  return a - b;
1714 }
1715 
1716 static int _upb_mapsorter_cmpstr(const void *_a, const void *_b) {
1717  upb_strview a, b;
1719  size_t common_size = UPB_MIN(a.size, b.size);
1720  int cmp = memcmp(a.data, b.data, common_size);
1721  if (cmp) return cmp;
1722  return a.size - b.size;
1723 }
1724 
1726  const upb_map *map, _upb_sortedmap *sorted) {
1727  int map_size = _upb_map_size(map);
1728  sorted->start = s->size;
1729  sorted->pos = sorted->start;
1730  sorted->end = sorted->start + map_size;
1731 
1732  /* Grow s->entries if necessary. */
1733  if (sorted->end > s->cap) {
1734  s->cap = _upb_lg2ceilsize(sorted->end);
1735  s->entries = realloc(s->entries, s->cap * sizeof(*s->entries));
1736  if (!s->entries) return false;
1737  }
1738 
1739  s->size = sorted->end;
1740 
1741  /* Copy non-empty entries from the table to s->entries. */
1742  upb_tabent const**dst = &s->entries[sorted->start];
1743  const upb_tabent *src = map->table.t.entries;
1744  const upb_tabent *end = src + upb_table_size(&map->table.t);
1745  for (; src < end; src++) {
1746  if (!upb_tabent_isempty(src)) {
1747  *dst = src;
1748  dst++;
1749  }
1750  }
1751  UPB_ASSERT(dst == &s->entries[sorted->end]);
1752 
1753  /* Sort entries according to the key type. */
1754 
1755  int (*compar)(const void *, const void *);
1756 
1757  switch (key_type) {
1761  compar = _upb_mapsorter_cmpi64;
1762  break;
1765  compar = _upb_mapsorter_cmpu64;
1766  break;
1771  compar = _upb_mapsorter_cmpi32;
1772  break;
1775  compar = _upb_mapsorter_cmpu32;
1776  break;
1778  compar = _upb_mapsorter_cmpbool;
1779  break;
1781  compar = _upb_mapsorter_cmpstr;
1782  break;
1783  default:
1784  UPB_UNREACHABLE();
1785  }
1786 
1787  qsort(&s->entries[sorted->start], map_size, sizeof(*s->entries), compar);
1788  return true;
1789 }
1790 
1793 struct upb_extreg {
1795  upb_strtable exts; /* Key is upb_msglayout* concatenated with fieldnum. */
1796 };
1797 
1798 #define EXTREG_KEY_SIZE (sizeof(upb_msglayout*) + sizeof(uint32_t))
1799 
1800 static void extreg_key(char *buf, const upb_msglayout *l, uint32_t fieldnum) {
1801  memcpy(buf, &l, sizeof(l));
1802  memcpy(buf + sizeof(l), &fieldnum, sizeof(fieldnum));
1803 }
1804 
1806  upb_extreg *r = upb_arena_malloc(arena, sizeof(*r));
1807  if (!r) return NULL;
1808  r->arena = arena;
1809  if (!upb_strtable_init(&r->exts, 8, arena)) return NULL;
1810  return r;
1811 }
1812 
1814  char buf[EXTREG_KEY_SIZE];
1815  const upb_msglayout_ext *start = e;
1816  const upb_msglayout_ext *end = e + count;
1817  for (; e < end; e++) {
1818  extreg_key(buf, e->extendee, e->field.number);
1819  if (!upb_strtable_insert(&r->exts, buf, EXTREG_KEY_SIZE,
1820  upb_value_constptr(e), r->arena)) {
1821  goto failure;
1822  }
1823  }
1824  return true;
1825 
1826 failure:
1827  /* Back out the entries previously added. */
1828  for (end = e, e = start; e < end; e++) {
1829  extreg_key(buf, e->extendee, e->field.number);
1830  upb_strtable_remove(&r->exts, buf, EXTREG_KEY_SIZE, NULL);
1831  }
1832  return false;
1833 }
1834 
1836  const upb_msglayout *l,
1837  uint32_t num) {
1838  char buf[EXTREG_KEY_SIZE];
1839  upb_value v;
1840  extreg_key(buf, l, num);
1841  if (upb_strtable_lookup2(&r->exts, buf, EXTREG_KEY_SIZE, &v)) {
1842  return upb_value_getconstptr(v);
1843  } else {
1844  return NULL;
1845  }
1846 }
1847 
1849 /*
1850  * upb_table Implementation
1851  *
1852  * Implementation is heavily inspired by Lua's ltable.c.
1853  */
1854 
1855 #include <string.h>
1856 
1857 
1858 /* Must be last. */
1859 
1860 #define UPB_MAXARRSIZE 16 /* 64k. */
1861 
1862 /* From Chromium. */
1863 #define ARRAY_SIZE(x) \
1864  ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
1865 
1866 static const double MAX_LOAD = 0.85;
1867 
1868 /* The minimum utilization of the array part of a mixed hash/array table. This
1869  * is a speed/memory-usage tradeoff (though it's not straightforward because of
1870  * cache effects). The lower this is, the more memory we'll use. */
1871 static const double MIN_DENSITY = 0.1;
1872 
1873 static bool is_pow2(uint64_t v) { return v == 0 || (v & (v - 1)) == 0; }
1874 
1876  upb_value ret;
1877  _upb_value_setval(&ret, val);
1878  return ret;
1879 }
1880 
1881 static int log2ceil(uint64_t v) {
1882  int ret = 0;
1883  bool pow2 = is_pow2(v);
1884  while (v >>= 1) ret++;
1885  ret = pow2 ? ret : ret + 1; /* Ceiling. */
1886  return UPB_MIN(UPB_MAXARRSIZE, ret);
1887 }
1888 
1889 char *upb_strdup2(const char *s, size_t len, upb_arena *a) {
1890  size_t n;
1891  char *p;
1892 
1893  /* Prevent overflow errors. */
1894  if (len == SIZE_MAX) return NULL;
1895  /* Always null-terminate, even if binary data; but don't rely on the input to
1896  * have a null-terminating byte since it may be a raw binary buffer. */
1897  n = len + 1;
1898  p = upb_arena_malloc(a, n);
1899  if (p) {
1900  memcpy(p, s, len);
1901  p[len] = 0;
1902  }
1903  return p;
1904 }
1905 
1906 /* A type to represent the lookup key of either a strtable or an inttable. */
1907 typedef union {
1908  uintptr_t num;
1909  struct {
1910  const char *str;
1911  size_t len;
1912  } str;
1913 } lookupkey_t;
1914 
1915 static lookupkey_t strkey2(const char *str, size_t len) {
1916  lookupkey_t k;
1917  k.str.str = str;
1918  k.str.len = len;
1919  return k;
1920 }
1921 
1923  lookupkey_t k;
1924  k.num = key;
1925  return k;
1926 }
1927 
1930 
1931 /* Base table (shared code) ***************************************************/
1932 
1934  return (uint32_t)key;
1935 }
1936 
1937 static const upb_tabent *upb_getentry(const upb_table *t, uint32_t hash) {
1938  return t->entries + (hash & t->mask);
1939 }
1940 
1941 static bool upb_arrhas(upb_tabval key) {
1942  return key.val != (uint64_t)-1;
1943 }
1944 
1945 
1946 static bool isfull(upb_table *t) {
1947  return t->count == t->max_count;
1948 }
1949 
1950 static bool init(upb_table *t, uint8_t size_lg2, upb_arena *a) {
1951  size_t bytes;
1952 
1953  t->count = 0;
1954  t->size_lg2 = size_lg2;
1955  t->mask = upb_table_size(t) ? upb_table_size(t) - 1 : 0;
1956  t->max_count = upb_table_size(t) * MAX_LOAD;
1957  bytes = upb_table_size(t) * sizeof(upb_tabent);
1958  if (bytes > 0) {
1959  t->entries = upb_arena_malloc(a, bytes);
1960  if (!t->entries) return false;
1961  memset(t->entries, 0, bytes);
1962  } else {
1963  t->entries = NULL;
1964  }
1965  return true;
1966 }
1967 
1969  upb_tabent *begin = t->entries;
1971  for (e = e + 1; e < end; e++) {
1972  if (upb_tabent_isempty(e)) return e;
1973  }
1974  for (e = begin; e < end; e++) {
1975  if (upb_tabent_isempty(e)) return e;
1976  }
1977  UPB_ASSERT(false);
1978  return NULL;
1979 }
1980 
1982  return (upb_tabent*)upb_getentry(t, hash);
1983 }
1984 
1986  uint32_t hash, eqlfunc_t *eql) {
1987  const upb_tabent *e;
1988 
1989  if (t->size_lg2 == 0) return NULL;
1990  e = upb_getentry(t, hash);
1991  if (upb_tabent_isempty(e)) return NULL;
1992  while (1) {
1993  if (eql(e->key, key)) return e;
1994  if ((e = e->next) == NULL) return NULL;
1995  }
1996 }
1997 
1999  uint32_t hash, eqlfunc_t *eql) {
2000  return (upb_tabent*)findentry(t, key, hash, eql);
2001 }
2002 
2003 static bool lookup(const upb_table *t, lookupkey_t key, upb_value *v,
2004  uint32_t hash, eqlfunc_t *eql) {
2005  const upb_tabent *e = findentry(t, key, hash, eql);
2006  if (e) {
2007  if (v) {
2008  _upb_value_setval(v, e->val.val);
2009  }
2010  return true;
2011  } else {
2012  return false;
2013  }
2014 }
2015 
2016 /* The given key must not already exist in the table. */
2017 static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey,
2018  upb_value val, uint32_t hash,
2019  hashfunc_t *hashfunc, eqlfunc_t *eql) {
2020  upb_tabent *mainpos_e;
2021  upb_tabent *our_e;
2022 
2023  UPB_ASSERT(findentry(t, key, hash, eql) == NULL);
2024 
2025  t->count++;
2026  mainpos_e = getentry_mutable(t, hash);
2027  our_e = mainpos_e;
2028 
2029  if (upb_tabent_isempty(mainpos_e)) {
2030  /* Our main position is empty; use it. */
2031  our_e->next = NULL;
2032  } else {
2033  /* Collision. */
2034  upb_tabent *new_e = emptyent(t, mainpos_e);
2035  /* Head of collider's chain. */
2036  upb_tabent *chain = getentry_mutable(t, hashfunc(mainpos_e->key));
2037  if (chain == mainpos_e) {
2038  /* Existing ent is in its main position (it has the same hash as us, and
2039  * is the head of our chain). Insert to new ent and append to this chain. */
2040  new_e->next = mainpos_e->next;
2041  mainpos_e->next = new_e;
2042  our_e = new_e;
2043  } else {
2044  /* Existing ent is not in its main position (it is a node in some other
2045  * chain). This implies that no existing ent in the table has our hash.
2046  * Evict it (updating its chain) and use its ent for head of our chain. */
2047  *new_e = *mainpos_e; /* copies next. */
2048  while (chain->next != mainpos_e) {
2049  chain = (upb_tabent*)chain->next;
2050  UPB_ASSERT(chain);
2051  }
2052  chain->next = new_e;
2053  our_e = mainpos_e;
2054  our_e->next = NULL;
2055  }
2056  }
2057  our_e->key = tabkey;
2058  our_e->val.val = val.val;
2059  UPB_ASSERT(findentry(t, key, hash, eql) == our_e);
2060 }
2061 
2062 static bool rm(upb_table *t, lookupkey_t key, upb_value *val,
2063  upb_tabkey *removed, uint32_t hash, eqlfunc_t *eql) {
2064  upb_tabent *chain = getentry_mutable(t, hash);
2065  if (upb_tabent_isempty(chain)) return false;
2066  if (eql(chain->key, key)) {
2067  /* Element to remove is at the head of its chain. */
2068  t->count--;
2069  if (val) _upb_value_setval(val, chain->val.val);
2070  if (removed) *removed = chain->key;
2071  if (chain->next) {
2072  upb_tabent *move = (upb_tabent*)chain->next;
2073  *chain = *move;
2074  move->key = 0; /* Make the slot empty. */
2075  } else {
2076  chain->key = 0; /* Make the slot empty. */
2077  }
2078  return true;
2079  } else {
2080  /* Element to remove is either in a non-head position or not in the
2081  * table. */
2082  while (chain->next && !eql(chain->next->key, key)) {
2083  chain = (upb_tabent*)chain->next;
2084  }
2085  if (chain->next) {
2086  /* Found element to remove. */
2087  upb_tabent *rm = (upb_tabent*)chain->next;
2088  t->count--;
2089  if (val) _upb_value_setval(val, chain->next->val.val);
2090  if (removed) *removed = rm->key;
2091  rm->key = 0; /* Make the slot empty. */
2092  chain->next = rm->next;
2093  return true;
2094  } else {
2095  /* Element to remove is not in the table. */
2096  return false;
2097  }
2098  }
2099 }
2100 
2101 static size_t next(const upb_table *t, size_t i) {
2102  do {
2103  if (++i >= upb_table_size(t))
2104  return SIZE_MAX - 1; /* Distinct from -1. */
2105  } while(upb_tabent_isempty(&t->entries[i]));
2106 
2107  return i;
2108 }
2109 
2110 static size_t begin(const upb_table *t) {
2111  return next(t, -1);
2112 }
2113 
2114 
2115 /* upb_strtable ***************************************************************/
2116 
2117 /* A simple "subclass" of upb_table that only adds a hash function for strings. */
2118 
2120  uint32_t len = (uint32_t) k2.str.len;
2121  char *str = upb_arena_malloc(a, k2.str.len + sizeof(uint32_t) + 1);
2122  if (str == NULL) return 0;
2123  memcpy(str, &len, sizeof(uint32_t));
2124  if (k2.str.len) memcpy(str + sizeof(uint32_t), k2.str.str, k2.str.len);
2125  str[sizeof(uint32_t) + k2.str.len] = '\0';
2126  return (uintptr_t)str;
2127 }
2128 
2129 /* Adapted from ABSL's wyhash. */
2130 
2131 static uint64_t UnalignedLoad64(const void *p) {
2132  uint64_t val;
2133  memcpy(&val, p, 8);
2134  return val;
2135 }
2136 
2137 static uint32_t UnalignedLoad32(const void *p) {
2138  uint32_t val;
2139  memcpy(&val, p, 4);
2140  return val;
2141 }
2142 
2143 #if defined(_MSC_VER) && defined(_M_X64)
2144 #include <intrin.h>
2145 #endif
2146 
2147 /* Computes a * b, returning the low 64 bits of the result and storing the high
2148  * 64 bits in |*high|. */
2149 static uint64_t upb_umul128(uint64_t v0, uint64_t v1, uint64_t* out_high) {
2150 #ifdef __SIZEOF_INT128__
2151  __uint128_t p = v0;
2152  p *= v1;
2153  *out_high = (uint64_t)(p >> 64);
2154  return (uint64_t)p;
2155 #elif defined(_MSC_VER) && defined(_M_X64)
2156  return _umul128(v0, v1, out_high);
2157 #else
2158  uint64_t a32 = v0 >> 32;
2159  uint64_t a00 = v0 & 0xffffffff;
2160  uint64_t b32 = v1 >> 32;
2161  uint64_t b00 = v1 & 0xffffffff;
2162  uint64_t high = a32 * b32;
2163  uint64_t low = a00 * b00;
2164  uint64_t mid1 = a32 * b00;
2165  uint64_t mid2 = a00 * b32;
2166  low += (mid1 << 32) + (mid2 << 32);
2167  // Omit carry bit, for mixing we do not care about exact numerical precision.
2168  high += (mid1 >> 32) + (mid2 >> 32);
2169  *out_high = high;
2170  return low;
2171 #endif
2172 }
2173 
2175  uint64_t high;
2176  uint64_t low = upb_umul128(v0, v1, &high);
2177  return low ^ high;
2178 }
2179 
2180 static uint64_t Wyhash(const void *data, size_t len, uint64_t seed,
2181  const uint64_t salt[]) {
2182  const uint8_t* ptr = (const uint8_t*)data;
2183  uint64_t starting_length = (uint64_t)len;
2184  uint64_t current_state = seed ^ salt[0];
2185 
2186  if (len > 64) {
2187  // If we have more than 64 bytes, we're going to handle chunks of 64
2188  // bytes at a time. We're going to build up two separate hash states
2189  // which we will then hash together.
2190  uint64_t duplicated_state = current_state;
2191 
2192  do {
2194  uint64_t b = UnalignedLoad64(ptr + 8);
2195  uint64_t c = UnalignedLoad64(ptr + 16);
2196  uint64_t d = UnalignedLoad64(ptr + 24);
2197  uint64_t e = UnalignedLoad64(ptr + 32);
2198  uint64_t f = UnalignedLoad64(ptr + 40);
2199  uint64_t g = UnalignedLoad64(ptr + 48);
2200  uint64_t h = UnalignedLoad64(ptr + 56);
2201 
2202  uint64_t cs0 = WyhashMix(a ^ salt[1], b ^ current_state);
2203  uint64_t cs1 = WyhashMix(c ^ salt[2], d ^ current_state);
2204  current_state = (cs0 ^ cs1);
2205 
2206  uint64_t ds0 = WyhashMix(e ^ salt[3], f ^ duplicated_state);
2207  uint64_t ds1 = WyhashMix(g ^ salt[4], h ^ duplicated_state);
2208  duplicated_state = (ds0 ^ ds1);
2209 
2210  ptr += 64;
2211  len -= 64;
2212  } while (len > 64);
2213 
2214  current_state = current_state ^ duplicated_state;
2215  }
2216 
2217  // We now have a data `ptr` with at most 64 bytes and the current state
2218  // of the hashing state machine stored in current_state.
2219  while (len > 16) {
2221  uint64_t b = UnalignedLoad64(ptr + 8);
2222 
2223  current_state = WyhashMix(a ^ salt[1], b ^ current_state);
2224 
2225  ptr += 16;
2226  len -= 16;
2227  }
2228 
2229  // We now have a data `ptr` with at most 16 bytes.
2230  uint64_t a = 0;
2231  uint64_t b = 0;
2232  if (len > 8) {
2233  // When we have at least 9 and at most 16 bytes, set A to the first 64
2234  // bits of the input and B to the last 64 bits of the input. Yes, they will
2235  // overlap in the middle if we are working with less than the full 16
2236  // bytes.
2237  a = UnalignedLoad64(ptr);
2238  b = UnalignedLoad64(ptr + len - 8);
2239  } else if (len > 3) {
2240  // If we have at least 4 and at most 8 bytes, set A to the first 32
2241  // bits and B to the last 32 bits.
2242  a = UnalignedLoad32(ptr);
2243  b = UnalignedLoad32(ptr + len - 4);
2244  } else if (len > 0) {
2245  // If we have at least 1 and at most 3 bytes, read all of the provided
2246  // bits into A, with some adjustments.
2247  a = ((ptr[0] << 16) | (ptr[len >> 1] << 8) | ptr[len - 1]);
2248  b = 0;
2249  } else {
2250  a = 0;
2251  b = 0;
2252  }
2253 
2254  uint64_t w = WyhashMix(a ^ salt[1], b ^ current_state);
2255  uint64_t z = salt[1] ^ starting_length;
2256  return WyhashMix(w, z);
2257 }
2258 
2259 const uint64_t kWyhashSalt[5] = {
2260  0x243F6A8885A308D3ULL, 0x13198A2E03707344ULL, 0xA4093822299F31D0ULL,
2261  0x082EFA98EC4E6C89ULL, 0x452821E638D01377ULL,
2262 };
2263 
2264 static uint32_t table_hash(const char *p, size_t n) {
2265  return Wyhash(p, n, 0, kWyhashSalt);
2266 }
2267 
2269  uint32_t len;
2270  char *str = upb_tabstr(key, &len);
2271  return table_hash(str, len);
2272 }
2273 
2275  uint32_t len;
2276  char *str = upb_tabstr(k1, &len);
2277  return len == k2.str.len && (len == 0 || memcmp(str, k2.str.str, len) == 0);
2278 }
2279 
2280 bool upb_strtable_init(upb_strtable *t, size_t expected_size, upb_arena *a) {
2281  // Multiply by approximate reciprocal of MAX_LOAD (0.85), with pow2 denominator.
2282  size_t need_entries = (expected_size + 1) * 1204 / 1024;
2283  UPB_ASSERT(need_entries >= expected_size * 0.85);
2284  int size_lg2 = _upb_lg2ceil(need_entries);
2285  return init(&t->t, size_lg2, a);
2286 }
2287 
2289  size_t bytes = upb_table_size(&t->t) * sizeof(upb_tabent);
2290  t->t.count = 0;
2291  memset((char*)t->t.entries, 0, bytes);
2292 }
2293 
2294 bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_arena *a) {
2295  upb_strtable new_table;
2297 
2298  if (!init(&new_table.t, size_lg2, a))
2299  return false;
2300  upb_strtable_begin(&i, t);
2301  for ( ; !upb_strtable_done(&i); upb_strtable_next(&i)) {
2303  upb_strtable_insert(&new_table, key.data, key.size,
2305  }
2306  *t = new_table;
2307  return true;
2308 }
2309 
2310 bool upb_strtable_insert(upb_strtable *t, const char *k, size_t len,
2311  upb_value v, upb_arena *a) {
2312  lookupkey_t key;
2313  upb_tabkey tabkey;
2314  uint32_t hash;
2315 
2316  if (isfull(&t->t)) {
2317  /* Need to resize. New table of double the size, add old elements to it. */
2318  if (!upb_strtable_resize(t, t->t.size_lg2 + 1, a)) {
2319  return false;
2320  }
2321  }
2322 
2323  key = strkey2(k, len);
2324  tabkey = strcopy(key, a);
2325  if (tabkey == 0) return false;
2326 
2327  hash = table_hash(key.str.str, key.str.len);
2328  insert(&t->t, key, tabkey, v, hash, &strhash, &streql);
2329  return true;
2330 }
2331 
2332 bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len,
2333  upb_value *v) {
2335  return lookup(&t->t, strkey2(key, len), v, hash, &streql);
2336 }
2337 
2338 bool upb_strtable_remove(upb_strtable *t, const char *key, size_t len,
2339  upb_value *val) {
2341  upb_tabkey tabkey;
2342  return rm(&t->t, strkey2(key, len), val, &tabkey, hash, &streql);
2343 }
2344 
2345 /* Iteration */
2346 
2348  i->t = t;
2349  i->index = begin(&t->t);
2350 }
2351 
2353  i->index = next(&i->t->t, i->index);
2354 }
2355 
2357  if (!i->t) return true;
2358  return i->index >= upb_table_size(&i->t->t) ||
2360 }
2361 
2363  upb_strview key;
2364  uint32_t len;
2366  key.data = upb_tabstr(str_tabent(i)->key, &len);
2367  key.size = len;
2368  return key;
2369 }
2370 
2373  return _upb_value_val(str_tabent(i)->val.val);
2374 }
2375 
2377  i->t = NULL;
2378  i->index = SIZE_MAX;
2379 }
2380 
2382  const upb_strtable_iter *i2) {
2384  return true;
2385  return i1->t == i2->t && i1->index == i2->index;
2386 }
2387 
2388 
2389 /* upb_inttable ***************************************************************/
2390 
2391 /* For inttables we use a hybrid structure where small keys are kept in an
2392  * array and large keys are put in the hash table. */
2393 
2395 
2397  return k1 == k2.num;
2398 }
2399 
2401  return (upb_tabval*)t->array;
2402 }
2403 
2405  if (key < t->array_size) {
2406  return upb_arrhas(t->array[key]) ? &(mutable_array(t)[key]) : NULL;
2407  } else {
2408  upb_tabent *e =
2410  return e ? &e->val : NULL;
2411  }
2412 }
2413 
2415  uintptr_t key) {
2416  return inttable_val((upb_inttable*)t, key);
2417 }
2418 
2420  return t->t.count + t->array_count;
2421 }
2422 
2423 static void check(upb_inttable *t) {
2424  UPB_UNUSED(t);
2425 #if defined(UPB_DEBUG_TABLE) && !defined(NDEBUG)
2426  {
2427  /* This check is very expensive (makes inserts/deletes O(N)). */
2428  size_t count = 0;
2430  upb_inttable_begin(&i, t);
2431  for(; !upb_inttable_done(&i); upb_inttable_next(&i), count++) {
2433  }
2435  }
2436 #endif
2437 }
2438 
2439 bool upb_inttable_sizedinit(upb_inttable *t, size_t asize, int hsize_lg2,
2440  upb_arena *a) {
2441  size_t array_bytes;
2442 
2443  if (!init(&t->t, hsize_lg2, a)) return false;
2444  /* Always make the array part at least 1 long, so that we know key 0
2445  * won't be in the hash part, which simplifies things. */
2446  t->array_size = UPB_MAX(1, asize);
2447  t->array_count = 0;
2448  array_bytes = t->array_size * sizeof(upb_value);
2449  t->array = upb_arena_malloc(a, array_bytes);
2450  if (!t->array) {
2451  return false;
2452  }
2453  memset(mutable_array(t), 0xff, array_bytes);
2454  check(t);
2455  return true;
2456 }
2457 
2459  return upb_inttable_sizedinit(t, 0, 4, a);
2460 }
2461 
2463  upb_arena *a) {
2464  upb_tabval tabval;
2465  tabval.val = val.val;
2466  UPB_ASSERT(upb_arrhas(tabval)); /* This will reject (uint64_t)-1. Fix this. */
2467 
2468  if (key < t->array_size) {
2469  UPB_ASSERT(!upb_arrhas(t->array[key]));
2470  t->array_count++;
2471  mutable_array(t)[key].val = val.val;
2472  } else {
2473  if (isfull(&t->t)) {
2474  /* Need to resize the hash part, but we re-use the array part. */
2475  size_t i;
2476  upb_table new_table;
2477 
2478  if (!init(&new_table, t->t.size_lg2 + 1, a)) {
2479  return false;
2480  }
2481 
2482  for (i = begin(&t->t); i < upb_table_size(&t->t); i = next(&t->t, i)) {
2483  const upb_tabent *e = &t->t.entries[i];
2484  uint32_t hash;
2485  upb_value v;
2486 
2487  _upb_value_setval(&v, e->val.val);
2488  hash = upb_inthash(e->key);
2489  insert(&new_table, intkey(e->key), e->key, v, hash, &inthash, &inteql);
2490  }
2491 
2492  UPB_ASSERT(t->t.count == new_table.count);
2493 
2494  t->t = new_table;
2495  }
2496  insert(&t->t, intkey(key), key, val, upb_inthash(key), &inthash, &inteql);
2497  }
2498  check(t);
2499  return true;
2500 }
2501 
2503  const upb_tabval *table_v = inttable_val_const(t, key);
2504  if (!table_v) return false;
2505  if (v) _upb_value_setval(v, table_v->val);
2506  return true;
2507 }
2508 
2510  upb_tabval *table_v = inttable_val(t, key);
2511  if (!table_v) return false;
2512  table_v->val = val.val;
2513  return true;
2514 }
2515 
2517  bool success;
2518  if (key < t->array_size) {
2519  if (upb_arrhas(t->array[key])) {
2521  t->array_count--;
2522  if (val) {
2523  _upb_value_setval(val, t->array[key].val);
2524  }
2525  mutable_array(t)[key] = empty;
2526  success = true;
2527  } else {
2528  success = false;
2529  }
2530  } else {
2531  success = rm(&t->t, intkey(key), val, NULL, upb_inthash(key), &inteql);
2532  }
2533  check(t);
2534  return success;
2535 }
2536 
2538  /* A power-of-two histogram of the table keys. */
2539  size_t counts[UPB_MAXARRSIZE + 1] = {0};
2540 
2541  /* The max key in each bucket. */
2542  uintptr_t max[UPB_MAXARRSIZE + 1] = {0};
2543 
2545  size_t arr_count;
2546  int size_lg2;
2547  upb_inttable new_t;
2548 
2549  upb_inttable_begin(&i, t);
2550  for (; !upb_inttable_done(&i); upb_inttable_next(&i)) {
2552  int bucket = log2ceil(key);
2553  max[bucket] = UPB_MAX(max[bucket], key);
2554  counts[bucket]++;
2555  }
2556 
2557  /* Find the largest power of two that satisfies the MIN_DENSITY
2558  * definition (while actually having some keys). */
2559  arr_count = upb_inttable_count(t);
2560 
2561  for (size_lg2 = ARRAY_SIZE(counts) - 1; size_lg2 > 0; size_lg2--) {
2562  if (counts[size_lg2] == 0) {
2563  /* We can halve again without losing any entries. */
2564  continue;
2565  } else if (arr_count >= (1 << size_lg2) * MIN_DENSITY) {
2566  break;
2567  }
2568 
2569  arr_count -= counts[size_lg2];
2570  }
2571 
2572  UPB_ASSERT(arr_count <= upb_inttable_count(t));
2573 
2574  {
2575  /* Insert all elements into new, perfectly-sized table. */
2576  size_t arr_size = max[size_lg2] + 1; /* +1 so arr[max] will fit. */
2577  size_t hash_count = upb_inttable_count(t) - arr_count;
2578  size_t hash_size = hash_count ? (hash_count / MAX_LOAD) + 1 : 0;
2579  int hashsize_lg2 = log2ceil(hash_size);
2580 
2581  upb_inttable_sizedinit(&new_t, arr_size, hashsize_lg2, a);
2582  upb_inttable_begin(&i, t);
2583  for (; !upb_inttable_done(&i); upb_inttable_next(&i)) {
2586  }
2587  UPB_ASSERT(new_t.array_size == arr_size);
2588  UPB_ASSERT(new_t.t.size_lg2 == hashsize_lg2);
2589  }
2590  *t = new_t;
2591 }
2592 
2593 /* Iteration. */
2594 
2595 static const upb_tabent *int_tabent(const upb_inttable_iter *i) {
2596  UPB_ASSERT(!i->array_part);
2597  return &i->t->t.entries[i->index];
2598 }
2599 
2601  UPB_ASSERT(i->array_part);
2602  return i->t->array[i->index];
2603 }
2604 
2606  i->t = t;
2607  i->index = -1;
2608  i->array_part = true;
2610 }
2611 
2613  const upb_inttable *t = iter->t;
2614  if (iter->array_part) {
2615  while (++iter->index < t->array_size) {
2616  if (upb_arrhas(int_arrent(iter))) {
2617  return;
2618  }
2619  }
2620  iter->array_part = false;
2621  iter->index = begin(&t->t);
2622  } else {
2623  iter->index = next(&t->t, iter->index);
2624  }
2625 }
2626 
2628  if (!i->t) return true;
2629  if (i->array_part) {
2630  return i->index >= i->t->array_size ||
2631  !upb_arrhas(int_arrent(i));
2632  } else {
2633  return i->index >= upb_table_size(&i->t->t) ||
2635  }
2636 }
2637 
2640  return i->array_part ? i->index : int_tabent(i)->key;
2641 }
2642 
2645  return _upb_value_val(
2646  i->array_part ? i->t->array[i->index].val : int_tabent(i)->val.val);
2647 }
2648 
2650  i->t = NULL;
2651  i->index = SIZE_MAX;
2652  i->array_part = false;
2653 }
2654 
2656  const upb_inttable_iter *i2) {
2658  return true;
2659  return i1->t == i2->t && i1->index == i2->index &&
2660  i1->array_part == i2->array_part;
2661 }
2662 
2665 #include <errno.h>
2666 #include <stdarg.h>
2667 #include <stddef.h>
2668 #include <stdint.h>
2669 #include <stdio.h>
2670 #include <stdlib.h>
2671 #include <string.h>
2672 
2673 
2674 /* upb_status *****************************************************************/
2675 
2677  if (!status) return;
2678  status->ok = true;
2679  status->msg[0] = '\0';
2680 }
2681 
2682 bool upb_ok(const upb_status *status) { return status->ok; }
2683 
2684 const char *upb_status_errmsg(const upb_status *status) { return status->msg; }
2685 
2687  if (!status) return;
2688  status->ok = false;
2689  strncpy(status->msg, msg, UPB_STATUS_MAX_MESSAGE - 1);
2690  status->msg[UPB_STATUS_MAX_MESSAGE - 1] = '\0';
2691 }
2692 
2693 void upb_status_seterrf(upb_status *status, const char *fmt, ...) {
2694  va_list args;
2695  va_start(args, fmt);
2697  va_end(args);
2698 }
2699 
2700 void upb_status_vseterrf(upb_status *status, const char *fmt, va_list args) {
2701  if (!status) return;
2702  status->ok = false;
2703  vsnprintf(status->msg, sizeof(status->msg), fmt, args);
2704  status->msg[UPB_STATUS_MAX_MESSAGE - 1] = '\0';
2705 }
2706 
2707 void upb_status_vappenderrf(upb_status *status, const char *fmt, va_list args) {
2708  size_t len;
2709  if (!status) return;
2710  status->ok = false;
2711  len = strlen(status->msg);
2712  vsnprintf(status->msg + len, sizeof(status->msg) - len, fmt, args);
2713  status->msg[UPB_STATUS_MAX_MESSAGE - 1] = '\0';
2714 }
2715 
2716 /* upb_alloc ******************************************************************/
2717 
2718 static void *upb_global_allocfunc(upb_alloc *alloc, void *ptr, size_t oldsize,
2719  size_t size) {
2720  UPB_UNUSED(alloc);
2721  UPB_UNUSED(oldsize);
2722  if (size == 0) {
2723  free(ptr);
2724  return NULL;
2725  } else {
2726  return realloc(ptr, size);
2727  }
2728 }
2729 
2730 static uint32_t *upb_cleanup_pointer(uintptr_t cleanup_metadata) {
2731  return (uint32_t *)(cleanup_metadata & ~0x1);
2732 }
2733 
2734 static bool upb_cleanup_has_initial_block(uintptr_t cleanup_metadata) {
2735  return cleanup_metadata & 0x1;
2736 }
2737 
2739  bool has_initial_block) {
2740  return (uintptr_t)cleanup | has_initial_block;
2741 }
2742 
2744 
2745 /* upb_arena ******************************************************************/
2746 
2747 /* Be conservative and choose 16 in case anyone is using SSE. */
2748 
2749 struct mem_block {
2750  struct mem_block *next;
2753  /* Data follows. */
2754 };
2755 
2756 typedef struct cleanup_ent {
2758  void *ud;
2759 } cleanup_ent;
2760 
2761 static const size_t memblock_reserve = UPB_ALIGN_UP(sizeof(mem_block), 16);
2762 
2764  /* Path splitting keeps time complexity down, see:
2765  * https://en.wikipedia.org/wiki/Disjoint-set_data_structure */
2766  while (a->parent != a) {
2767  upb_arena *next = a->parent;
2768  a->parent = next->parent;
2769  a = next;
2770  }
2771  return a;
2772 }
2773 
2775  size_t size) {
2776  mem_block *block = ptr;
2777 
2778  /* The block is for arena |a|, but should appear in the freelist of |root|. */
2779  block->next = root->freelist;
2780  block->size = (uint32_t)size;
2781  block->cleanups = 0;
2782  root->freelist = block;
2783  a->last_size = block->size;
2784  if (!root->freelist_tail) root->freelist_tail = block;
2785 
2786  a->head.ptr = UPB_PTR_AT(block, memblock_reserve, char);
2787  a->head.end = UPB_PTR_AT(block, size, char);
2788  a->cleanup_metadata = upb_cleanup_metadata(
2789  &block->cleanups, upb_cleanup_has_initial_block(a->cleanup_metadata));
2790 
2791  UPB_POISON_MEMORY_REGION(a->head.ptr, a->head.end - a->head.ptr);
2792 }
2793 
2794 static bool upb_arena_allocblock(upb_arena *a, size_t size) {
2796  size_t block_size = UPB_MAX(size, a->last_size * 2) + memblock_reserve;
2797  mem_block *block = upb_malloc(root->block_alloc, block_size);
2798 
2799  if (!block) return false;
2800  upb_arena_addblock(a, root, block, block_size);
2801  return true;
2802 }
2803 
2805  if (!upb_arena_allocblock(a, size)) return NULL; /* Out of memory. */
2807  return upb_arena_malloc(a, size);
2808 }
2809 
2810 static void *upb_arena_doalloc(upb_alloc *alloc, void *ptr, size_t oldsize,
2811  size_t size) {
2812  upb_arena *a = (upb_arena*)alloc; /* upb_alloc is initial member. */
2813  return upb_arena_realloc(a, ptr, oldsize, size);
2814 }
2815 
2816 /* Public Arena API ***********************************************************/
2817 
2819  const size_t first_block_overhead = sizeof(upb_arena) + memblock_reserve;
2820  upb_arena *a;
2821 
2822  /* We need to malloc the initial block. */
2823  n = first_block_overhead + 256;
2824  if (!alloc || !(mem = upb_malloc(alloc, n))) {
2825  return NULL;
2826  }
2827 
2828  a = UPB_PTR_AT(mem, n - sizeof(*a), upb_arena);
2829  n -= sizeof(*a);
2830 
2831  a->head.alloc.func = &upb_arena_doalloc;
2832  a->block_alloc = alloc;
2833  a->parent = a;
2834  a->refcount = 1;
2835  a->freelist = NULL;
2836  a->freelist_tail = NULL;
2837  a->cleanup_metadata = upb_cleanup_metadata(NULL, false);
2838 
2839  upb_arena_addblock(a, a, mem, n);
2840 
2841  return a;
2842 }
2843 
2845  upb_arena *a;
2846 
2847  /* Round block size down to alignof(*a) since we will allocate the arena
2848  * itself at the end. */
2850 
2851  if (UPB_UNLIKELY(n < sizeof(upb_arena))) {
2852  return arena_initslow(mem, n, alloc);
2853  }
2854 
2855  a = UPB_PTR_AT(mem, n - sizeof(*a), upb_arena);
2856 
2857  a->head.alloc.func = &upb_arena_doalloc;
2858  a->block_alloc = alloc;
2859  a->parent = a;
2860  a->refcount = 1;
2861  a->last_size = UPB_MAX(128, n);
2862  a->head.ptr = mem;
2863  a->head.end = UPB_PTR_AT(mem, n - sizeof(*a), char);
2864  a->freelist = NULL;
2865  a->cleanup_metadata = upb_cleanup_metadata(NULL, true);
2866 
2867  return a;
2868 }
2869 
2870 static void arena_dofree(upb_arena *a) {
2871  mem_block *block = a->freelist;
2872  UPB_ASSERT(a->parent == a);
2873  UPB_ASSERT(a->refcount == 0);
2874 
2875  while (block) {
2876  /* Load first since we are deleting block. */
2877  mem_block *next = block->next;
2878 
2879  if (block->cleanups > 0) {
2880  cleanup_ent *end = UPB_PTR_AT(block, block->size, void);
2881  cleanup_ent *ptr = end - block->cleanups;
2882 
2883  for (; ptr < end; ptr++) {
2884  ptr->cleanup(ptr->ud);
2885  }
2886  }
2887 
2888  upb_free(a->block_alloc, block);
2889  block = next;
2890  }
2891 }
2892 
2894  a = arena_findroot(a);
2895  if (--a->refcount == 0) arena_dofree(a);
2896 }
2897 
2899  cleanup_ent *ent;
2900  uint32_t* cleanups = upb_cleanup_pointer(a->cleanup_metadata);
2901 
2902  if (!cleanups || _upb_arenahas(a) < sizeof(cleanup_ent)) {
2903  if (!upb_arena_allocblock(a, 128)) return false; /* Out of memory. */
2904  UPB_ASSERT(_upb_arenahas(a) >= sizeof(cleanup_ent));
2905  cleanups = upb_cleanup_pointer(a->cleanup_metadata);
2906  }
2907 
2908  a->head.end -= sizeof(cleanup_ent);
2909  ent = (cleanup_ent*)a->head.end;
2910  (*cleanups)++;
2912 
2913  ent->cleanup = func;
2914  ent->ud = ud;
2915 
2916  return true;
2917 }
2918 
2920  upb_arena *r1 = arena_findroot(a1);
2921  upb_arena *r2 = arena_findroot(a2);
2922 
2923  if (r1 == r2) return true; /* Already fused. */
2924 
2925  /* Do not fuse initial blocks since we cannot lifetime extend them. */
2926  if (upb_cleanup_has_initial_block(r1->cleanup_metadata)) return false;
2927  if (upb_cleanup_has_initial_block(r2->cleanup_metadata)) return false;
2928 
2929  /* Only allow fuse with a common allocator */
2930  if (r1->block_alloc != r2->block_alloc) return false;
2931 
2932  /* We want to join the smaller tree to the larger tree.
2933  * So swap first if they are backwards. */
2934  if (r1->refcount < r2->refcount) {
2935  upb_arena *tmp = r1;
2936  r1 = r2;
2937  r2 = tmp;
2938  }
2939 
2940  /* r1 takes over r2's freelist and refcount. */
2941  r1->refcount += r2->refcount;
2942  if (r2->freelist_tail) {
2943  UPB_ASSERT(r2->freelist_tail->next == NULL);
2944  r2->freelist_tail->next = r1->freelist;
2945  r1->freelist = r2->freelist;
2946  }
2947  r2->parent = r1;
2948  return true;
2949 }
2950 
2952 // Fast decoder: ~3x the speed of decode.c, but requires x86-64/ARM64.
2953 // Also the table size grows by 2x.
2954 //
2955 // Could potentially be ported to other 64-bit archs that pass at least six
2956 // arguments in registers and have 8 unused high bits in pointers.
2957 //
2958 // The overall design is to create specialized functions for every possible
2959 // field type (eg. oneof boolean field with a 1 byte tag) and then dispatch
2960 // to the specialized function as quickly as possible.
2961 
2962 
2963 
2964 /* Must be last. */
2965 
2966 #if UPB_FASTTABLE
2967 
2968 // The standard set of arguments passed to each parsing function.
2969 // Thanks to x86-64 calling conventions, these will stay in registers.
2970 #define UPB_PARSE_PARAMS \
2971  upb_decstate *d, const char *ptr, upb_msg *msg, intptr_t table, \
2972  uint64_t hasbits, uint64_t data
2973 
2974 #define UPB_PARSE_ARGS d, ptr, msg, table, hasbits, data
2975 
2976 #define RETURN_GENERIC(m) \
2977  /* Uncomment either of these for debugging purposes. */ \
2978  /* fprintf(stderr, m); */ \
2979  /*__builtin_trap(); */ \
2980  return fastdecode_generic(d, ptr, msg, table, hasbits, 0);
2981 
2982 typedef enum {
2983  CARD_s = 0, /* Singular (optional, non-repeated) */
2984  CARD_o = 1, /* Oneof */
2985  CARD_r = 2, /* Repeated */
2986  CARD_p = 3 /* Packed Repeated */
2987 } upb_card;
2988 
2990 static const char *fastdecode_isdonefallback(UPB_PARSE_PARAMS) {
2991  int overrun = data;
2992  ptr = decode_isdonefallback_inl(d, ptr, overrun);
2993  if (ptr == NULL) {
2994  return fastdecode_err(d);
2995  }
2997  UPB_MUSTTAIL return fastdecode_tagdispatch(UPB_PARSE_ARGS);
2998 }
2999 
3001 static const char *fastdecode_dispatch(UPB_PARSE_PARAMS) {
3002  if (UPB_UNLIKELY(ptr >= d->limit_ptr)) {
3003  int overrun = ptr - d->end;
3004  if (UPB_LIKELY(overrun == d->limit)) {
3005  // Parse is finished.
3006  *(uint32_t*)msg |= hasbits; // Sync hasbits.
3007  return ptr;
3008  } else {
3009  data = overrun;
3010  UPB_MUSTTAIL return fastdecode_isdonefallback(UPB_PARSE_ARGS);
3011  }
3012  }
3013 
3014  // Read two bytes of tag data (for a one-byte tag, the high byte is junk).
3016  UPB_MUSTTAIL return fastdecode_tagdispatch(UPB_PARSE_ARGS);
3017 }
3018 
3020 static bool fastdecode_checktag(uint16_t data, int tagbytes) {
3021  if (tagbytes == 1) {
3022  return (data & 0xff) == 0;
3023  } else {
3024  return data == 0;
3025  }
3026 }
3027 
3029 static const char *fastdecode_longsize(const char *ptr, int *size) {
3030  int i;
3031  UPB_ASSERT(*size & 0x80);
3032  *size &= 0xff;
3033  for (i = 0; i < 3; i++) {
3034  ptr++;
3035  size_t byte = (uint8_t)ptr[-1];
3036  *size += (byte - 1) << (7 + 7 * i);
3037  if (UPB_LIKELY((byte & 0x80) == 0)) return ptr;
3038  }
3039  ptr++;
3040  size_t byte = (uint8_t)ptr[-1];
3041  // len is limited by 2gb not 4gb, hence 8 and not 16 as normally expected
3042  // for a 32 bit varint.
3043  if (UPB_UNLIKELY(byte >= 8)) return NULL;
3044  *size += (byte - 1) << 28;
3045  return ptr;
3046 }
3047 
3049 static bool fastdecode_boundscheck(const char *ptr, size_t len,
3050  const char *end) {
3051  uintptr_t uptr = (uintptr_t)ptr;
3052  uintptr_t uend = (uintptr_t)end + 16;
3053  uintptr_t res = uptr + len;
3054  return res < uptr || res > uend;
3055 }
3056 
3058 static bool fastdecode_boundscheck2(const char *ptr, size_t len,
3059  const char *end) {
3060  // This is one extra branch compared to the more normal:
3061  // return (size_t)(end - ptr) < size;
3062  // However it is one less computation if we are just about to use "ptr + len":
3063  // https://godbolt.org/z/35YGPz
3064  // In microbenchmarks this shows an overall 4% improvement.
3065  uintptr_t uptr = (uintptr_t)ptr;
3066  uintptr_t uend = (uintptr_t)end;
3067  uintptr_t res = uptr + len;
3068  return res < uptr || res > uend;
3069 }
3070 
3071 typedef const char *fastdecode_delimfunc(upb_decstate *d, const char *ptr,
3072  void *ctx);
3073 
3075 static const char *fastdecode_delimited(upb_decstate *d, const char *ptr,
3076  fastdecode_delimfunc *func, void *ctx) {
3077  ptr++;
3078  int len = (int8_t)ptr[-1];
3079  if (fastdecode_boundscheck2(ptr, len, d->limit_ptr)) {
3080  // Slow case: Sub-message is >=128 bytes and/or exceeds the current buffer.
3081  // If it exceeds the buffer limit, limit/limit_ptr will change during
3082  // sub-message parsing, so we need to preserve delta, not limit.
3083  if (UPB_UNLIKELY(len & 0x80)) {
3084  // Size varint >1 byte (length >= 128).
3085  ptr = fastdecode_longsize(ptr, &len);
3086  if (!ptr) {
3087  // Corrupt wire format: size exceeded INT_MAX.
3088  return NULL;
3089  }
3090  }
3091  if (ptr - d->end + (int)len > d->limit) {
3092  // Corrupt wire format: invalid limit.
3093  return NULL;
3094  }
3095  int delta = decode_pushlimit(d, ptr, len);
3096  ptr = func(d, ptr, ctx);
3097  decode_poplimit(d, ptr, delta);
3098  } else {
3099  // Fast case: Sub-message is <128 bytes and fits in the current buffer.
3100  // This means we can preserve limit/limit_ptr verbatim.
3101  const char *saved_limit_ptr = d->limit_ptr;
3102  int saved_limit = d->limit;
3103  d->limit_ptr = ptr + len;
3104  d->limit = d->limit_ptr - d->end;
3105  UPB_ASSERT(d->limit_ptr == d->end + UPB_MIN(0, d->limit));
3106  ptr = func(d, ptr, ctx);
3107  d->limit_ptr = saved_limit_ptr;
3108  d->limit = saved_limit;
3109  UPB_ASSERT(d->limit_ptr == d->end + UPB_MIN(0, d->limit));
3110  }
3111  return ptr;
3112 }
3113 
3114 /* singular, oneof, repeated field handling ***********************************/
3115 
3116 typedef struct {
3117  upb_array *arr;
3118  void *end;
3119 } fastdecode_arr;
3120 
3121 typedef enum {
3122  FD_NEXT_ATLIMIT,
3123  FD_NEXT_SAMEFIELD,
3124  FD_NEXT_OTHERFIELD
3125 } fastdecode_next;
3126 
3127 typedef struct {
3128  void *dst;
3129  fastdecode_next next;
3130  uint32_t tag;
3131 } fastdecode_nextret;
3132 
3134 static void *fastdecode_resizearr(upb_decstate *d, void *dst,
3135  fastdecode_arr *farr, int valbytes) {
3136  if (UPB_UNLIKELY(dst == farr->end)) {
3137  size_t old_size = farr->arr->size;
3138  size_t old_bytes = old_size * valbytes;
3139  size_t new_size = old_size * 2;
3140  size_t new_bytes = new_size * valbytes;
3141  char *old_ptr = _upb_array_ptr(farr->arr);
3142  char *new_ptr = upb_arena_realloc(&d->arena, old_ptr, old_bytes, new_bytes);
3143  uint8_t elem_size_lg2 = __builtin_ctz(valbytes);
3144  farr->arr->size = new_size;
3145  farr->arr->data = _upb_array_tagptr(new_ptr, elem_size_lg2);
3146  dst = (void*)(new_ptr + (old_size * valbytes));
3147  farr->end = (void*)(new_ptr + (new_size * valbytes));
3148  }
3149  return dst;
3150 }
3151 
3153 static bool fastdecode_tagmatch(uint32_t tag, uint64_t data, int tagbytes) {
3154  if (tagbytes == 1) {
3155  return (uint8_t)tag == (uint8_t)data;
3156  } else {
3157  return (uint16_t)tag == (uint16_t)data;
3158  }
3159 }
3160 
3162 static void fastdecode_commitarr(void *dst, fastdecode_arr *farr,
3163  int valbytes) {
3164  farr->arr->len =
3165  (size_t)((char *)dst - (char *)_upb_array_ptr(farr->arr)) / valbytes;
3166 }
3167 
3169 static fastdecode_nextret fastdecode_nextrepeated(upb_decstate *d, void *dst,
3170  const char **ptr,
3171  fastdecode_arr *farr,
3172  uint64_t data, int tagbytes,
3173  int valbytes) {
3174  fastdecode_nextret ret;
3175  dst = (char *)dst + valbytes;
3176 
3177  if (UPB_LIKELY(!decode_isdone(d, ptr))) {
3178  ret.tag = fastdecode_loadtag(*ptr);
3179  if (fastdecode_tagmatch(ret.tag, data, tagbytes)) {
3180  ret.next = FD_NEXT_SAMEFIELD;
3181  } else {
3182  fastdecode_commitarr(dst, farr, valbytes);
3183  ret.next = FD_NEXT_OTHERFIELD;
3184  }
3185  } else {
3186  fastdecode_commitarr(dst, farr, valbytes);
3187  ret.next = FD_NEXT_ATLIMIT;
3188  }
3189 
3190  ret.dst = dst;
3191  return ret;
3192 }
3193 
3195 static void *fastdecode_fieldmem(upb_msg *msg, uint64_t data) {
3196  size_t ofs = data >> 48;
3197  return (char *)msg + ofs;
3198 }
3199 
3201 static void *fastdecode_getfield(upb_decstate *d, const char *ptr, upb_msg *msg,
3202  uint64_t *data, uint64_t *hasbits,
3203  fastdecode_arr *farr, int valbytes,
3204  upb_card card) {
3205  switch (card) {
3206  case CARD_s: {
3207  uint8_t hasbit_index = *data >> 24;
3208  // Set hasbit and return pointer to scalar field.
3209  *hasbits |= 1ull << hasbit_index;
3210  return fastdecode_fieldmem(msg, *data);
3211  }
3212  case CARD_o: {
3213  uint16_t case_ofs = *data >> 32;
3214  uint32_t *oneof_case = UPB_PTR_AT(msg, case_ofs, uint32_t);
3215  uint8_t field_number = *data >> 24;
3216  *oneof_case = field_number;
3217  return fastdecode_fieldmem(msg, *data);
3218  }
3219  case CARD_r: {
3220  // Get pointer to upb_array and allocate/expand if necessary.
3221  uint8_t elem_size_lg2 = __builtin_ctz(valbytes);
3222  upb_array **arr_p = fastdecode_fieldmem(msg, *data);
3223  char *begin;
3224  *(uint32_t*)msg |= *hasbits;
3225  *hasbits = 0;
3226  if (UPB_LIKELY(!*arr_p)) {
3227  farr->arr = _upb_array_new(&d->arena, 8, elem_size_lg2);
3228  *arr_p = farr->arr;
3229  } else {
3230  farr->arr = *arr_p;
3231  }
3232  begin = _upb_array_ptr(farr->arr);
3233  farr->end = begin + (farr->arr->size * valbytes);
3235  return begin + (farr->arr->len * valbytes);
3236  }
3237  default:
3238  UPB_UNREACHABLE();
3239  }
3240 }
3241 
3243 static bool fastdecode_flippacked(uint64_t *data, int tagbytes) {
3244  *data ^= (0x2 ^ 0x0); // Patch data to match packed wiretype.
3245  return fastdecode_checktag(*data, tagbytes);
3246 }
3247 
3248 #define FASTDECODE_CHECKPACKED(tagbytes, card, func) \
3249  if (UPB_UNLIKELY(!fastdecode_checktag(data, tagbytes))) { \
3250  if (card == CARD_r && fastdecode_flippacked(&data, tagbytes)) { \
3251  UPB_MUSTTAIL return func(UPB_PARSE_ARGS); \
3252  } \
3253  RETURN_GENERIC("packed check tag mismatch\n"); \
3254  }
3255 
3256 /* varint fields **************************************************************/
3257 
3259 static uint64_t fastdecode_munge(uint64_t val, int valbytes, bool zigzag) {
3260  if (valbytes == 1) {
3261  return val != 0;
3262  } else if (zigzag) {
3263  if (valbytes == 4) {
3264  uint32_t n = val;
3265  return (n >> 1) ^ -(int32_t)(n & 1);
3266  } else if (valbytes == 8) {
3267  return (val >> 1) ^ -(int64_t)(val & 1);
3268  }
3269  UPB_UNREACHABLE();
3270  }
3271  return val;
3272 }
3273 
3275 static const char *fastdecode_varint64(const char *ptr, uint64_t *val) {
3276  ptr++;
3277  *val = (uint8_t)ptr[-1];
3278  if (UPB_UNLIKELY(*val & 0x80)) {
3279  int i;
3280  for (i = 0; i < 8; i++) {
3281  ptr++;
3282  uint64_t byte = (uint8_t)ptr[-1];
3283  *val += (byte - 1) << (7 + 7 * i);
3284  if (UPB_LIKELY((byte & 0x80) == 0)) goto done;
3285  }
3286  ptr++;
3287  uint64_t byte = (uint8_t)ptr[-1];
3288  if (byte > 1) {
3289  return NULL;
3290  }
3291  *val += (byte - 1) << 63;
3292  }
3293 done:
3294  UPB_ASSUME(ptr != NULL);
3295  return ptr;
3296 }
3297 
3298 #define FASTDECODE_UNPACKEDVARINT(d, ptr, msg, table, hasbits, data, tagbytes, \
3299  valbytes, card, zigzag, packed) \
3300  uint64_t val; \
3301  void *dst; \
3302  fastdecode_arr farr; \
3303  \
3304  FASTDECODE_CHECKPACKED(tagbytes, card, packed); \
3305  \
3306  dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &farr, valbytes, \
3307  card); \
3308  if (card == CARD_r) { \
3309  if (UPB_UNLIKELY(!dst)) { \
3310  RETURN_GENERIC("need array resize\n"); \
3311  } \
3312  } \
3313  \
3314  again: \
3315  if (card == CARD_r) { \
3316  dst = fastdecode_resizearr(d, dst, &farr, valbytes); \
3317  } \
3318  \
3319  ptr += tagbytes; \
3320  ptr = fastdecode_varint64(ptr, &val); \
3321  if (ptr == NULL) \
3322  return fastdecode_err(d); \
3323  val = fastdecode_munge(val, valbytes, zigzag); \
3324  memcpy(dst, &val, valbytes); \
3325  \
3326  if (card == CARD_r) { \
3327  fastdecode_nextret ret = fastdecode_nextrepeated( \
3328  d, dst, &ptr, &farr, data, tagbytes, valbytes); \
3329  switch (ret.next) { \
3330  case FD_NEXT_SAMEFIELD: \
3331  dst = ret.dst; \
3332  goto again; \
3333  case FD_NEXT_OTHERFIELD: \
3334  data = ret.tag; \
3335  UPB_MUSTTAIL return fastdecode_tagdispatch(UPB_PARSE_ARGS); \
3336  case FD_NEXT_ATLIMIT: \
3337  return ptr; \
3338  } \
3339  } \
3340  \
3341  UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS);
3342 
3343 typedef struct {
3344  uint8_t valbytes;
3345  bool zigzag;
3346  void *dst;
3347  fastdecode_arr farr;
3348 } fastdecode_varintdata;
3349 
3351 static const char *fastdecode_topackedvarint(upb_decstate *d, const char *ptr,
3352  void *ctx) {
3353  fastdecode_varintdata *data = ctx;
3354  void *dst = data->dst;
3355  uint64_t val;
3356 
3357  while (!decode_isdone(d, &ptr)) {
3358  dst = fastdecode_resizearr(d, dst, &data->farr, data->valbytes);
3359  ptr = fastdecode_varint64(ptr, &val);
3360  if (ptr == NULL) return NULL;
3361  val = fastdecode_munge(val, data->valbytes, data->zigzag);
3362  memcpy(dst, &val, data->valbytes);
3363  dst = (char *)dst + data->valbytes;
3364  }
3365 
3366  fastdecode_commitarr(dst, &data->farr, data->valbytes);
3367  return ptr;
3368 }
3369 
3370 #define FASTDECODE_PACKEDVARINT(d, ptr, msg, table, hasbits, data, tagbytes, \
3371  valbytes, zigzag, unpacked) \
3372  fastdecode_varintdata ctx = {valbytes, zigzag}; \
3373  \
3374  FASTDECODE_CHECKPACKED(tagbytes, CARD_r, unpacked); \
3375  \
3376  ctx.dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &ctx.farr, \
3377  valbytes, CARD_r); \
3378  if (UPB_UNLIKELY(!ctx.dst)) { \
3379  RETURN_GENERIC("need array resize\n"); \
3380  } \
3381  \
3382  ptr += tagbytes; \
3383  ptr = fastdecode_delimited(d, ptr, &fastdecode_topackedvarint, &ctx); \
3384  \
3385  if (UPB_UNLIKELY(ptr == NULL)) { \
3386  return fastdecode_err(d); \
3387  } \
3388  \
3389  UPB_MUSTTAIL return fastdecode_dispatch(d, ptr, msg, table, hasbits, 0);
3390 
3391 #define FASTDECODE_VARINT(d, ptr, msg, table, hasbits, data, tagbytes, \
3392  valbytes, card, zigzag, unpacked, packed) \
3393  if (card == CARD_p) { \
3394  FASTDECODE_PACKEDVARINT(d, ptr, msg, table, hasbits, data, tagbytes, \
3395  valbytes, zigzag, unpacked); \
3396  } else { \
3397  FASTDECODE_UNPACKEDVARINT(d, ptr, msg, table, hasbits, data, tagbytes, \
3398  valbytes, card, zigzag, packed); \
3399  }
3400 
3401 #define z_ZZ true
3402 #define b_ZZ false
3403 #define v_ZZ false
3404 
3405 /* Generate all combinations:
3406  * {s,o,r,p} x {b1,v4,z4,v8,z8} x {1bt,2bt} */
3407 
3408 #define F(card, type, valbytes, tagbytes) \
3409  UPB_NOINLINE \
3410  const char *upb_p##card##type##valbytes##_##tagbytes##bt(UPB_PARSE_PARAMS) { \
3411  FASTDECODE_VARINT(d, ptr, msg, table, hasbits, data, tagbytes, valbytes, \
3412  CARD_##card, type##_ZZ, \
3413  upb_pr##type##valbytes##_##tagbytes##bt, \
3414  upb_pp##type##valbytes##_##tagbytes##bt); \
3415  }
3416 
3417 #define TYPES(card, tagbytes) \
3418  F(card, b, 1, tagbytes) \
3419  F(card, v, 4, tagbytes) \
3420  F(card, v, 8, tagbytes) \
3421  F(card, z, 4, tagbytes) \
3422  F(card, z, 8, tagbytes)
3423 
3424 #define TAGBYTES(card) \
3425  TYPES(card, 1) \
3426  TYPES(card, 2)
3427 
3428 TAGBYTES(s)
3429 TAGBYTES(o)
3430 TAGBYTES(r)
3431 TAGBYTES(p)
3432 
3433 #undef z_ZZ
3434 #undef b_ZZ
3435 #undef v_ZZ
3436 #undef o_ONEOF
3437 #undef s_ONEOF
3438 #undef r_ONEOF
3439 #undef F
3440 #undef TYPES
3441 #undef TAGBYTES
3442 #undef FASTDECODE_UNPACKEDVARINT
3443 #undef FASTDECODE_PACKEDVARINT
3444 #undef FASTDECODE_VARINT
3445 
3446 
3447 /* fixed fields ***************************************************************/
3448 
3449 #define FASTDECODE_UNPACKEDFIXED(d, ptr, msg, table, hasbits, data, tagbytes, \
3450  valbytes, card, packed) \
3451  void *dst; \
3452  fastdecode_arr farr; \
3453  \
3454  FASTDECODE_CHECKPACKED(tagbytes, card, packed) \
3455  \
3456  dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &farr, valbytes, \
3457  card); \
3458  if (card == CARD_r) { \
3459  if (UPB_UNLIKELY(!dst)) { \
3460  RETURN_GENERIC("couldn't allocate array in arena\n"); \
3461  } \
3462  } \
3463  \
3464  again: \
3465  if (card == CARD_r) { \
3466  dst = fastdecode_resizearr(d, dst, &farr, valbytes); \
3467  } \
3468  \
3469  ptr += tagbytes; \
3470  memcpy(dst, ptr, valbytes); \
3471  ptr += valbytes; \
3472  \
3473  if (card == CARD_r) { \
3474  fastdecode_nextret ret = fastdecode_nextrepeated( \
3475  d, dst, &ptr, &farr, data, tagbytes, valbytes); \
3476  switch (ret.next) { \
3477  case FD_NEXT_SAMEFIELD: \
3478  dst = ret.dst; \
3479  goto again; \
3480  case FD_NEXT_OTHERFIELD: \
3481  data = ret.tag; \
3482  UPB_MUSTTAIL return fastdecode_tagdispatch(UPB_PARSE_ARGS); \
3483  case FD_NEXT_ATLIMIT: \
3484  return ptr; \
3485  } \
3486  } \
3487  \
3488  UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS);
3489 
3490 #define FASTDECODE_PACKEDFIXED(d, ptr, msg, table, hasbits, data, tagbytes, \
3491  valbytes, unpacked) \
3492  FASTDECODE_CHECKPACKED(tagbytes, CARD_r, unpacked) \
3493  \
3494  ptr += tagbytes; \
3495  int size = (uint8_t)ptr[0]; \
3496  ptr++; \
3497  if (size & 0x80) { \
3498  ptr = fastdecode_longsize(ptr, &size); \
3499  } \
3500  \
3501  if (UPB_UNLIKELY(fastdecode_boundscheck(ptr, size, d->limit_ptr) || \
3502  (size % valbytes) != 0)) { \
3503  return fastdecode_err(d); \
3504  } \
3505  \
3506  upb_array **arr_p = fastdecode_fieldmem(msg, data); \
3507  upb_array *arr = *arr_p; \
3508  uint8_t elem_size_lg2 = __builtin_ctz(valbytes); \
3509  int elems = size / valbytes; \
3510  \
3511  if (UPB_LIKELY(!arr)) { \
3512  *arr_p = arr = _upb_array_new(&d->arena, elems, elem_size_lg2); \
3513  if (!arr) { \
3514  return fastdecode_err(d); \
3515  } \
3516  } else { \
3517  _upb_array_resize(arr, elems, &d->arena); \
3518  } \
3519  \
3520  char *dst = _upb_array_ptr(arr); \
3521  memcpy(dst, ptr, size); \
3522  arr->len = elems; \
3523  \
3524  ptr += size; \
3525  UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS);
3526 
3527 #define FASTDECODE_FIXED(d, ptr, msg, table, hasbits, data, tagbytes, \
3528  valbytes, card, unpacked, packed) \
3529  if (card == CARD_p) { \
3530  FASTDECODE_PACKEDFIXED(d, ptr, msg, table, hasbits, data, tagbytes, \
3531  valbytes, unpacked); \
3532  } else { \
3533  FASTDECODE_UNPACKEDFIXED(d, ptr, msg, table, hasbits, data, tagbytes, \
3534  valbytes, card, packed); \
3535  }
3536 
3537 /* Generate all combinations:
3538  * {s,o,r,p} x {f4,f8} x {1bt,2bt} */
3539 
3540 #define F(card, valbytes, tagbytes) \
3541  UPB_NOINLINE \
3542  const char *upb_p##card##f##valbytes##_##tagbytes##bt(UPB_PARSE_PARAMS) { \
3543  FASTDECODE_FIXED(d, ptr, msg, table, hasbits, data, tagbytes, valbytes, \
3544  CARD_##card, upb_ppf##valbytes##_##tagbytes##bt, \
3545  upb_prf##valbytes##_##tagbytes##bt); \
3546  }
3547 
3548 #define TYPES(card, tagbytes) \
3549  F(card, 4, tagbytes) \
3550  F(card, 8, tagbytes)
3551 
3552 #define TAGBYTES(card) \
3553  TYPES(card, 1) \
3554  TYPES(card, 2)
3555 
3556 TAGBYTES(s)
3557 TAGBYTES(o)
3558 TAGBYTES(r)
3559 TAGBYTES(p)
3560 
3561 #undef F
3562 #undef TYPES
3563 #undef TAGBYTES
3564 #undef FASTDECODE_UNPACKEDFIXED
3565 #undef FASTDECODE_PACKEDFIXED
3566 
3567 /* string fields **************************************************************/
3568 
3569 typedef const char *fastdecode_copystr_func(struct upb_decstate *d,
3570  const char *ptr, upb_msg *msg,
3571  const upb_msglayout *table,
3572  uint64_t hasbits, upb_strview *dst);
3573 
3575 static const char *fastdecode_verifyutf8(upb_decstate *d, const char *ptr,
3577  uint64_t hasbits, uint64_t data) {
3579  if (!decode_verifyutf8_inl(dst->data, dst->size)) {
3580  return fastdecode_err(d);
3581  }
3582  UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS);
3583 }
3584 
3585 #define FASTDECODE_LONGSTRING(d, ptr, msg, table, hasbits, dst, validate_utf8) \
3586  int size = (uint8_t)ptr[0]; /* Could plumb through hasbits. */ \
3587  ptr++; \
3588  if (size & 0x80) { \
3589  ptr = fastdecode_longsize(ptr, &size); \
3590  } \
3591  \
3592  if (UPB_UNLIKELY(fastdecode_boundscheck(ptr, size, d->limit_ptr))) { \
3593  dst->size = 0; \
3594  return fastdecode_err(d); \
3595  } \
3596  \
3597  if (d->alias) { \
3598  dst->data = ptr; \
3599  dst->size = size; \
3600  } else { \
3601  char *data = upb_arena_malloc(&d->arena, size); \
3602  if (!data) { \
3603  return fastdecode_err(d); \
3604  } \
3605  memcpy(data, ptr, size); \
3606  dst->data = data; \
3607  dst->size = size; \
3608  } \
3609  \
3610  ptr += size; \
3611  if (validate_utf8) { \
3612  data = (uint64_t)dst; \
3613  UPB_MUSTTAIL return fastdecode_verifyutf8(UPB_PARSE_ARGS); \
3614  } else { \
3615  UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS); \
3616  }
3617 
3619 static const char *fastdecode_longstring_utf8(struct upb_decstate *d,
3620  const char *ptr, upb_msg *msg,
3621  intptr_t table, uint64_t hasbits,
3622  uint64_t data) {
3624  FASTDECODE_LONGSTRING(d, ptr, msg, table, hasbits, dst, true);
3625 }
3626 
3628 static const char *fastdecode_longstring_noutf8(struct upb_decstate *d,
3629  const char *ptr, upb_msg *msg,
3630  intptr_t table,
3631  uint64_t hasbits,
3632  uint64_t data) {
3634  FASTDECODE_LONGSTRING(d, ptr, msg, table, hasbits, dst, false);
3635 }
3636 
3638 static void fastdecode_docopy(upb_decstate *d, const char *ptr, uint32_t size,
3639  int copy, char *data, upb_strview *dst) {
3640  d->arena.head.ptr += copy;
3641  dst->data = data;
3643  memcpy(data, ptr, copy);
3645 }
3646 
3647 #define FASTDECODE_COPYSTRING(d, ptr, msg, table, hasbits, data, tagbytes, \
3648  card, validate_utf8) \
3649  upb_strview *dst; \
3650  fastdecode_arr farr; \
3651  int64_t size; \
3652  size_t arena_has; \
3653  size_t common_has; \
3654  char *buf; \
3655  \
3656  UPB_ASSERT(!d->alias); \
3657  UPB_ASSERT(fastdecode_checktag(data, tagbytes)); \
3658  \
3659  dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &farr, \
3660  sizeof(upb_strview), card); \
3661  \
3662  again: \
3663  if (card == CARD_r) { \
3664  dst = fastdecode_resizearr(d, dst, &farr, sizeof(upb_strview)); \
3665  } \
3666  \
3667  size = (uint8_t)ptr[tagbytes]; \
3668  ptr += tagbytes + 1; \
3669  dst->size = size; \
3670  \
3671  buf = d->arena.head.ptr; \
3672  arena_has = _upb_arenahas(&d->arena); \
3673  common_has = UPB_MIN(arena_has, (d->end - ptr) + 16); \
3674  \
3675  if (UPB_LIKELY(size <= 15 - tagbytes)) { \
3676  if (arena_has < 16) \
3677  goto longstr; \
3678  d->arena.head.ptr += 16; \
3679  memcpy(buf, ptr - tagbytes - 1, 16); \
3680  dst->data = buf + tagbytes + 1; \
3681  } else if (UPB_LIKELY(size <= 32)) { \
3682  if (UPB_UNLIKELY(common_has < 32)) \
3683  goto longstr; \
3684  fastdecode_docopy(d, ptr, size, 32, buf, dst); \
3685  } else if (UPB_LIKELY(size <= 64)) { \
3686  if (UPB_UNLIKELY(common_has < 64)) \
3687  goto longstr; \
3688  fastdecode_docopy(d, ptr, size, 64, buf, dst); \
3689  } else if (UPB_LIKELY(size < 128)) { \
3690  if (UPB_UNLIKELY(common_has < 128)) \
3691  goto longstr; \
3692  fastdecode_docopy(d, ptr, size, 128, buf, dst); \
3693  } else { \
3694  goto longstr; \
3695  } \
3696  \
3697  ptr += size; \
3698  \
3699  if (card == CARD_r) { \
3700  if (validate_utf8 && !decode_verifyutf8_inl(dst->data, dst->size)) { \
3701  return fastdecode_err(d); \
3702  } \
3703  fastdecode_nextret ret = fastdecode_nextrepeated( \
3704  d, dst, &ptr, &farr, data, tagbytes, sizeof(upb_strview)); \
3705  switch (ret.next) { \
3706  case FD_NEXT_SAMEFIELD: \
3707  dst = ret.dst; \
3708  goto again; \
3709  case FD_NEXT_OTHERFIELD: \
3710  data = ret.tag; \
3711  UPB_MUSTTAIL return fastdecode_tagdispatch(UPB_PARSE_ARGS); \
3712  case FD_NEXT_ATLIMIT: \
3713  return ptr; \
3714  } \
3715  } \
3716  \
3717  if (card != CARD_r && validate_utf8) { \
3718  data = (uint64_t)dst; \
3719  UPB_MUSTTAIL return fastdecode_verifyutf8(UPB_PARSE_ARGS); \
3720  } \
3721  \
3722  UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS); \
3723  \
3724  longstr: \
3725  ptr--; \
3726  if (validate_utf8) { \
3727  UPB_MUSTTAIL return fastdecode_longstring_utf8(d, ptr, msg, table, \
3728  hasbits, (uint64_t)dst); \
3729  } else { \
3730  UPB_MUSTTAIL return fastdecode_longstring_noutf8(d, ptr, msg, table, \
3731  hasbits, (uint64_t)dst); \
3732  }
3733 
3734 #define FASTDECODE_STRING(d, ptr, msg, table, hasbits, data, tagbytes, card, \
3735  copyfunc, validate_utf8) \
3736  upb_strview *dst; \
3737  fastdecode_arr farr; \
3738  int64_t size; \
3739  \
3740  if (UPB_UNLIKELY(!fastdecode_checktag(data, tagbytes))) { \
3741  RETURN_GENERIC("string field tag mismatch\n"); \
3742  } \
3743  \
3744  if (UPB_UNLIKELY(!d->alias)) { \
3745  UPB_MUSTTAIL return copyfunc(UPB_PARSE_ARGS); \
3746  } \
3747  \
3748  dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &farr, \
3749  sizeof(upb_strview), card); \
3750  \
3751  again: \
3752  if (card == CARD_r) { \
3753  dst = fastdecode_resizearr(d, dst, &farr, sizeof(upb_strview)); \
3754  } \
3755  \
3756  size = (int8_t)ptr[tagbytes]; \
3757  ptr += tagbytes + 1; \
3758  dst->data = ptr; \
3759  dst->size = size; \
3760  \
3761  if (UPB_UNLIKELY(fastdecode_boundscheck(ptr, size, d->end))) { \
3762  ptr--; \
3763  if (validate_utf8) { \
3764  return fastdecode_longstring_utf8(d, ptr, msg, table, hasbits, \
3765  (uint64_t)dst); \
3766  } else { \
3767  return fastdecode_longstring_noutf8(d, ptr, msg, table, hasbits, \
3768  (uint64_t)dst); \
3769  } \
3770  } \
3771  \
3772  ptr += size; \
3773  \
3774  if (card == CARD_r) { \
3775  if (validate_utf8 && !decode_verifyutf8_inl(dst->data, dst->size)) { \
3776  return fastdecode_err(d); \
3777  } \
3778  fastdecode_nextret ret = fastdecode_nextrepeated( \
3779  d, dst, &ptr, &farr, data, tagbytes, sizeof(upb_strview)); \
3780  switch (ret.next) { \
3781  case FD_NEXT_SAMEFIELD: \
3782  dst = ret.dst; \
3783  if (UPB_UNLIKELY(!d->alias)) { \
3784  /* Buffer flipped and we can't alias any more. Bounce to */ \
3785  /* copyfunc(), but via dispatch since we need to reload table */ \
3786  /* data also. */ \
3787  fastdecode_commitarr(dst, &farr, sizeof(upb_strview)); \
3788  data = ret.tag; \
3789  UPB_MUSTTAIL return fastdecode_tagdispatch(UPB_PARSE_ARGS); \
3790  } \
3791  goto again; \
3792  case FD_NEXT_OTHERFIELD: \
3793  data = ret.tag; \
3794  UPB_MUSTTAIL return fastdecode_tagdispatch(UPB_PARSE_ARGS); \
3795  case FD_NEXT_ATLIMIT: \
3796  return ptr; \
3797  } \
3798  } \
3799  \
3800  if (card != CARD_r && validate_utf8) { \
3801  data = (uint64_t)dst; \
3802  UPB_MUSTTAIL return fastdecode_verifyutf8(UPB_PARSE_ARGS); \
3803  } \
3804  \
3805  UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS);
3806 
3807 /* Generate all combinations:
3808  * {p,c} x {s,o,r} x {s, b} x {1bt,2bt} */
3809 
3810 #define s_VALIDATE true
3811 #define b_VALIDATE false
3812 
3813 #define F(card, tagbytes, type) \
3814  UPB_NOINLINE \
3815  const char *upb_c##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS) { \
3816  FASTDECODE_COPYSTRING(d, ptr, msg, table, hasbits, data, tagbytes, \
3817  CARD_##card, type##_VALIDATE); \
3818  } \
3819  const char *upb_p##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS) { \
3820  FASTDECODE_STRING(d, ptr, msg, table, hasbits, data, tagbytes, \
3821  CARD_##card, upb_c##card##type##_##tagbytes##bt, \
3822  type##_VALIDATE); \
3823  }
3824 
3825 #define UTF8(card, tagbytes) \
3826  F(card, tagbytes, s) \
3827  F(card, tagbytes, b)
3828 
3829 #define TAGBYTES(card) \
3830  UTF8(card, 1) \
3831  UTF8(card, 2)
3832 
3833 TAGBYTES(s)
3834 TAGBYTES(o)
3835 TAGBYTES(r)
3836 
3837 #undef s_VALIDATE
3838 #undef b_VALIDATE
3839 #undef F
3840 #undef TAGBYTES
3841 #undef FASTDECODE_LONGSTRING
3842 #undef FASTDECODE_COPYSTRING
3843 #undef FASTDECODE_STRING
3844 
3845 /* message fields *************************************************************/
3846 
3847 UPB_INLINE
3848 upb_msg *decode_newmsg_ceil(upb_decstate *d, const upb_msglayout *l,
3849  int msg_ceil_bytes) {
3850  size_t size = l->size + sizeof(upb_msg_internal);
3851  char *msg_data;
3852  if (UPB_LIKELY(msg_ceil_bytes > 0 &&
3853  _upb_arenahas(&d->arena) >= msg_ceil_bytes)) {
3854  UPB_ASSERT(size <= (size_t)msg_ceil_bytes);
3855  msg_data = d->arena.head.ptr;
3856  d->arena.head.ptr += size;
3857  UPB_UNPOISON_MEMORY_REGION(msg_data, msg_ceil_bytes);
3858  memset(msg_data, 0, msg_ceil_bytes);
3859  UPB_POISON_MEMORY_REGION(msg_data + size, msg_ceil_bytes - size);
3860  } else {
3861  msg_data = (char*)upb_arena_malloc(&d->arena, size);
3862  memset(msg_data, 0, size);
3863  }
3864  return msg_data + sizeof(upb_msg_internal);
3865 }
3866 
3867 typedef struct {
3868  intptr_t table;
3869  upb_msg *msg;
3870 } fastdecode_submsgdata;
3871 
3873 static const char *fastdecode_tosubmsg(upb_decstate *d, const char *ptr,
3874  void *ctx) {
3875  fastdecode_submsgdata *submsg = ctx;
3876  ptr = fastdecode_dispatch(d, ptr, submsg->msg, submsg->table, 0, 0);
3877  UPB_ASSUME(ptr != NULL);
3878  return ptr;
3879 }
3880 
3881 #define FASTDECODE_SUBMSG(d, ptr, msg, table, hasbits, data, tagbytes, \
3882  msg_ceil_bytes, card) \
3883  \
3884  if (UPB_UNLIKELY(!fastdecode_checktag(data, tagbytes))) { \
3885  RETURN_GENERIC("submessage field tag mismatch\n"); \
3886  } \
3887  \
3888  if (--d->depth == 0) return fastdecode_err(d); \
3889  \
3890  upb_msg **dst; \
3891  uint32_t submsg_idx = (data >> 16) & 0xff; \
3892  const upb_msglayout *tablep = decode_totablep(table); \
3893  const upb_msglayout *subtablep = tablep->submsgs[submsg_idx]; \
3894  fastdecode_submsgdata submsg = {decode_totable(subtablep)}; \
3895  fastdecode_arr farr; \
3896  \
3897  if (subtablep->table_mask == (uint8_t)-1) { \
3898  RETURN_GENERIC("submessage doesn't have fast tables."); \
3899  } \
3900  \
3901  dst = fastdecode_getfield(d, ptr, msg, &data, &hasbits, &farr, \
3902  sizeof(upb_msg *), card); \
3903  \
3904  if (card == CARD_s) { \
3905  *(uint32_t *)msg |= hasbits; \
3906  hasbits = 0; \
3907  } \
3908  \
3909  again: \
3910  if (card == CARD_r) { \
3911  dst = fastdecode_resizearr(d, dst, &farr, sizeof(upb_msg *)); \
3912  } \
3913  \
3914  submsg.msg = *dst; \
3915  \
3916  if (card == CARD_r || UPB_LIKELY(!submsg.msg)) { \
3917  *dst = submsg.msg = decode_newmsg_ceil(d, subtablep, msg_ceil_bytes); \
3918  } \
3919  \
3920  ptr += tagbytes; \
3921  ptr = fastdecode_delimited(d, ptr, fastdecode_tosubmsg, &submsg); \
3922  \
3923  if (UPB_UNLIKELY(ptr == NULL || d->end_group != DECODE_NOGROUP)) { \
3924  return fastdecode_err(d); \
3925  } \
3926  \
3927  if (card == CARD_r) { \
3928  fastdecode_nextret ret = fastdecode_nextrepeated( \
3929  d, dst, &ptr, &farr, data, tagbytes, sizeof(upb_msg *)); \
3930  switch (ret.next) { \
3931  case FD_NEXT_SAMEFIELD: \
3932  dst = ret.dst; \
3933  goto again; \
3934  case FD_NEXT_OTHERFIELD: \
3935  d->depth++; \
3936  data = ret.tag; \
3937  UPB_MUSTTAIL return fastdecode_tagdispatch(UPB_PARSE_ARGS); \
3938  case FD_NEXT_ATLIMIT: \
3939  d->depth++; \
3940  return ptr; \
3941  } \
3942  } \
3943  \
3944  d->depth++; \
3945  UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS);
3946 
3947 #define F(card, tagbytes, size_ceil, ceil_arg) \
3948  const char *upb_p##card##m_##tagbytes##bt_max##size_ceil##b( \
3949  UPB_PARSE_PARAMS) { \
3950  FASTDECODE_SUBMSG(d, ptr, msg, table, hasbits, data, tagbytes, ceil_arg, \
3951  CARD_##card); \
3952  }
3953 
3954 #define SIZES(card, tagbytes) \
3955  F(card, tagbytes, 64, 64) \
3956  F(card, tagbytes, 128, 128) \
3957  F(card, tagbytes, 192, 192) \
3958  F(card, tagbytes, 256, 256) \
3959  F(card, tagbytes, max, -1)
3960 
3961 #define TAGBYTES(card) \
3962  SIZES(card, 1) \
3963  SIZES(card, 2)
3964 
3965 TAGBYTES(s)
3966 TAGBYTES(o)
3967 TAGBYTES(r)
3968 
3969 #undef TAGBYTES
3970 #undef SIZES
3971 #undef F
3972 #undef FASTDECODE_SUBMSG
3973 
3974 #endif /* UPB_FASTTABLE */
3975 /* This file was generated by upbc (the upb compiler) from the input
3977  * file:
3978  *
3979  * google/protobuf/descriptor.proto
3980  *
3981  * Do not edit -- your changes will be discarded when the file is
3982  * regenerated. */
3983 
3984 #include <stddef.h>
3985 
3986 
3989 };
3990 
3992  {1, UPB_SIZE(0, 0), 0, 0, 11, _UPB_MODE_ARRAY},
3993 };
3994 
3998  UPB_SIZE(8, 8), 1, false, 1, 255,
3999 };
4000 
4008 };
4009 
4011  {1, UPB_SIZE(4, 8), 1, 0, 12, _UPB_MODE_SCALAR},
4012  {2, UPB_SIZE(12, 24), 2, 0, 12, _UPB_MODE_SCALAR},
4013  {3, UPB_SIZE(36, 72), 0, 0, 12, _UPB_MODE_ARRAY},
4014  {4, UPB_SIZE(40, 80), 0, 0, 11, _UPB_MODE_ARRAY},
4015  {5, UPB_SIZE(44, 88), 0, 1, 11, _UPB_MODE_ARRAY},
4016  {6, UPB_SIZE(48, 96), 0, 4, 11, _UPB_MODE_ARRAY},
4017  {7, UPB_SIZE(52, 104), 0, 2, 11, _UPB_MODE_ARRAY},
4018  {8, UPB_SIZE(28, 56), 3, 3, 11, _UPB_MODE_SCALAR},
4019  {9, UPB_SIZE(32, 64), 4, 5, 11, _UPB_MODE_SCALAR},
4020  {10, UPB_SIZE(56, 112), 0, 0, 5, _UPB_MODE_ARRAY},
4021  {11, UPB_SIZE(60, 120), 0, 0, 5, _UPB_MODE_ARRAY},
4022  {12, UPB_SIZE(20, 40), 5, 0, 12, _UPB_MODE_SCALAR},
4023 };
4024 
4028  UPB_SIZE(64, 128), 12, false, 12, 255,
4029 };
4030 
4039 };
4040 
4042  {1, UPB_SIZE(4, 8), 1, 0, 12, _UPB_MODE_SCALAR},
4043  {2, UPB_SIZE(16, 32), 0, 4, 11, _UPB_MODE_ARRAY},
4044  {3, UPB_SIZE(20, 40), 0, 0, 11, _UPB_MODE_ARRAY},
4045  {4, UPB_SIZE(24, 48), 0, 3, 11, _UPB_MODE_ARRAY},
4046  {5, UPB_SIZE(28, 56), 0, 1, 11, _UPB_MODE_ARRAY},
4047  {6, UPB_SIZE(32, 64), 0, 4, 11, _UPB_MODE_ARRAY},
4048  {7, UPB_SIZE(12, 24), 2, 5, 11, _UPB_MODE_SCALAR},
4049  {8, UPB_SIZE(36, 72), 0, 6, 11, _UPB_MODE_ARRAY},
4050  {9, UPB_SIZE(40, 80), 0, 2, 11, _UPB_MODE_ARRAY},
4051  {10, UPB_SIZE(44, 88), 0, 0, 12, _UPB_MODE_ARRAY},
4052 };
4053 
4057  UPB_SIZE(48, 96), 10, false, 10, 255,
4058 };
4059 
4062 };
4063 
4065  {1, UPB_SIZE(4, 4), 1, 0, 5, _UPB_MODE_SCALAR},
4066  {2, UPB_SIZE(8, 8), 2, 0, 5, _UPB_MODE_SCALAR},
4067  {3, UPB_SIZE(12, 16), 3, 0, 11, _UPB_MODE_SCALAR},
4068 };
4069 
4073  UPB_SIZE(16, 24), 3, false, 3, 255,
4074 };
4075 
4077  {1, UPB_SIZE(4, 4), 1, 0, 5, _UPB_MODE_SCALAR},
4078  {2, UPB_SIZE(8, 8), 2, 0, 5, _UPB_MODE_SCALAR},
4079 };
4080 
4082  NULL,
4084  UPB_SIZE(16, 16), 2, false, 2, 255,
4085 };
4086 
4089 };
4090 
4092  {999, UPB_SIZE(0, 0), 0, 0, 11, _UPB_MODE_ARRAY},
4093 };
4094 
4098  UPB_SIZE(8, 8), 1, false, 0, 255,
4099 };
4100 
4103 };
4104 
4106  {1, UPB_SIZE(24, 24), 1, 0, 12, _UPB_MODE_SCALAR},
4107  {2, UPB_SIZE(32, 40), 2, 0, 12, _UPB_MODE_SCALAR},
4108  {3, UPB_SIZE(12, 12), 3, 0, 5, _UPB_MODE_SCALAR},
4109  {4, UPB_SIZE(4, 4), 4, 0, 14, _UPB_MODE_SCALAR},
4110  {5, UPB_SIZE(8, 8), 5, 0, 14, _UPB_MODE_SCALAR},
4111  {6, UPB_SIZE(40, 56), 6, 0, 12, _UPB_MODE_SCALAR},
4112  {7, UPB_SIZE(48, 72), 7, 0, 12, _UPB_MODE_SCALAR},
4113  {8, UPB_SIZE(64, 104), 8, 0, 11, _UPB_MODE_SCALAR},
4114  {9, UPB_SIZE(16, 16), 9, 0, 5, _UPB_MODE_SCALAR},
4115  {10, UPB_SIZE(56, 88), 10, 0, 12, _UPB_MODE_SCALAR},
4116  {17, UPB_SIZE(20, 20), 11, 0, 8, _UPB_MODE_SCALAR},
4117 };
4118 
4122  UPB_SIZE(72, 112), 11, false, 10, 255,
4123 };
4124 
4127 };
4128 
4130  {1, UPB_SIZE(4, 8), 1, 0, 12, _UPB_MODE_SCALAR},
4131  {2, UPB_SIZE(12, 24), 2, 0, 11, _UPB_MODE_SCALAR},
4132 };
4133 
4137  UPB_SIZE(16, 32), 2, false, 2, 255,
4138 };
4139 
4144 };
4145 
4147  {1, UPB_SIZE(4, 8), 1, 0, 12, _UPB_MODE_SCALAR},
4148  {2, UPB_SIZE(16, 32), 0, 2, 11, _UPB_MODE_ARRAY},
4149  {3, UPB_SIZE(12, 24), 2, 1, 11, _UPB_MODE_SCALAR},
4150  {4, UPB_SIZE(20, 40), 0, 0, 11, _UPB_MODE_ARRAY},
4151  {5, UPB_SIZE(24, 48), 0, 0, 12, _UPB_MODE_ARRAY},
4152 };
4153 
4157  UPB_SIZE(32, 64), 5, false, 5, 255,
4158 };
4159 
4161  {1, UPB_SIZE(4, 4), 1, 0, 5, _UPB_MODE_SCALAR},
4162  {2, UPB_SIZE(8, 8), 2, 0, 5, _UPB_MODE_SCALAR},
4163 };
4164 
4166  NULL,
4168  UPB_SIZE(16, 16), 2, false, 2, 255,
4169 };
4170 
4173 };
4174 
4176  {1, UPB_SIZE(8, 8), 1, 0, 12, _UPB_MODE_SCALAR},
4177  {2, UPB_SIZE(4, 4), 2, 0, 5, _UPB_MODE_SCALAR},
4178  {3, UPB_SIZE(16, 24), 3, 0, 11, _UPB_MODE_SCALAR},
4179 };
4180 
4184  UPB_SIZE(24, 32), 3, false, 3, 255,
4185 };
4186 
4190 };
4191 
4193  {1, UPB_SIZE(4, 8), 1, 0, 12, _UPB_MODE_SCALAR},
4194  {2, UPB_SIZE(16, 32), 0, 0, 11, _UPB_MODE_ARRAY},
4195  {3, UPB_SIZE(12, 24), 2, 1, 11, _UPB_MODE_SCALAR},
4196 };
4197 
4201  UPB_SIZE(24, 48), 3, false, 3, 255,
4202 };
4203 
4206 };
4207 
4209  {1, UPB_SIZE(4, 8), 1, 0, 12, _UPB_MODE_SCALAR},
4210  {2, UPB_SIZE(12, 24), 2, 0, 12, _UPB_MODE_SCALAR},
4211  {3, UPB_SIZE(20, 40), 3, 0, 12, _UPB_MODE_SCALAR},
4212  {4, UPB_SIZE(28, 56), 4, 0, 11, _UPB_MODE_SCALAR},
4213  {5, UPB_SIZE(1, 1), 5, 0, 8, _UPB_MODE_SCALAR},
4214  {6, UPB_SIZE(2, 2), 6, 0, 8, _UPB_MODE_SCALAR},
4215 };
4216 
4220  UPB_SIZE(32, 64), 6, false, 6, 255,
4221 };
4222 
4225 };
4226 
4228  {1, UPB_SIZE(20, 24), 1, 0, 12, _UPB_MODE_SCALAR},
4229  {8, UPB_SIZE(28, 40), 2, 0, 12, _UPB_MODE_SCALAR},
4230  {9, UPB_SIZE(4, 4), 3, 0, 14, _UPB_MODE_SCALAR},
4231  {10, UPB_SIZE(8, 8), 4, 0, 8, _UPB_MODE_SCALAR},
4232  {11, UPB_SIZE(36, 56), 5, 0, 12, _UPB_MODE_SCALAR},
4233  {16, UPB_SIZE(9, 9), 6, 0, 8, _UPB_MODE_SCALAR},
4234  {17, UPB_SIZE(10, 10), 7, 0, 8, _UPB_MODE_SCALAR},
4235  {18, UPB_SIZE(11, 11), 8, 0, 8, _UPB_MODE_SCALAR},
4236  {20, UPB_SIZE(12, 12), 9, 0, 8, _UPB_MODE_SCALAR},
4237  {23, UPB_SIZE(13, 13), 10, 0, 8, _UPB_MODE_SCALAR},
4238  {27, UPB_SIZE(14, 14), 11, 0, 8, _UPB_MODE_SCALAR},
4239  {31, UPB_SIZE(15, 15), 12, 0, 8, _UPB_MODE_SCALAR},
4240  {36, UPB_SIZE(44, 72), 13, 0, 12, _UPB_MODE_SCALAR},
4241  {37, UPB_SIZE(52, 88), 14, 0, 12, _UPB_MODE_SCALAR},
4242  {39, UPB_SIZE(60, 104), 15, 0, 12, _UPB_MODE_SCALAR},
4243  {40, UPB_SIZE(68, 120), 16, 0, 12, _UPB_MODE_SCALAR},
4244  {41, UPB_SIZE(76, 136), 17, 0, 12, _UPB_MODE_SCALAR},
4245  {42, UPB_SIZE(16, 16), 18, 0, 8, _UPB_MODE_SCALAR},
4246  {44, UPB_SIZE(84, 152), 19, 0, 12, _UPB_MODE_SCALAR},
4247  {45, UPB_SIZE(92, 168), 20, 0, 12, _UPB_MODE_SCALAR},
4248  {999, UPB_SIZE(100, 184), 0, 0, 11, _UPB_MODE_ARRAY},
4249 };
4250 
4254  UPB_SIZE(104, 192), 21, false, 1, 255,
4255 };
4256 
4259 };
4260 
4262  {1, UPB_SIZE(1, 1), 1, 0, 8, _UPB_MODE_SCALAR},
4263  {2, UPB_SIZE(2, 2), 2, 0, 8, _UPB_MODE_SCALAR},
4264  {3, UPB_SIZE(3, 3), 3, 0, 8, _UPB_MODE_SCALAR},
4265  {7, UPB_SIZE(4, 4), 4, 0, 8, _UPB_MODE_SCALAR},
4266  {999, UPB_SIZE(8, 8), 0, 0, 11, _UPB_MODE_ARRAY},
4267 };
4268 
4272  UPB_SIZE(16, 16), 5, false, 3, 255,
4273 };
4274 
4277 };
4278 
4280  {1, UPB_SIZE(4, 4), 1, 0, 14, _UPB_MODE_SCALAR},
4281  {2, UPB_SIZE(12, 12), 2, 0, 8, _UPB_MODE_SCALAR},
4282  {3, UPB_SIZE(13, 13), 3, 0, 8, _UPB_MODE_SCALAR},
4283  {5, UPB_SIZE(14, 14), 4, 0, 8, _UPB_MODE_SCALAR},
4284  {6, UPB_SIZE(8, 8), 5, 0, 14, _UPB_MODE_SCALAR},
4285  {10, UPB_SIZE(15, 15), 6, 0, 8, _UPB_MODE_SCALAR},
4286  {999, UPB_SIZE(16, 16), 0, 0, 11, _UPB_MODE_ARRAY},
4287 };
4288 
4292  UPB_SIZE(24, 24), 7, false, 3, 255,
4293 };
4294 
4297 };
4298 
4300  {999, UPB_SIZE(0, 0), 0, 0, 11, _UPB_MODE_ARRAY},
4301 };
4302 
4306  UPB_SIZE(8, 8), 1, false, 0, 255,
4307 };
4308 
4311 };
4312 
4314  {2, UPB_SIZE(1, 1), 1, 0, 8, _UPB_MODE_SCALAR},
4315  {3, UPB_SIZE(2, 2), 2, 0, 8, _UPB_MODE_SCALAR},
4316  {999, UPB_SIZE(4, 8), 0, 0, 11, _UPB_MODE_ARRAY},
4317 };
4318 
4322  UPB_SIZE(8, 16), 3, false, 0, 255,
4323 };
4324 
4327 };
4328 
4330  {1, UPB_SIZE(1, 1), 1, 0, 8, _UPB_MODE_SCALAR},
4331  {999, UPB_SIZE(4, 8), 0, 0, 11, _UPB_MODE_ARRAY},
4332 };
4333 
4337  UPB_SIZE(8, 16), 2, false, 1, 255,
4338 };
4339 
4342 };
4343 
4345  {33, UPB_SIZE(1, 1), 1, 0, 8, _UPB_MODE_SCALAR},
4346  {999, UPB_SIZE(4, 8), 0, 0, 11, _UPB_MODE_ARRAY},
4347 };
4348 
4352  UPB_SIZE(8, 16), 2, false, 0, 255,
4353 };
4354 
4357 };
4358 
4360  {33, UPB_SIZE(8, 8), 1, 0, 8, _UPB_MODE_SCALAR},
4361  {34, UPB_SIZE(4, 4), 2, 0, 14, _UPB_MODE_SCALAR},
4362  {999, UPB_SIZE(12, 16), 0, 0, 11, _UPB_MODE_ARRAY},
4363 };
4364 
4368  UPB_SIZE(16, 24), 3, false, 0, 255,
4369 };
4370 
4373 };
4374 
4376  {2, UPB_SIZE(56, 80), 0, 0, 11, _UPB_MODE_ARRAY},
4377  {3, UPB_SIZE(32, 32), 1, 0, 12, _UPB_MODE_SCALAR},
4378  {4, UPB_SIZE(8, 8), 2, 0, 4, _UPB_MODE_SCALAR},
4379  {5, UPB_SIZE(16, 16), 3, 0, 3, _UPB_MODE_SCALAR},
4380  {6, UPB_SIZE(24, 24), 4, 0, 1, _UPB_MODE_SCALAR},
4381  {7, UPB_SIZE(40, 48), 5, 0, 12, _UPB_MODE_SCALAR},
4382  {8, UPB_SIZE(48, 64), 6, 0, 12, _UPB_MODE_SCALAR},
4383 };
4384 
4388  UPB_SIZE(64, 96), 7, false, 0, 255,
4389 };
4390 
4392  {1, UPB_SIZE(4, 8), 1, 0, 12, _UPB_MODE_SCALAR},
4393  {2, UPB_SIZE(1, 1), 2, 0, 8, _UPB_MODE_SCALAR},
4394 };
4395 
4397  NULL,
4399  UPB_SIZE(16, 32), 2, false, 2, 255,
4400 };
4401 
4404 };
4405 
4407  {1, UPB_SIZE(0, 0), 0, 0, 11, _UPB_MODE_ARRAY},
4408 };
4409 
4413  UPB_SIZE(8, 8), 1, false, 1, 255,
4414 };
4415 
4417  {1, UPB_SIZE(20, 40), 0, 0, 5, _UPB_MODE_ARRAY | _UPB_MODE_IS_PACKED},
4418  {2, UPB_SIZE(24, 48), 0, 0, 5, _UPB_MODE_ARRAY | _UPB_MODE_IS_PACKED},
4419  {3, UPB_SIZE(4, 8), 1, 0, 12, _UPB_MODE_SCALAR},
4420  {4, UPB_SIZE(12, 24), 2, 0, 12, _UPB_MODE_SCALAR},
4421  {6, UPB_SIZE(28, 56), 0, 0, 12, _UPB_MODE_ARRAY},
4422 };
4423 
4425  NULL,
4427  UPB_SIZE(32, 64), 5, false, 4, 255,
4428 };
4429 
4432 };
4433 
4435  {1, UPB_SIZE(0, 0), 0, 0, 11, _UPB_MODE_ARRAY},
4436 };
4437 
4441  UPB_SIZE(8, 8), 1, false, 1, 255,
4442 };
4443 
4445  {1, UPB_SIZE(20, 32), 0, 0, 5, _UPB_MODE_ARRAY | _UPB_MODE_IS_PACKED},
4446  {2, UPB_SIZE(12, 16), 1, 0, 12, _UPB_MODE_SCALAR},
4447  {3, UPB_SIZE(4, 4), 2, 0, 5, _UPB_MODE_SCALAR},
4448  {4, UPB_SIZE(8, 8), 3, 0, 5, _UPB_MODE_SCALAR},
4449 };
4450 
4452  NULL,
4454  UPB_SIZE(24, 48), 4, false, 4, 255,
4455 };
4456 
4457 
4458 /* This file was generated by upbc (the upb compiler) from the input
4460  * file:
4461  *
4462  * google/protobuf/descriptor.proto
4463  *
4464  * Do not edit -- your changes will be discarded when the file is
4465  * regenerated. */
4466 
4467 
4495 
4496 static const upb_msglayout *layouts[27] = {
4524 };
4525 
4526 static const char descriptor[7601] = {'\n', ' ', 'g', 'o', 'o', 'g', 'l', 'e', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 'd', 'e', 's', 'c', 'r', 'i', 'p',
4527 't', 'o', 'r', '.', 'p', 'r', 'o', 't', 'o', '\022', '\017', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u',
4528 'f', '\"', 'M', '\n', '\021', 'F', 'i', 'l', 'e', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'S', 'e', 't', '\022', '8', '\n',
4529 '\004', 'f', 'i', 'l', 'e', '\030', '\001', ' ', '\003', '(', '\013', '2', '$', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't',
4530 'o', 'b', 'u', 'f', '.', 'F', 'i', 'l', 'e', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', 'R',
4531 '\004', 'f', 'i', 'l', 'e', '\"', '\344', '\004', '\n', '\023', 'F', 'i', 'l', 'e', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P',
4532 'r', 'o', 't', 'o', '\022', '\022', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', 'R', '\004', 'n', 'a', 'm', 'e', '\022',
4533 '\030', '\n', '\007', 'p', 'a', 'c', 'k', 'a', 'g', 'e', '\030', '\002', ' ', '\001', '(', '\t', 'R', '\007', 'p', 'a', 'c', 'k', 'a', 'g', 'e',
4534 '\022', '\036', '\n', '\n', 'd', 'e', 'p', 'e', 'n', 'd', 'e', 'n', 'c', 'y', '\030', '\003', ' ', '\003', '(', '\t', 'R', '\n', 'd', 'e', 'p',
4535 'e', 'n', 'd', 'e', 'n', 'c', 'y', '\022', '+', '\n', '\021', 'p', 'u', 'b', 'l', 'i', 'c', '_', 'd', 'e', 'p', 'e', 'n', 'd', 'e',
4536 'n', 'c', 'y', '\030', '\n', ' ', '\003', '(', '\005', 'R', '\020', 'p', 'u', 'b', 'l', 'i', 'c', 'D', 'e', 'p', 'e', 'n', 'd', 'e', 'n',
4537 'c', 'y', '\022', '\'', '\n', '\017', 'w', 'e', 'a', 'k', '_', 'd', 'e', 'p', 'e', 'n', 'd', 'e', 'n', 'c', 'y', '\030', '\013', ' ', '\003',
4538 '(', '\005', 'R', '\016', 'w', 'e', 'a', 'k', 'D', 'e', 'p', 'e', 'n', 'd', 'e', 'n', 'c', 'y', '\022', 'C', '\n', '\014', 'm', 'e', 's',
4539 's', 'a', 'g', 'e', '_', 't', 'y', 'p', 'e', '\030', '\004', ' ', '\003', '(', '\013', '2', ' ', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.',
4540 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', 'R',
4541 '\013', 'm', 'e', 's', 's', 'a', 'g', 'e', 'T', 'y', 'p', 'e', '\022', 'A', '\n', '\t', 'e', 'n', 'u', 'm', '_', 't', 'y', 'p', 'e',
4542 '\030', '\005', ' ', '\003', '(', '\013', '2', '$', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.',
4543 'E', 'n', 'u', 'm', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', 'R', '\010', 'e', 'n', 'u', 'm',
4544 'T', 'y', 'p', 'e', '\022', 'A', '\n', '\007', 's', 'e', 'r', 'v', 'i', 'c', 'e', '\030', '\006', ' ', '\003', '(', '\013', '2', '\'', '.', 'g',
4545 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'e', 'r', 'v', 'i', 'c', 'e', 'D', 'e', 's',
4546 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', 'R', '\007', 's', 'e', 'r', 'v', 'i', 'c', 'e', '\022', 'C', '\n', '\t',
4547 'e', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', '\030', '\007', ' ', '\003', '(', '\013', '2', '%', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.',
4548 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l', 'd', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P',
4549 'r', 'o', 't', 'o', 'R', '\t', 'e', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', '\022', '6', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n',
4550 's', '\030', '\010', ' ', '\001', '(', '\013', '2', '\034', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f',
4551 '.', 'F', 'i', 'l', 'e', 'O', 'p', 't', 'i', 'o', 'n', 's', 'R', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\022', 'I', '\n', '\020',
4552 's', 'o', 'u', 'r', 'c', 'e', '_', 'c', 'o', 'd', 'e', '_', 'i', 'n', 'f', 'o', '\030', '\t', ' ', '\001', '(', '\013', '2', '\037', '.',
4553 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 'd',
4554 'e', 'I', 'n', 'f', 'o', 'R', '\016', 's', 'o', 'u', 'r', 'c', 'e', 'C', 'o', 'd', 'e', 'I', 'n', 'f', 'o', '\022', '\026', '\n', '\006',
4555 's', 'y', 'n', 't', 'a', 'x', '\030', '\014', ' ', '\001', '(', '\t', 'R', '\006', 's', 'y', 'n', 't', 'a', 'x', '\"', '\271', '\006', '\n', '\017',
4556 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', '\022', '\022', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001',
4557 ' ', '\001', '(', '\t', 'R', '\004', 'n', 'a', 'm', 'e', '\022', ';', '\n', '\005', 'f', 'i', 'e', 'l', 'd', '\030', '\002', ' ', '\003', '(', '\013',
4558 '2', '%', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l', 'd', 'D',
4559 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', 'R', '\005', 'f', 'i', 'e', 'l', 'd', '\022', 'C', '\n', '\t',
4560 'e', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', '\030', '\006', ' ', '\003', '(', '\013', '2', '%', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.',
4561 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l', 'd', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P',
4562 'r', 'o', 't', 'o', 'R', '\t', 'e', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', '\022', 'A', '\n', '\013', 'n', 'e', 's', 't', 'e', 'd',
4563 '_', 't', 'y', 'p', 'e', '\030', '\003', ' ', '\003', '(', '\013', '2', ' ', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't',
4564 'o', 'b', 'u', 'f', '.', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', 'R', '\n', 'n', 'e', 's',
4565 't', 'e', 'd', 'T', 'y', 'p', 'e', '\022', 'A', '\n', '\t', 'e', 'n', 'u', 'm', '_', 't', 'y', 'p', 'e', '\030', '\004', ' ', '\003', '(',
4566 '\013', '2', '$', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'E', 'n', 'u', 'm', 'D',
4567 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', 'R', '\010', 'e', 'n', 'u', 'm', 'T', 'y', 'p', 'e', '\022',
4568 'X', '\n', '\017', 'e', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', '_', 'r', 'a', 'n', 'g', 'e', '\030', '\005', ' ', '\003', '(', '\013', '2',
4569 '/', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'D', 'e', 's', 'c', 'r', 'i', 'p',
4570 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', '.', 'E', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', 'R', 'a', 'n', 'g', 'e', 'R', '\016',
4571 'e', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', 'R', 'a', 'n', 'g', 'e', '\022', 'D', '\n', '\n', 'o', 'n', 'e', 'o', 'f', '_', 'd',
4572 'e', 'c', 'l', '\030', '\010', ' ', '\003', '(', '\013', '2', '%', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b',
4573 'u', 'f', '.', 'O', 'n', 'e', 'o', 'f', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', 'R', '\t',
4574 'o', 'n', 'e', 'o', 'f', 'D', 'e', 'c', 'l', '\022', '9', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\007', ' ', '\001', '(',
4575 '\013', '2', '\037', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'M', 'e', 's', 's', 'a',
4576 'g', 'e', 'O', 'p', 't', 'i', 'o', 'n', 's', 'R', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\022', 'U', '\n', '\016', 'r', 'e', 's',
4577 'e', 'r', 'v', 'e', 'd', '_', 'r', 'a', 'n', 'g', 'e', '\030', '\t', ' ', '\003', '(', '\013', '2', '.', '.', 'g', 'o', 'o', 'g', 'l',
4578 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't',
4579 'o', '.', 'R', 'e', 's', 'e', 'r', 'v', 'e', 'd', 'R', 'a', 'n', 'g', 'e', 'R', '\r', 'r', 'e', 's', 'e', 'r', 'v', 'e', 'd',
4580 'R', 'a', 'n', 'g', 'e', '\022', '#', '\n', '\r', 'r', 'e', 's', 'e', 'r', 'v', 'e', 'd', '_', 'n', 'a', 'm', 'e', '\030', '\n', ' ',
4581 '\003', '(', '\t', 'R', '\014', 'r', 'e', 's', 'e', 'r', 'v', 'e', 'd', 'N', 'a', 'm', 'e', '\032', 'z', '\n', '\016', 'E', 'x', 't', 'e',
4582 'n', 's', 'i', 'o', 'n', 'R', 'a', 'n', 'g', 'e', '\022', '\024', '\n', '\005', 's', 't', 'a', 'r', 't', '\030', '\001', ' ', '\001', '(', '\005',
4583 'R', '\005', 's', 't', 'a', 'r', 't', '\022', '\020', '\n', '\003', 'e', 'n', 'd', '\030', '\002', ' ', '\001', '(', '\005', 'R', '\003', 'e', 'n', 'd',
4584 '\022', '@', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\003', ' ', '\001', '(', '\013', '2', '&', '.', 'g', 'o', 'o', 'g', 'l',
4585 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'E', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', 'R', 'a', 'n', 'g', 'e',
4586 'O', 'p', 't', 'i', 'o', 'n', 's', 'R', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\032', '7', '\n', '\r', 'R', 'e', 's', 'e', 'r',
4587 'v', 'e', 'd', 'R', 'a', 'n', 'g', 'e', '\022', '\024', '\n', '\005', 's', 't', 'a', 'r', 't', '\030', '\001', ' ', '\001', '(', '\005', 'R', '\005',
4588 's', 't', 'a', 'r', 't', '\022', '\020', '\n', '\003', 'e', 'n', 'd', '\030', '\002', ' ', '\001', '(', '\005', 'R', '\003', 'e', 'n', 'd', '\"', '|',
4589 '\n', '\025', 'E', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', 'R', 'a', 'n', 'g', 'e', 'O', 'p', 't', 'i', 'o', 'n', 's', '\022', 'X',
4590 '\n', '\024', 'u', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', '_', 'o', 'p', 't', 'i', 'o', 'n', '\030', '\347', '\007',
4591 ' ', '\003', '(', '\013', '2', '$', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'U', 'n',
4592 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', 'R', '\023', 'u', 'n', 'i', 'n', 't', 'e',
4593 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', '*', '\t', '\010', '\350', '\007', '\020', '\200', '\200', '\200', '\200', '\002', '\"',
4594 '\301', '\006', '\n', '\024', 'F', 'i', 'e', 'l', 'd', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', '\022',
4595 '\022', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', 'R', '\004', 'n', 'a', 'm', 'e', '\022', '\026', '\n', '\006', 'n', 'u',
4596 'm', 'b', 'e', 'r', '\030', '\003', ' ', '\001', '(', '\005', 'R', '\006', 'n', 'u', 'm', 'b', 'e', 'r', '\022', 'A', '\n', '\005', 'l', 'a', 'b',
4597 'e', 'l', '\030', '\004', ' ', '\001', '(', '\016', '2', '+', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u',
4598 'f', '.', 'F', 'i', 'e', 'l', 'd', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', '.', 'L', 'a',
4599 'b', 'e', 'l', 'R', '\005', 'l', 'a', 'b', 'e', 'l', '\022', '>', '\n', '\004', 't', 'y', 'p', 'e', '\030', '\005', ' ', '\001', '(', '\016', '2',
4600 '*', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l', 'd', 'D', 'e',
4601 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', '.', 'T', 'y', 'p', 'e', 'R', '\004', 't', 'y', 'p', 'e', '\022',
4602 '\033', '\n', '\t', 't', 'y', 'p', 'e', '_', 'n', 'a', 'm', 'e', '\030', '\006', ' ', '\001', '(', '\t', 'R', '\010', 't', 'y', 'p', 'e', 'N',
4603 'a', 'm', 'e', '\022', '\032', '\n', '\010', 'e', 'x', 't', 'e', 'n', 'd', 'e', 'e', '\030', '\002', ' ', '\001', '(', '\t', 'R', '\010', 'e', 'x',
4604 't', 'e', 'n', 'd', 'e', 'e', '\022', '#', '\n', '\r', 'd', 'e', 'f', 'a', 'u', 'l', 't', '_', 'v', 'a', 'l', 'u', 'e', '\030', '\007',
4605 ' ', '\001', '(', '\t', 'R', '\014', 'd', 'e', 'f', 'a', 'u', 'l', 't', 'V', 'a', 'l', 'u', 'e', '\022', '\037', '\n', '\013', 'o', 'n', 'e',
4606 'o', 'f', '_', 'i', 'n', 'd', 'e', 'x', '\030', '\t', ' ', '\001', '(', '\005', 'R', '\n', 'o', 'n', 'e', 'o', 'f', 'I', 'n', 'd', 'e',
4607 'x', '\022', '\033', '\n', '\t', 'j', 's', 'o', 'n', '_', 'n', 'a', 'm', 'e', '\030', '\n', ' ', '\001', '(', '\t', 'R', '\010', 'j', 's', 'o',
4608 'n', 'N', 'a', 'm', 'e', '\022', '7', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\010', ' ', '\001', '(', '\013', '2', '\035', '.',
4609 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l', 'd', 'O', 'p', 't', 'i',
4610 'o', 'n', 's', 'R', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\022', '\'', '\n', '\017', 'p', 'r', 'o', 't', 'o', '3', '_', 'o', 'p',
4611 't', 'i', 'o', 'n', 'a', 'l', '\030', '\021', ' ', '\001', '(', '\010', 'R', '\016', 'p', 'r', 'o', 't', 'o', '3', 'O', 'p', 't', 'i', 'o',
4612 'n', 'a', 'l', '\"', '\266', '\002', '\n', '\004', 'T', 'y', 'p', 'e', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'D', 'O', 'U', 'B',
4613 'L', 'E', '\020', '\001', '\022', '\016', '\n', '\n', 'T', 'Y', 'P', 'E', '_', 'F', 'L', 'O', 'A', 'T', '\020', '\002', '\022', '\016', '\n', '\n', 'T',
4614 'Y', 'P', 'E', '_', 'I', 'N', 'T', '6', '4', '\020', '\003', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'U', 'I', 'N', 'T', '6',
4615 '4', '\020', '\004', '\022', '\016', '\n', '\n', 'T', 'Y', 'P', 'E', '_', 'I', 'N', 'T', '3', '2', '\020', '\005', '\022', '\020', '\n', '\014', 'T', 'Y',
4616 'P', 'E', '_', 'F', 'I', 'X', 'E', 'D', '6', '4', '\020', '\006', '\022', '\020', '\n', '\014', 'T', 'Y', 'P', 'E', '_', 'F', 'I', 'X', 'E',
4617 'D', '3', '2', '\020', '\007', '\022', '\r', '\n', '\t', 'T', 'Y', 'P', 'E', '_', 'B', 'O', 'O', 'L', '\020', '\010', '\022', '\017', '\n', '\013', 'T',
4618 'Y', 'P', 'E', '_', 'S', 'T', 'R', 'I', 'N', 'G', '\020', '\t', '\022', '\016', '\n', '\n', 'T', 'Y', 'P', 'E', '_', 'G', 'R', 'O', 'U',
4619 'P', '\020', '\n', '\022', '\020', '\n', '\014', 'T', 'Y', 'P', 'E', '_', 'M', 'E', 'S', 'S', 'A', 'G', 'E', '\020', '\013', '\022', '\016', '\n', '\n',
4620 'T', 'Y', 'P', 'E', '_', 'B', 'Y', 'T', 'E', 'S', '\020', '\014', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'U', 'I', 'N', 'T',
4621 '3', '2', '\020', '\r', '\022', '\r', '\n', '\t', 'T', 'Y', 'P', 'E', '_', 'E', 'N', 'U', 'M', '\020', '\016', '\022', '\021', '\n', '\r', 'T', 'Y',
4622 'P', 'E', '_', 'S', 'F', 'I', 'X', 'E', 'D', '3', '2', '\020', '\017', '\022', '\021', '\n', '\r', 'T', 'Y', 'P', 'E', '_', 'S', 'F', 'I',
4623 'X', 'E', 'D', '6', '4', '\020', '\020', '\022', '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'S', 'I', 'N', 'T', '3', '2', '\020', '\021', '\022',
4624 '\017', '\n', '\013', 'T', 'Y', 'P', 'E', '_', 'S', 'I', 'N', 'T', '6', '4', '\020', '\022', '\"', 'C', '\n', '\005', 'L', 'a', 'b', 'e', 'l',
4625 '\022', '\022', '\n', '\016', 'L', 'A', 'B', 'E', 'L', '_', 'O', 'P', 'T', 'I', 'O', 'N', 'A', 'L', '\020', '\001', '\022', '\022', '\n', '\016', 'L',
4626 'A', 'B', 'E', 'L', '_', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'D', '\020', '\002', '\022', '\022', '\n', '\016', 'L', 'A', 'B', 'E', 'L', '_',
4627 'R', 'E', 'P', 'E', 'A', 'T', 'E', 'D', '\020', '\003', '\"', 'c', '\n', '\024', 'O', 'n', 'e', 'o', 'f', 'D', 'e', 's', 'c', 'r', 'i',
4628 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', '\022', '\022', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', 'R', '\004',
4629 'n', 'a', 'm', 'e', '\022', '7', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\002', ' ', '\001', '(', '\013', '2', '\035', '.', 'g',
4630 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'O', 'n', 'e', 'o', 'f', 'O', 'p', 't', 'i', 'o',
4631 'n', 's', 'R', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\"', '\343', '\002', '\n', '\023', 'E', 'n', 'u', 'm', 'D', 'e', 's', 'c', 'r',
4632 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', '\022', '\022', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', 'R',
4633 '\004', 'n', 'a', 'm', 'e', '\022', '?', '\n', '\005', 'v', 'a', 'l', 'u', 'e', '\030', '\002', ' ', '\003', '(', '\013', '2', ')', '.', 'g', 'o',
4634 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'E', 'n', 'u', 'm', 'V', 'a', 'l', 'u', 'e', 'D', 'e',
4635 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', 'R', '\005', 'v', 'a', 'l', 'u', 'e', '\022', '6', '\n', '\007', 'o',
4636 'p', 't', 'i', 'o', 'n', 's', '\030', '\003', ' ', '\001', '(', '\013', '2', '\034', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o',
4637 't', 'o', 'b', 'u', 'f', '.', 'E', 'n', 'u', 'm', 'O', 'p', 't', 'i', 'o', 'n', 's', 'R', '\007', 'o', 'p', 't', 'i', 'o', 'n',
4638 's', '\022', ']', '\n', '\016', 'r', 'e', 's', 'e', 'r', 'v', 'e', 'd', '_', 'r', 'a', 'n', 'g', 'e', '\030', '\004', ' ', '\003', '(', '\013',
4639 '2', '6', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'E', 'n', 'u', 'm', 'D', 'e',
4640 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', '.', 'E', 'n', 'u', 'm', 'R', 'e', 's', 'e', 'r', 'v', 'e',
4641 'd', 'R', 'a', 'n', 'g', 'e', 'R', '\r', 'r', 'e', 's', 'e', 'r', 'v', 'e', 'd', 'R', 'a', 'n', 'g', 'e', '\022', '#', '\n', '\r',
4642 'r', 'e', 's', 'e', 'r', 'v', 'e', 'd', '_', 'n', 'a', 'm', 'e', '\030', '\005', ' ', '\003', '(', '\t', 'R', '\014', 'r', 'e', 's', 'e',
4643 'r', 'v', 'e', 'd', 'N', 'a', 'm', 'e', '\032', ';', '\n', '\021', 'E', 'n', 'u', 'm', 'R', 'e', 's', 'e', 'r', 'v', 'e', 'd', 'R',
4644 'a', 'n', 'g', 'e', '\022', '\024', '\n', '\005', 's', 't', 'a', 'r', 't', '\030', '\001', ' ', '\001', '(', '\005', 'R', '\005', 's', 't', 'a', 'r',
4645 't', '\022', '\020', '\n', '\003', 'e', 'n', 'd', '\030', '\002', ' ', '\001', '(', '\005', 'R', '\003', 'e', 'n', 'd', '\"', '\203', '\001', '\n', '\030', 'E',
4646 'n', 'u', 'm', 'V', 'a', 'l', 'u', 'e', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', '\022', '\022',
4647 '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', 'R', '\004', 'n', 'a', 'm', 'e', '\022', '\026', '\n', '\006', 'n', 'u', 'm',
4648 'b', 'e', 'r', '\030', '\002', ' ', '\001', '(', '\005', 'R', '\006', 'n', 'u', 'm', 'b', 'e', 'r', '\022', ';', '\n', '\007', 'o', 'p', 't', 'i',
4649 'o', 'n', 's', '\030', '\003', ' ', '\001', '(', '\013', '2', '!', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b',
4650 'u', 'f', '.', 'E', 'n', 'u', 'm', 'V', 'a', 'l', 'u', 'e', 'O', 'p', 't', 'i', 'o', 'n', 's', 'R', '\007', 'o', 'p', 't', 'i',
4651 'o', 'n', 's', '\"', '\247', '\001', '\n', '\026', 'S', 'e', 'r', 'v', 'i', 'c', 'e', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r',
4652 'P', 'r', 'o', 't', 'o', '\022', '\022', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', 'R', '\004', 'n', 'a', 'm', 'e',
4653 '\022', '>', '\n', '\006', 'm', 'e', 't', 'h', 'o', 'd', '\030', '\002', ' ', '\003', '(', '\013', '2', '&', '.', 'g', 'o', 'o', 'g', 'l', 'e',
4654 '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'M', 'e', 't', 'h', 'o', 'd', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o',
4655 'r', 'P', 'r', 'o', 't', 'o', 'R', '\006', 'm', 'e', 't', 'h', 'o', 'd', '\022', '9', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's',
4656 '\030', '\003', ' ', '\001', '(', '\013', '2', '\037', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.',
4657 'S', 'e', 'r', 'v', 'i', 'c', 'e', 'O', 'p', 't', 'i', 'o', 'n', 's', 'R', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\"', '\211',
4658 '\002', '\n', '\025', 'M', 'e', 't', 'h', 'o', 'd', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', '\022',
4659 '\022', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\001', ' ', '\001', '(', '\t', 'R', '\004', 'n', 'a', 'm', 'e', '\022', '\035', '\n', '\n', 'i', 'n',
4660 'p', 'u', 't', '_', 't', 'y', 'p', 'e', '\030', '\002', ' ', '\001', '(', '\t', 'R', '\t', 'i', 'n', 'p', 'u', 't', 'T', 'y', 'p', 'e',
4661 '\022', '\037', '\n', '\013', 'o', 'u', 't', 'p', 'u', 't', '_', 't', 'y', 'p', 'e', '\030', '\003', ' ', '\001', '(', '\t', 'R', '\n', 'o', 'u',
4662 't', 'p', 'u', 't', 'T', 'y', 'p', 'e', '\022', '8', '\n', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\030', '\004', ' ', '\001', '(', '\013',
4663 '2', '\036', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'M', 'e', 't', 'h', 'o', 'd',
4664 'O', 'p', 't', 'i', 'o', 'n', 's', 'R', '\007', 'o', 'p', 't', 'i', 'o', 'n', 's', '\022', '0', '\n', '\020', 'c', 'l', 'i', 'e', 'n',
4665 't', '_', 's', 't', 'r', 'e', 'a', 'm', 'i', 'n', 'g', '\030', '\005', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R',
4666 '\017', 'c', 'l', 'i', 'e', 'n', 't', 'S', 't', 'r', 'e', 'a', 'm', 'i', 'n', 'g', '\022', '0', '\n', '\020', 's', 'e', 'r', 'v', 'e',
4667 'r', '_', 's', 't', 'r', 'e', 'a', 'm', 'i', 'n', 'g', '\030', '\006', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R',
4668 '\017', 's', 'e', 'r', 'v', 'e', 'r', 'S', 't', 'r', 'e', 'a', 'm', 'i', 'n', 'g', '\"', '\221', '\t', '\n', '\013', 'F', 'i', 'l', 'e',
4669 'O', 'p', 't', 'i', 'o', 'n', 's', '\022', '!', '\n', '\014', 'j', 'a', 'v', 'a', '_', 'p', 'a', 'c', 'k', 'a', 'g', 'e', '\030', '\001',
4670 ' ', '\001', '(', '\t', 'R', '\013', 'j', 'a', 'v', 'a', 'P', 'a', 'c', 'k', 'a', 'g', 'e', '\022', '0', '\n', '\024', 'j', 'a', 'v', 'a',
4671 '_', 'o', 'u', 't', 'e', 'r', '_', 'c', 'l', 'a', 's', 's', 'n', 'a', 'm', 'e', '\030', '\010', ' ', '\001', '(', '\t', 'R', '\022', 'j',
4672 'a', 'v', 'a', 'O', 'u', 't', 'e', 'r', 'C', 'l', 'a', 's', 's', 'n', 'a', 'm', 'e', '\022', '5', '\n', '\023', 'j', 'a', 'v', 'a',
4673 '_', 'm', 'u', 'l', 't', 'i', 'p', 'l', 'e', '_', 'f', 'i', 'l', 'e', 's', '\030', '\n', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a',
4674 'l', 's', 'e', 'R', '\021', 'j', 'a', 'v', 'a', 'M', 'u', 'l', 't', 'i', 'p', 'l', 'e', 'F', 'i', 'l', 'e', 's', '\022', 'D', '\n',
4675 '\035', 'j', 'a', 'v', 'a', '_', 'g', 'e', 'n', 'e', 'r', 'a', 't', 'e', '_', 'e', 'q', 'u', 'a', 'l', 's', '_', 'a', 'n', 'd',
4676 '_', 'h', 'a', 's', 'h', '\030', '\024', ' ', '\001', '(', '\010', 'B', '\002', '\030', '\001', 'R', '\031', 'j', 'a', 'v', 'a', 'G', 'e', 'n', 'e',
4677 'r', 'a', 't', 'e', 'E', 'q', 'u', 'a', 'l', 's', 'A', 'n', 'd', 'H', 'a', 's', 'h', '\022', ':', '\n', '\026', 'j', 'a', 'v', 'a',
4678 '_', 's', 't', 'r', 'i', 'n', 'g', '_', 'c', 'h', 'e', 'c', 'k', '_', 'u', 't', 'f', '8', '\030', '\033', ' ', '\001', '(', '\010', ':',
4679 '\005', 'f', 'a', 'l', 's', 'e', 'R', '\023', 'j', 'a', 'v', 'a', 'S', 't', 'r', 'i', 'n', 'g', 'C', 'h', 'e', 'c', 'k', 'U', 't',
4680 'f', '8', '\022', 'S', '\n', '\014', 'o', 'p', 't', 'i', 'm', 'i', 'z', 'e', '_', 'f', 'o', 'r', '\030', '\t', ' ', '\001', '(', '\016', '2',
4681 ')', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'l', 'e', 'O', 'p', 't',
4682 'i', 'o', 'n', 's', '.', 'O', 'p', 't', 'i', 'm', 'i', 'z', 'e', 'M', 'o', 'd', 'e', ':', '\005', 'S', 'P', 'E', 'E', 'D', 'R',
4683 '\013', 'o', 'p', 't', 'i', 'm', 'i', 'z', 'e', 'F', 'o', 'r', '\022', '\035', '\n', '\n', 'g', 'o', '_', 'p', 'a', 'c', 'k', 'a', 'g',
4684 'e', '\030', '\013', ' ', '\001', '(', '\t', 'R', '\t', 'g', 'o', 'P', 'a', 'c', 'k', 'a', 'g', 'e', '\022', '5', '\n', '\023', 'c', 'c', '_',
4685 'g', 'e', 'n', 'e', 'r', 'i', 'c', '_', 's', 'e', 'r', 'v', 'i', 'c', 'e', 's', '\030', '\020', ' ', '\001', '(', '\010', ':', '\005', 'f',
4686 'a', 'l', 's', 'e', 'R', '\021', 'c', 'c', 'G', 'e', 'n', 'e', 'r', 'i', 'c', 'S', 'e', 'r', 'v', 'i', 'c', 'e', 's', '\022', '9',
4687 '\n', '\025', 'j', 'a', 'v', 'a', '_', 'g', 'e', 'n', 'e', 'r', 'i', 'c', '_', 's', 'e', 'r', 'v', 'i', 'c', 'e', 's', '\030', '\021',
4688 ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R', '\023', 'j', 'a', 'v', 'a', 'G', 'e', 'n', 'e', 'r', 'i', 'c', 'S',
4689 'e', 'r', 'v', 'i', 'c', 'e', 's', '\022', '5', '\n', '\023', 'p', 'y', '_', 'g', 'e', 'n', 'e', 'r', 'i', 'c', '_', 's', 'e', 'r',
4690 'v', 'i', 'c', 'e', 's', '\030', '\022', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R', '\021', 'p', 'y', 'G', 'e', 'n',
4691 'e', 'r', 'i', 'c', 'S', 'e', 'r', 'v', 'i', 'c', 'e', 's', '\022', '7', '\n', '\024', 'p', 'h', 'p', '_', 'g', 'e', 'n', 'e', 'r',
4692 'i', 'c', '_', 's', 'e', 'r', 'v', 'i', 'c', 'e', 's', '\030', '*', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R',
4693 '\022', 'p', 'h', 'p', 'G', 'e', 'n', 'e', 'r', 'i', 'c', 'S', 'e', 'r', 'v', 'i', 'c', 'e', 's', '\022', '%', '\n', '\n', 'd', 'e',
4694 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd', '\030', '\027', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R', '\n', 'd', 'e',
4695 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd', '\022', '.', '\n', '\020', 'c', 'c', '_', 'e', 'n', 'a', 'b', 'l', 'e', '_', 'a', 'r', 'e',
4696 'n', 'a', 's', '\030', '\037', ' ', '\001', '(', '\010', ':', '\004', 't', 'r', 'u', 'e', 'R', '\016', 'c', 'c', 'E', 'n', 'a', 'b', 'l', 'e',
4697 'A', 'r', 'e', 'n', 'a', 's', '\022', '*', '\n', '\021', 'o', 'b', 'j', 'c', '_', 'c', 'l', 'a', 's', 's', '_', 'p', 'r', 'e', 'f',
4698 'i', 'x', '\030', '$', ' ', '\001', '(', '\t', 'R', '\017', 'o', 'b', 'j', 'c', 'C', 'l', 'a', 's', 's', 'P', 'r', 'e', 'f', 'i', 'x',
4699 '\022', ')', '\n', '\020', 'c', 's', 'h', 'a', 'r', 'p', '_', 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\030', '%', ' ', '\001', '(',
4700 '\t', 'R', '\017', 'c', 's', 'h', 'a', 'r', 'p', 'N', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\022', '!', '\n', '\014', 's', 'w', 'i',
4701 'f', 't', '_', 'p', 'r', 'e', 'f', 'i', 'x', '\030', '\'', ' ', '\001', '(', '\t', 'R', '\013', 's', 'w', 'i', 'f', 't', 'P', 'r', 'e',
4702 'f', 'i', 'x', '\022', '(', '\n', '\020', 'p', 'h', 'p', '_', 'c', 'l', 'a', 's', 's', '_', 'p', 'r', 'e', 'f', 'i', 'x', '\030', '(',
4703 ' ', '\001', '(', '\t', 'R', '\016', 'p', 'h', 'p', 'C', 'l', 'a', 's', 's', 'P', 'r', 'e', 'f', 'i', 'x', '\022', '#', '\n', '\r', 'p',
4704 'h', 'p', '_', 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\030', ')', ' ', '\001', '(', '\t', 'R', '\014', 'p', 'h', 'p', 'N', 'a',
4705 'm', 'e', 's', 'p', 'a', 'c', 'e', '\022', '4', '\n', '\026', 'p', 'h', 'p', '_', 'm', 'e', 't', 'a', 'd', 'a', 't', 'a', '_', 'n',
4706 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\030', ',', ' ', '\001', '(', '\t', 'R', '\024', 'p', 'h', 'p', 'M', 'e', 't', 'a', 'd', 'a',
4707 't', 'a', 'N', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\022', '!', '\n', '\014', 'r', 'u', 'b', 'y', '_', 'p', 'a', 'c', 'k', 'a',
4708 'g', 'e', '\030', '-', ' ', '\001', '(', '\t', 'R', '\013', 'r', 'u', 'b', 'y', 'P', 'a', 'c', 'k', 'a', 'g', 'e', '\022', 'X', '\n', '\024',
4709 'u', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', '_', 'o', 'p', 't', 'i', 'o', 'n', '\030', '\347', '\007', ' ', '\003',
4710 '(', '\013', '2', '$', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'U', 'n', 'i', 'n',
4711 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', 'R', '\023', 'u', 'n', 'i', 'n', 't', 'e', 'r', 'p',
4712 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', '\"', ':', '\n', '\014', 'O', 'p', 't', 'i', 'm', 'i', 'z', 'e', 'M', 'o',
4713 'd', 'e', '\022', '\t', '\n', '\005', 'S', 'P', 'E', 'E', 'D', '\020', '\001', '\022', '\r', '\n', '\t', 'C', 'O', 'D', 'E', '_', 'S', 'I', 'Z',
4714 'E', '\020', '\002', '\022', '\020', '\n', '\014', 'L', 'I', 'T', 'E', '_', 'R', 'U', 'N', 'T', 'I', 'M', 'E', '\020', '\003', '*', '\t', '\010', '\350',
4715 '\007', '\020', '\200', '\200', '\200', '\200', '\002', 'J', '\004', '\010', '&', '\020', '\'', '\"', '\321', '\002', '\n', '\016', 'M', 'e', 's', 's', 'a', 'g', 'e',
4716 'O', 'p', 't', 'i', 'o', 'n', 's', '\022', '<', '\n', '\027', 'm', 'e', 's', 's', 'a', 'g', 'e', '_', 's', 'e', 't', '_', 'w', 'i',
4717 'r', 'e', '_', 'f', 'o', 'r', 'm', 'a', 't', '\030', '\001', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R', '\024', 'm',
4718 'e', 's', 's', 'a', 'g', 'e', 'S', 'e', 't', 'W', 'i', 'r', 'e', 'F', 'o', 'r', 'm', 'a', 't', '\022', 'L', '\n', '\037', 'n', 'o',
4719 '_', 's', 't', 'a', 'n', 'd', 'a', 'r', 'd', '_', 'd', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', '_', 'a', 'c', 'c', 'e',
4720 's', 's', 'o', 'r', '\030', '\002', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R', '\034', 'n', 'o', 'S', 't', 'a', 'n',
4721 'd', 'a', 'r', 'd', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'A', 'c', 'c', 'e', 's', 's', 'o', 'r', '\022', '%', '\n',
4722 '\n', 'd', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd', '\030', '\003', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R',
4723 '\n', 'd', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd', '\022', '\033', '\n', '\t', 'm', 'a', 'p', '_', 'e', 'n', 't', 'r', 'y', '\030',
4724 '\007', ' ', '\001', '(', '\010', 'R', '\010', 'm', 'a', 'p', 'E', 'n', 't', 'r', 'y', '\022', 'X', '\n', '\024', 'u', 'n', 'i', 'n', 't', 'e',
4725 'r', 'p', 'r', 'e', 't', 'e', 'd', '_', 'o', 'p', 't', 'i', 'o', 'n', '\030', '\347', '\007', ' ', '\003', '(', '\013', '2', '$', '.', 'g',
4726 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'U', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e',
4727 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', 'R', '\023', 'u', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O',
4728 'p', 't', 'i', 'o', 'n', '*', '\t', '\010', '\350', '\007', '\020', '\200', '\200', '\200', '\200', '\002', 'J', '\004', '\010', '\010', '\020', '\t', 'J', '\004', '\010',
4729 '\t', '\020', '\n', '\"', '\342', '\003', '\n', '\014', 'F', 'i', 'e', 'l', 'd', 'O', 'p', 't', 'i', 'o', 'n', 's', '\022', 'A', '\n', '\005', 'c',
4730 't', 'y', 'p', 'e', '\030', '\001', ' ', '\001', '(', '\016', '2', '#', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o',
4731 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l', 'd', 'O', 'p', 't', 'i', 'o', 'n', 's', '.', 'C', 'T', 'y', 'p', 'e', ':', '\006', 'S',
4732 'T', 'R', 'I', 'N', 'G', 'R', '\005', 'c', 't', 'y', 'p', 'e', '\022', '\026', '\n', '\006', 'p', 'a', 'c', 'k', 'e', 'd', '\030', '\002', ' ',
4733 '\001', '(', '\010', 'R', '\006', 'p', 'a', 'c', 'k', 'e', 'd', '\022', 'G', '\n', '\006', 'j', 's', 't', 'y', 'p', 'e', '\030', '\006', ' ', '\001',
4734 '(', '\016', '2', '$', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'F', 'i', 'e', 'l',
4735 'd', 'O', 'p', 't', 'i', 'o', 'n', 's', '.', 'J', 'S', 'T', 'y', 'p', 'e', ':', '\t', 'J', 'S', '_', 'N', 'O', 'R', 'M', 'A',
4736 'L', 'R', '\006', 'j', 's', 't', 'y', 'p', 'e', '\022', '\031', '\n', '\004', 'l', 'a', 'z', 'y', '\030', '\005', ' ', '\001', '(', '\010', ':', '\005',
4737 'f', 'a', 'l', 's', 'e', 'R', '\004', 'l', 'a', 'z', 'y', '\022', '%', '\n', '\n', 'd', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd',
4738 '\030', '\003', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R', '\n', 'd', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd',
4739 '\022', '\031', '\n', '\004', 'w', 'e', 'a', 'k', '\030', '\n', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R', '\004', 'w', 'e',
4740 'a', 'k', '\022', 'X', '\n', '\024', 'u', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', '_', 'o', 'p', 't', 'i', 'o',
4741 'n', '\030', '\347', '\007', ' ', '\003', '(', '\013', '2', '$', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u',
4742 'f', '.', 'U', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', 'R', '\023', 'u', 'n',
4743 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', '\"', '/', '\n', '\005', 'C', 'T', 'y', 'p',
4744 'e', '\022', '\n', '\n', '\006', 'S', 'T', 'R', 'I', 'N', 'G', '\020', '\000', '\022', '\010', '\n', '\004', 'C', 'O', 'R', 'D', '\020', '\001', '\022', '\020',
4745 '\n', '\014', 'S', 'T', 'R', 'I', 'N', 'G', '_', 'P', 'I', 'E', 'C', 'E', '\020', '\002', '\"', '5', '\n', '\006', 'J', 'S', 'T', 'y', 'p',
4746 'e', '\022', '\r', '\n', '\t', 'J', 'S', '_', 'N', 'O', 'R', 'M', 'A', 'L', '\020', '\000', '\022', '\r', '\n', '\t', 'J', 'S', '_', 'S', 'T',
4747 'R', 'I', 'N', 'G', '\020', '\001', '\022', '\r', '\n', '\t', 'J', 'S', '_', 'N', 'U', 'M', 'B', 'E', 'R', '\020', '\002', '*', '\t', '\010', '\350',
4748 '\007', '\020', '\200', '\200', '\200', '\200', '\002', 'J', '\004', '\010', '\004', '\020', '\005', '\"', 's', '\n', '\014', 'O', 'n', 'e', 'o', 'f', 'O', 'p', 't',
4749 'i', 'o', 'n', 's', '\022', 'X', '\n', '\024', 'u', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', '_', 'o', 'p', 't',
4750 'i', 'o', 'n', '\030', '\347', '\007', ' ', '\003', '(', '\013', '2', '$', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o',
4751 'b', 'u', 'f', '.', 'U', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', 'R', '\023',
4752 'u', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', '*', '\t', '\010', '\350', '\007', '\020',
4753 '\200', '\200', '\200', '\200', '\002', '\"', '\300', '\001', '\n', '\013', 'E', 'n', 'u', 'm', 'O', 'p', 't', 'i', 'o', 'n', 's', '\022', '\037', '\n', '\013',
4754 'a', 'l', 'l', 'o', 'w', '_', 'a', 'l', 'i', 'a', 's', '\030', '\002', ' ', '\001', '(', '\010', 'R', '\n', 'a', 'l', 'l', 'o', 'w', 'A',
4755 'l', 'i', 'a', 's', '\022', '%', '\n', '\n', 'd', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd', '\030', '\003', ' ', '\001', '(', '\010', ':',
4756 '\005', 'f', 'a', 'l', 's', 'e', 'R', '\n', 'd', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd', '\022', 'X', '\n', '\024', 'u', 'n', 'i',
4757 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', '_', 'o', 'p', 't', 'i', 'o', 'n', '\030', '\347', '\007', ' ', '\003', '(', '\013', '2',
4758 '$', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'U', 'n', 'i', 'n', 't', 'e', 'r',
4759 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', 'R', '\023', 'u', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't',
4760 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', '*', '\t', '\010', '\350', '\007', '\020', '\200', '\200', '\200', '\200', '\002', 'J', '\004', '\010', '\005', '\020', '\006',
4761 '\"', '\236', '\001', '\n', '\020', 'E', 'n', 'u', 'm', 'V', 'a', 'l', 'u', 'e', 'O', 'p', 't', 'i', 'o', 'n', 's', '\022', '%', '\n', '\n',
4762 'd', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd', '\030', '\001', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R', '\n',
4763 'd', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd', '\022', 'X', '\n', '\024', 'u', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't',
4764 'e', 'd', '_', 'o', 'p', 't', 'i', 'o', 'n', '\030', '\347', '\007', ' ', '\003', '(', '\013', '2', '$', '.', 'g', 'o', 'o', 'g', 'l', 'e',
4765 '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'U', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p',
4766 't', 'i', 'o', 'n', 'R', '\023', 'u', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n',
4767 '*', '\t', '\010', '\350', '\007', '\020', '\200', '\200', '\200', '\200', '\002', '\"', '\234', '\001', '\n', '\016', 'S', 'e', 'r', 'v', 'i', 'c', 'e', 'O', 'p',
4768 't', 'i', 'o', 'n', 's', '\022', '%', '\n', '\n', 'd', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd', '\030', '!', ' ', '\001', '(', '\010',
4769 ':', '\005', 'f', 'a', 'l', 's', 'e', 'R', '\n', 'd', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd', '\022', 'X', '\n', '\024', 'u', 'n',
4770 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', '_', 'o', 'p', 't', 'i', 'o', 'n', '\030', '\347', '\007', ' ', '\003', '(', '\013',
4771 '2', '$', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'U', 'n', 'i', 'n', 't', 'e',
4772 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', 'R', '\023', 'u', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e',
4773 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', '*', '\t', '\010', '\350', '\007', '\020', '\200', '\200', '\200', '\200', '\002', '\"', '\340', '\002', '\n', '\r',
4774 'M', 'e', 't', 'h', 'o', 'd', 'O', 'p', 't', 'i', 'o', 'n', 's', '\022', '%', '\n', '\n', 'd', 'e', 'p', 'r', 'e', 'c', 'a', 't',
4775 'e', 'd', '\030', '!', ' ', '\001', '(', '\010', ':', '\005', 'f', 'a', 'l', 's', 'e', 'R', '\n', 'd', 'e', 'p', 'r', 'e', 'c', 'a', 't',
4776 'e', 'd', '\022', 'q', '\n', '\021', 'i', 'd', 'e', 'm', 'p', 'o', 't', 'e', 'n', 'c', 'y', '_', 'l', 'e', 'v', 'e', 'l', '\030', '\"',
4777 ' ', '\001', '(', '\016', '2', '/', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'M', 'e',
4778 't', 'h', 'o', 'd', 'O', 'p', 't', 'i', 'o', 'n', 's', '.', 'I', 'd', 'e', 'm', 'p', 'o', 't', 'e', 'n', 'c', 'y', 'L', 'e',
4779 'v', 'e', 'l', ':', '\023', 'I', 'D', 'E', 'M', 'P', 'O', 'T', 'E', 'N', 'C', 'Y', '_', 'U', 'N', 'K', 'N', 'O', 'W', 'N', 'R',
4780 '\020', 'i', 'd', 'e', 'm', 'p', 'o', 't', 'e', 'n', 'c', 'y', 'L', 'e', 'v', 'e', 'l', '\022', 'X', '\n', '\024', 'u', 'n', 'i', 'n',
4781 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', '_', 'o', 'p', 't', 'i', 'o', 'n', '\030', '\347', '\007', ' ', '\003', '(', '\013', '2', '$',
4782 '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'U', 'n', 'i', 'n', 't', 'e', 'r', 'p',
4783 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', 'R', '\023', 'u', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e',
4784 'd', 'O', 'p', 't', 'i', 'o', 'n', '\"', 'P', '\n', '\020', 'I', 'd', 'e', 'm', 'p', 'o', 't', 'e', 'n', 'c', 'y', 'L', 'e', 'v',
4785 'e', 'l', '\022', '\027', '\n', '\023', 'I', 'D', 'E', 'M', 'P', 'O', 'T', 'E', 'N', 'C', 'Y', '_', 'U', 'N', 'K', 'N', 'O', 'W', 'N',
4786 '\020', '\000', '\022', '\023', '\n', '\017', 'N', 'O', '_', 'S', 'I', 'D', 'E', '_', 'E', 'F', 'F', 'E', 'C', 'T', 'S', '\020', '\001', '\022', '\016',
4787 '\n', '\n', 'I', 'D', 'E', 'M', 'P', 'O', 'T', 'E', 'N', 'T', '\020', '\002', '*', '\t', '\010', '\350', '\007', '\020', '\200', '\200', '\200', '\200', '\002',
4788 '\"', '\232', '\003', '\n', '\023', 'U', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o', 'n', '\022',
4789 'A', '\n', '\004', 'n', 'a', 'm', 'e', '\030', '\002', ' ', '\003', '(', '\013', '2', '-', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r',
4790 'o', 't', 'o', 'b', 'u', 'f', '.', 'U', 'n', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'e', 'd', 'O', 'p', 't', 'i', 'o',
4791 'n', '.', 'N', 'a', 'm', 'e', 'P', 'a', 'r', 't', 'R', '\004', 'n', 'a', 'm', 'e', '\022', ')', '\n', '\020', 'i', 'd', 'e', 'n', 't',
4792 'i', 'f', 'i', 'e', 'r', '_', 'v', 'a', 'l', 'u', 'e', '\030', '\003', ' ', '\001', '(', '\t', 'R', '\017', 'i', 'd', 'e', 'n', 't', 'i',
4793 'f', 'i', 'e', 'r', 'V', 'a', 'l', 'u', 'e', '\022', ',', '\n', '\022', 'p', 'o', 's', 'i', 't', 'i', 'v', 'e', '_', 'i', 'n', 't',
4794 '_', 'v', 'a', 'l', 'u', 'e', '\030', '\004', ' ', '\001', '(', '\004', 'R', '\020', 'p', 'o', 's', 'i', 't', 'i', 'v', 'e', 'I', 'n', 't',
4795 'V', 'a', 'l', 'u', 'e', '\022', ',', '\n', '\022', 'n', 'e', 'g', 'a', 't', 'i', 'v', 'e', '_', 'i', 'n', 't', '_', 'v', 'a', 'l',
4796 'u', 'e', '\030', '\005', ' ', '\001', '(', '\003', 'R', '\020', 'n', 'e', 'g', 'a', 't', 'i', 'v', 'e', 'I', 'n', 't', 'V', 'a', 'l', 'u',
4797 'e', '\022', '!', '\n', '\014', 'd', 'o', 'u', 'b', 'l', 'e', '_', 'v', 'a', 'l', 'u', 'e', '\030', '\006', ' ', '\001', '(', '\001', 'R', '\013',
4798 'd', 'o', 'u', 'b', 'l', 'e', 'V', 'a', 'l', 'u', 'e', '\022', '!', '\n', '\014', 's', 't', 'r', 'i', 'n', 'g', '_', 'v', 'a', 'l',
4799 'u', 'e', '\030', '\007', ' ', '\001', '(', '\014', 'R', '\013', 's', 't', 'r', 'i', 'n', 'g', 'V', 'a', 'l', 'u', 'e', '\022', '\'', '\n', '\017',
4800 'a', 'g', 'g', 'r', 'e', 'g', 'a', 't', 'e', '_', 'v', 'a', 'l', 'u', 'e', '\030', '\010', ' ', '\001', '(', '\t', 'R', '\016', 'a', 'g',
4801 'g', 'r', 'e', 'g', 'a', 't', 'e', 'V', 'a', 'l', 'u', 'e', '\032', 'J', '\n', '\010', 'N', 'a', 'm', 'e', 'P', 'a', 'r', 't', '\022',
4802 '\033', '\n', '\t', 'n', 'a', 'm', 'e', '_', 'p', 'a', 'r', 't', '\030', '\001', ' ', '\002', '(', '\t', 'R', '\010', 'n', 'a', 'm', 'e', 'P',
4803 'a', 'r', 't', '\022', '!', '\n', '\014', 'i', 's', '_', 'e', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', '\030', '\002', ' ', '\002', '(', '\010',
4804 'R', '\013', 'i', 's', 'E', 'x', 't', 'e', 'n', 's', 'i', 'o', 'n', '\"', '\247', '\002', '\n', '\016', 'S', 'o', 'u', 'r', 'c', 'e', 'C',
4805 'o', 'd', 'e', 'I', 'n', 'f', 'o', '\022', 'D', '\n', '\010', 'l', 'o', 'c', 'a', 't', 'i', 'o', 'n', '\030', '\001', ' ', '\003', '(', '\013',
4806 '2', '(', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'S', 'o', 'u', 'r', 'c', 'e',
4807 'C', 'o', 'd', 'e', 'I', 'n', 'f', 'o', '.', 'L', 'o', 'c', 'a', 't', 'i', 'o', 'n', 'R', '\010', 'l', 'o', 'c', 'a', 't', 'i',
4808 'o', 'n', '\032', '\316', '\001', '\n', '\010', 'L', 'o', 'c', 'a', 't', 'i', 'o', 'n', '\022', '\026', '\n', '\004', 'p', 'a', 't', 'h', '\030', '\001',
4809 ' ', '\003', '(', '\005', 'B', '\002', '\020', '\001', 'R', '\004', 'p', 'a', 't', 'h', '\022', '\026', '\n', '\004', 's', 'p', 'a', 'n', '\030', '\002', ' ',
4810 '\003', '(', '\005', 'B', '\002', '\020', '\001', 'R', '\004', 's', 'p', 'a', 'n', '\022', ')', '\n', '\020', 'l', 'e', 'a', 'd', 'i', 'n', 'g', '_',
4811 'c', 'o', 'm', 'm', 'e', 'n', 't', 's', '\030', '\003', ' ', '\001', '(', '\t', 'R', '\017', 'l', 'e', 'a', 'd', 'i', 'n', 'g', 'C', 'o',
4812 'm', 'm', 'e', 'n', 't', 's', '\022', '+', '\n', '\021', 't', 'r', 'a', 'i', 'l', 'i', 'n', 'g', '_', 'c', 'o', 'm', 'm', 'e', 'n',
4813 't', 's', '\030', '\004', ' ', '\001', '(', '\t', 'R', '\020', 't', 'r', 'a', 'i', 'l', 'i', 'n', 'g', 'C', 'o', 'm', 'm', 'e', 'n', 't',
4814 's', '\022', ':', '\n', '\031', 'l', 'e', 'a', 'd', 'i', 'n', 'g', '_', 'd', 'e', 't', 'a', 'c', 'h', 'e', 'd', '_', 'c', 'o', 'm',
4815 'm', 'e', 'n', 't', 's', '\030', '\006', ' ', '\003', '(', '\t', 'R', '\027', 'l', 'e', 'a', 'd', 'i', 'n', 'g', 'D', 'e', 't', 'a', 'c',
4816 'h', 'e', 'd', 'C', 'o', 'm', 'm', 'e', 'n', 't', 's', '\"', '\321', '\001', '\n', '\021', 'G', 'e', 'n', 'e', 'r', 'a', 't', 'e', 'd',
4817 'C', 'o', 'd', 'e', 'I', 'n', 'f', 'o', '\022', 'M', '\n', '\n', 'a', 'n', 'n', 'o', 't', 'a', 't', 'i', 'o', 'n', '\030', '\001', ' ',
4818 '\003', '(', '\013', '2', '-', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'G', 'e', 'n',
4819 'e', 'r', 'a', 't', 'e', 'd', 'C', 'o', 'd', 'e', 'I', 'n', 'f', 'o', '.', 'A', 'n', 'n', 'o', 't', 'a', 't', 'i', 'o', 'n',
4820 'R', '\n', 'a', 'n', 'n', 'o', 't', 'a', 't', 'i', 'o', 'n', '\032', 'm', '\n', '\n', 'A', 'n', 'n', 'o', 't', 'a', 't', 'i', 'o',
4821 'n', '\022', '\026', '\n', '\004', 'p', 'a', 't', 'h', '\030', '\001', ' ', '\003', '(', '\005', 'B', '\002', '\020', '\001', 'R', '\004', 'p', 'a', 't', 'h',
4822 '\022', '\037', '\n', '\013', 's', 'o', 'u', 'r', 'c', 'e', '_', 'f', 'i', 'l', 'e', '\030', '\002', ' ', '\001', '(', '\t', 'R', '\n', 's', 'o',
4823 'u', 'r', 'c', 'e', 'F', 'i', 'l', 'e', '\022', '\024', '\n', '\005', 'b', 'e', 'g', 'i', 'n', '\030', '\003', ' ', '\001', '(', '\005', 'R', '\005',
4824 'b', 'e', 'g', 'i', 'n', '\022', '\020', '\n', '\003', 'e', 'n', 'd', '\030', '\004', ' ', '\001', '(', '\005', 'R', '\003', 'e', 'n', 'd', 'B', '~',
4825 '\n', '\023', 'c', 'o', 'm', '.', 'g', 'o', 'o', 'g', 'l', 'e', '.', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', 'B', '\020', 'D', 'e',
4826 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'P', 'r', 'o', 't', 'o', 's', 'H', '\001', 'Z', '-', 'g', 'o', 'o', 'g', 'l', 'e', '.',
4827 'g', 'o', 'l', 'a', 'n', 'g', '.', 'o', 'r', 'g', '/', 'p', 'r', 'o', 't', 'o', 'b', 'u', 'f', '/', 't', 'y', 'p', 'e', 's',
4828 '/', 'd', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'p', 'b', '\370', '\001', '\001', '\242', '\002', '\003', 'G', 'P', 'B', '\252', '\002', '\032',
4829 'G', 'o', 'o', 'g', 'l', 'e', '.', 'P', 'r', 'o', 't', 'o', 'b', 'u', 'f', '.', 'R', 'e', 'f', 'l', 'e', 'c', 't', 'i', 'o',
4830 'n',
4831 };
4832 
4833 static upb_def_init *deps[1] = {
4834  NULL
4835 };
4836 
4838  deps,
4839  layouts,
4840  "google/protobuf/descriptor.proto",
4842 };
4843 
4846 #include <ctype.h>
4847 #include <errno.h>
4848 #include <setjmp.h>
4849 #include <stdlib.h>
4850 #include <string.h>
4851 
4852 
4853 /* Must be last. */
4854 
4855 typedef struct {
4856  size_t len;
4857  char str[1]; /* Null-terminated string data follows. */
4858 } str_t;
4859 
4860 struct upb_fielddef {
4861  const upb_filedef *file;
4862  const upb_msgdef *msgdef;
4863  const char *full_name;
4864  const char *json_name;
4865  union {
4866  int64_t sint;
4867  uint64_t uint;
4868  double dbl;
4869  float flt;
4870  bool boolean;
4871  str_t *str;
4872  } defaultval;
4873  const upb_oneofdef *oneof;
4874  union {
4875  const upb_msgdef *msgdef;
4876  const upb_enumdef *enumdef;
4878  } sub;
4879  uint32_t number_;
4882  bool is_extension_;
4883  bool lazy_;
4884  bool packed_;
4888 };
4889 
4890 struct upb_msgdef {
4892  const upb_filedef *file;
4893  const char *full_name;
4894 
4895  /* Tables for looking up fields by number and name. */
4898 
4899  const upb_fielddef *fields;
4900  const upb_oneofdef *oneofs;
4901  int field_count;
4902  int oneof_count;
4904 
4905  /* Is this a map-entry message? */
4906  bool map_entry;
4908 
4909  /* TODO(haberman): proper extension ranges (there can be multiple). */
4910 };
4911 
4912 struct upb_enumdef {
4913  const upb_filedef *file;
4914  const char *full_name;
4918 };
4919 
4920 struct upb_oneofdef {
4921  const upb_msgdef *parent;
4922  const char *full_name;
4928 };
4929 
4930 struct upb_filedef {
4931  const char *name;
4932  const char *package;
4933  const char *phpprefix;
4934  const char *phpnamespace;
4935 
4936  const upb_filedef **deps;
4937  const upb_msgdef *msgs;
4938  const upb_enumdef *enums;
4939  const upb_fielddef *exts;
4941 
4942  int dep_count;
4943  int msg_count;
4944  int enum_count;
4945  int ext_count;
4947 };
4948 
4949 struct upb_symtab {
4950  upb_arena *arena;
4951  upb_strtable syms; /* full_name -> packed def ptr */
4952  upb_strtable files; /* file_name -> upb_filedef* */
4954 };
4955 
4956 /* Inside a symtab we store tagged pointers to specific def types. */
4957 typedef enum {
4959 
4960  /* Only inside symtab table. */
4963 
4964  /* Only inside message table. */
4967 } upb_deftype_t;
4968 
4969 static const void *unpack_def(upb_value v, upb_deftype_t type) {
4970  uintptr_t num = (uintptr_t)upb_value_getconstptr(v);
4971  return (num & 3) == type ? (const void*)(num & ~3) : NULL;
4972 }
4973 
4974 static upb_value pack_def(const void *ptr, upb_deftype_t type) {
4976  return upb_value_constptr((const void*)num);
4977 }
4978 
4979 /* isalpha() etc. from <ctype.h> are locale-dependent, which we don't want. */
4980 static bool upb_isbetween(char c, char low, char high) {
4981  return c >= low && c <= high;
4982 }
4983 
4984 static bool upb_isletter(char c) {
4985  return upb_isbetween(c, 'A', 'Z') || upb_isbetween(c, 'a', 'z') || c == '_';
4986 }
4987 
4988 static bool upb_isalphanum(char c) {
4989  return upb_isletter(c) || upb_isbetween(c, '0', '9');
4990 }
4991 
4992 static const char *shortdefname(const char *fullname) {
4993  const char *p;
4994 
4995  if (fullname == NULL) {
4996  return NULL;
4997  } else if ((p = strrchr(fullname, '.')) == NULL) {
4998  /* No '.' in the name, return the full string. */
4999  return fullname;
5000  } else {
5001  /* Return one past the last '.'. */
5002  return p + 1;
5003  }
5004 }
5005 
5006 /* All submessage fields are lower than all other fields.
5007  * Secondly, fields are increasing in order. */
5010  const uint32_t high_bit = 1 << 30;
5011  UPB_ASSERT(ret < high_bit);
5012  if (!upb_fielddef_issubmsg(f))
5013  ret |= high_bit;
5014  return ret;
5015 }
5016 
5017 int cmp_fields(const void *p1, const void *p2) {
5018  const upb_fielddef *f1 = *(upb_fielddef*const*)p1;
5019  const upb_fielddef *f2 = *(upb_fielddef*const*)p2;
5020  return field_rank(f1) - field_rank(f2);
5021 }
5022 
5024  upb_status_seterrmsg(status, "out of memory");
5025 }
5026 
5028  const char *name = upb_msgdef_fullname(m);
5029  if (name == NULL) {
5030  m->well_known_type = UPB_WELLKNOWN_UNSPECIFIED;
5031  return;
5032  }
5033  if (!strcmp(name, "google.protobuf.Any")) {
5034  m->well_known_type = UPB_WELLKNOWN_ANY;
5035  } else if (!strcmp(name, "google.protobuf.FieldMask")) {
5036  m->well_known_type = UPB_WELLKNOWN_FIELDMASK;
5037  } else if (!strcmp(name, "google.protobuf.Duration")) {
5038  m->well_known_type = UPB_WELLKNOWN_DURATION;
5039  } else if (!strcmp(name, "google.protobuf.Timestamp")) {
5040  m->well_known_type = UPB_WELLKNOWN_TIMESTAMP;
5041  } else if (!strcmp(name, "google.protobuf.DoubleValue")) {
5042  m->well_known_type = UPB_WELLKNOWN_DOUBLEVALUE;
5043  } else if (!strcmp(name, "google.protobuf.FloatValue")) {
5044  m->well_known_type = UPB_WELLKNOWN_FLOATVALUE;
5045  } else if (!strcmp(name, "google.protobuf.Int64Value")) {
5046  m->well_known_type = UPB_WELLKNOWN_INT64VALUE;
5047  } else if (!strcmp(name, "google.protobuf.UInt64Value")) {
5048  m->well_known_type = UPB_WELLKNOWN_UINT64VALUE;
5049  } else if (!strcmp(name, "google.protobuf.Int32Value")) {
5050  m->well_known_type = UPB_WELLKNOWN_INT32VALUE;
5051  } else if (!strcmp(name, "google.protobuf.UInt32Value")) {
5052  m->well_known_type = UPB_WELLKNOWN_UINT32VALUE;
5053  } else if (!strcmp(name, "google.protobuf.BoolValue")) {
5054  m->well_known_type = UPB_WELLKNOWN_BOOLVALUE;
5055  } else if (!strcmp(name, "google.protobuf.StringValue")) {
5056  m->well_known_type = UPB_WELLKNOWN_STRINGVALUE;
5057  } else if (!strcmp(name, "google.protobuf.BytesValue")) {
5058  m->well_known_type = UPB_WELLKNOWN_BYTESVALUE;
5059  } else if (!strcmp(name, "google.protobuf.Value")) {
5060  m->well_known_type = UPB_WELLKNOWN_VALUE;
5061  } else if (!strcmp(name, "google.protobuf.ListValue")) {
5062  m->well_known_type = UPB_WELLKNOWN_LISTVALUE;
5063  } else if (!strcmp(name, "google.protobuf.Struct")) {
5064  m->well_known_type = UPB_WELLKNOWN_STRUCT;
5065  } else {
5066  m->well_known_type = UPB_WELLKNOWN_UNSPECIFIED;
5067  }
5068 }
5069 
5070 
5071 /* upb_enumdef ****************************************************************/
5072 
5073 const char *upb_enumdef_fullname(const upb_enumdef *e) {
5074  return e->full_name;
5075 }
5076 
5077 const char *upb_enumdef_name(const upb_enumdef *e) {
5078  return shortdefname(e->full_name);
5079 }
5080 
5082  return e->file;
5083 }
5084 
5086  UPB_ASSERT(upb_enumdef_iton(e, e->defaultval));
5087  return e->defaultval;
5088 }
5089 
5091  return (int)upb_strtable_count(&e->ntoi);
5092 }
5093 
5095  /* We iterate over the ntoi table, to account for duplicate numbers. */
5096  upb_strtable_begin(i, &e->ntoi);
5097 }
5098 
5101 
5102 bool upb_enumdef_ntoi(const upb_enumdef *def, const char *name,
5103  size_t len, int32_t *num) {
5104  upb_value v;
5105  if (!upb_strtable_lookup2(&def->ntoi, name, len, &v)) {
5106  return false;
5107  }
5108  if (num) *num = upb_value_getint32(v);
5109  return true;
5110 }
5111 
5113  upb_value v;
5114  return upb_inttable_lookup(&def->iton, num, &v) ? upb_value_getcstr(v) : NULL;
5115 }
5116 
5119 }
5120 
5122  return upb_value_getint32(upb_strtable_iter_value(iter));
5123 }
5124 
5125 
5126 /* upb_fielddef ***************************************************************/
5127 
5128 const char *upb_fielddef_fullname(const upb_fielddef *f) {
5129  return f->full_name;
5130 }
5131 
5133  switch (f->type_) {
5135  return UPB_TYPE_DOUBLE;
5137  return UPB_TYPE_FLOAT;
5141  return UPB_TYPE_INT64;
5145  return UPB_TYPE_INT32;
5148  return UPB_TYPE_UINT64;
5151  return UPB_TYPE_UINT32;
5153  return UPB_TYPE_ENUM;
5155  return UPB_TYPE_BOOL;
5157  return UPB_TYPE_STRING;
5159  return UPB_TYPE_BYTES;
5162  return UPB_TYPE_MESSAGE;
5163  }
5164  UPB_UNREACHABLE();
5165 }
5166 
5168  return f->type_;
5169 }
5170 
5172  return f->index_;
5173 }
5174 
5176  return f->label_;
5177 }
5178 
5180  return f->number_;
5181 }
5182 
5184  return f->is_extension_;
5185 }
5186 
5188  return f->lazy_;
5189 }
5190 
5192  return f->packed_;
5193 }
5194 
5195 const char *upb_fielddef_name(const upb_fielddef *f) {
5196  return shortdefname(f->full_name);
5197 }
5198 
5199 const char *upb_fielddef_jsonname(const upb_fielddef *f) {
5200  return f->json_name;
5201 }
5202 
5204  return f->file;
5205 }
5206 
5208  return f->msgdef;
5209 }
5210 
5212  return f->oneof;
5213 }
5214 
5216  if (!f->oneof || upb_oneofdef_issynthetic(f->oneof)) return NULL;
5217  return f->oneof;
5218 }
5219 
5222  upb_msgval ret;
5223  if (upb_fielddef_isstring(f)) {
5224  str_t *str = f->defaultval.str;
5225  if (str) {
5226  ret.str_val.data = str->str;
5227  ret.str_val.size = str->len;
5228  } else {
5229  ret.str_val.size = 0;
5230  }
5231  } else {
5232  memcpy(&ret, &f->defaultval, 8);
5233  }
5234  return ret;
5235 }
5236 
5237 static void chkdefaulttype(const upb_fielddef *f, int ctype) {
5238  UPB_UNUSED(f);
5239  UPB_UNUSED(ctype);
5240 }
5241 
5244  return f->defaultval.sint;
5245 }
5246 
5249  return (int32_t)f->defaultval.sint;
5250 }
5251 
5254  return f->defaultval.uint;
5255 }
5256 
5259  return (uint32_t)f->defaultval.uint;
5260 }
5261 
5264  return f->defaultval.boolean;
5265 }
5266 
5269  return f->defaultval.flt;
5270 }
5271 
5274  return f->defaultval.dbl;
5275 }
5276 
5277 const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len) {
5278  str_t *str = f->defaultval.str;
5282  if (str) {
5283  if (len) *len = str->len;
5284  return str->str;
5285  } else {
5286  if (len) *len = 0;
5287  return NULL;
5288  }
5289 }
5290 
5292  return upb_fielddef_type(f) == UPB_TYPE_MESSAGE ? f->sub.msgdef : NULL;
5293 }
5294 
5296  return upb_fielddef_type(f) == UPB_TYPE_ENUM ? f->sub.enumdef : NULL;
5297 }
5298 
5300  return &f->msgdef->layout->fields[f->layout_index];
5301 }
5302 
5305 }
5306 
5308  return upb_fielddef_type(f) == UPB_TYPE_STRING ||
5310 }
5311 
5314 }
5315 
5318 }
5319 
5323 }
5324 
5327 }
5328 
5330  if (upb_fielddef_isseq(f)) return false;
5332  f->file->syntax == UPB_SYNTAX_PROTO2;
5333 }
5334 
5335 static bool between(int32_t x, int32_t low, int32_t high) {
5336  return x >= low && x <= high;
5337 }
5338 
5342 
5344  return between(type, 1, 18);
5345 }
5346 
5347 /* upb_msgdef *****************************************************************/
5348 
5349 const char *upb_msgdef_fullname(const upb_msgdef *m) {
5350  return m->full_name;
5351 }
5352 
5354  return m->file;
5355 }
5356 
5357 const char *upb_msgdef_name(const upb_msgdef *m) {
5358  return shortdefname(m->full_name);
5359 }
5360 
5362  return m->file->syntax;
5363 }
5364 
5366  upb_value val;
5367  return upb_inttable_lookup(&m->itof, i, &val) ? upb_value_getconstptr(val)
5368  : NULL;
5369 }
5370 
5371 const upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name,
5372  size_t len) {
5373  upb_value val;
5374 
5375  if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) {
5376  return NULL;
5377  }
5378 
5379  return unpack_def(val, UPB_DEFTYPE_FIELD);
5380 }
5381 
5382 const upb_oneofdef *upb_msgdef_ntoo(const upb_msgdef *m, const char *name,
5383  size_t len) {
5384  upb_value val;
5385 
5386  if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) {
5387  return NULL;
5388  }
5389 
5390  return unpack_def(val, UPB_DEFTYPE_ONEOF);
5391 }
5392 
5393 bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len,
5394  const upb_fielddef **f, const upb_oneofdef **o) {
5395  upb_value val;
5396 
5397  if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) {
5398  return false;
5399  }
5400 
5401  *o = unpack_def(val, UPB_DEFTYPE_ONEOF);
5402  *f = unpack_def(val, UPB_DEFTYPE_FIELD);
5403  return *o || *f; /* False if this was a JSON name. */
5404 }
5405 
5407  const char *name, size_t len) {
5408  upb_value val;
5409  const upb_fielddef* f;
5410 
5411  if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) {
5412  return NULL;
5413  }
5414 
5415  f = unpack_def(val, UPB_DEFTYPE_FIELD);
5416  if (!f) f = unpack_def(val, UPB_DEFTYPE_FIELD_JSONNAME);
5417 
5418  return f;
5419 }
5420 
5422  return m->field_count;
5423 }
5424 
5426  return m->oneof_count;
5427 }
5428 
5430  return m->real_oneof_count;
5431 }
5432 
5434  return m->field_count;
5435 }
5436 
5438  return m->oneof_count;
5439 }
5440 
5442  return m->real_oneof_count;
5443 }
5444 
5446  return m->layout;
5447 }
5448 
5450  UPB_ASSERT(i >= 0 && i < m->field_count);
5451  return &m->fields[i];
5452 }
5453 
5455  UPB_ASSERT(i >= 0 && i < m->oneof_count);
5456  return &m->oneofs[i];
5457 }
5458 
5460  return m->map_entry;
5461 }
5462 
5464  return m->well_known_type;
5465 }
5466 
5469  return type >= UPB_WELLKNOWN_DOUBLEVALUE &&
5471 }
5472 
5475  return type >= UPB_WELLKNOWN_DOUBLEVALUE &&
5477 }
5478 
5480  upb_inttable_begin(iter, &m->itof);
5481 }
5482 
5484 
5486  return upb_inttable_done(iter);
5487 }
5488 
5490  return (upb_fielddef *)upb_value_getconstptr(upb_inttable_iter_value(iter));
5491 }
5492 
5495 }
5496 
5498  const upb_msg_field_iter * iter2) {
5499  return upb_inttable_iter_isequal(iter1, iter2);
5500 }
5501 
5503  upb_strtable_begin(iter, &m->ntof);
5504  /* We need to skip past any initial fields. */
5505  while (!upb_strtable_done(iter) &&
5508  }
5509 }
5510 
5512  /* We need to skip past fields to return only oneofs. */
5513  do {
5515  } while (!upb_strtable_done(iter) &&
5517 }
5518 
5520  return upb_strtable_done(iter);
5521 }
5522 
5525 }
5526 
5529 }
5530 
5532  const upb_msg_oneof_iter *iter2) {
5533  return upb_strtable_iter_isequal(iter1, iter2);
5534 }
5535 
5536 /* upb_oneofdef ***************************************************************/
5537 
5538 const char *upb_oneofdef_name(const upb_oneofdef *o) {
5539  return shortdefname(o->full_name);
5540 }
5541 
5543  return o->parent;
5544 }
5545 
5547  return o->field_count;
5548 }
5549 
5551  UPB_ASSERT(i < o->field_count);
5552  return o->fields[i];
5553 }
5554 
5556  return o->field_count;
5557 }
5558 
5560  return o - o->parent->oneofs;
5561 }
5562 
5564  return o->synthetic;
5565 }
5566 
5568  const char *name, size_t length) {
5569  upb_value val;
5570  return upb_strtable_lookup2(&o->ntof, name, length, &val) ?
5571  upb_value_getptr(val) : NULL;
5572 }
5573 
5575  upb_value val;
5576  return upb_inttable_lookup(&o->itof, num, &val) ? upb_value_getptr(val)
5577  : NULL;
5578 }
5579 
5581  upb_inttable_begin(iter, &o->itof);
5582 }
5583 
5586 }
5587 
5589  return upb_inttable_done(iter);
5590 }
5591 
5593  return (upb_fielddef *)upb_value_getconstptr(upb_inttable_iter_value(iter));
5594 }
5595 
5598 }
5599 
5600 /* upb_filedef ****************************************************************/
5601 
5602 const char *upb_filedef_name(const upb_filedef *f) {
5603  return f->name;
5604 }
5605 
5606 const char *upb_filedef_package(const upb_filedef *f) {
5607  return f->package;
5608 }
5609 
5610 const char *upb_filedef_phpprefix(const upb_filedef *f) {
5611  return f->phpprefix;
5612 }
5613 
5615  return f->phpnamespace;
5616 }
5617 
5619  return f->syntax;
5620 }
5621 
5623  return f->msg_count;
5624 }
5625 
5627  return f->dep_count;
5628 }
5629 
5631  return f->enum_count;
5632 }
5633 
5635  return i < 0 || i >= f->dep_count ? NULL : f->deps[i];
5636 }
5637 
5639  return i < 0 || i >= f->msg_count ? NULL : &f->msgs[i];
5640 }
5641 
5643  return i < 0 || i >= f->enum_count ? NULL : &f->enums[i];
5644 }
5645 
5647  return f->symtab;
5648 }
5649 
5651  upb_arena_free(s->arena);
5652  upb_gfree(s);
5653 }
5654 
5656  upb_symtab *s = upb_gmalloc(sizeof(*s));
5657 
5658  if (!s) {
5659  return NULL;
5660  }
5661 
5662  s->arena = upb_arena_new();
5663  s->bytes_loaded = 0;
5664 
5665  if (!upb_strtable_init(&s->syms, 32, s->arena) ||
5666  !upb_strtable_init(&s->files, 4, s->arena)) {
5667  upb_arena_free(s->arena);
5668  upb_gfree(s);
5669  s = NULL;
5670  }
5671  return s;
5672 }
5673 
5674 const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym) {
5675  upb_value v;
5676  return upb_strtable_lookup(&s->syms, sym, &v) ?
5677  unpack_def(v, UPB_DEFTYPE_MSG) : NULL;
5678 }
5679 
5680 const upb_msgdef *upb_symtab_lookupmsg2(const upb_symtab *s, const char *sym,
5681  size_t len) {
5682  upb_value v;
5683  return upb_strtable_lookup2(&s->syms, sym, len, &v) ?
5684  unpack_def(v, UPB_DEFTYPE_MSG) : NULL;
5685 }
5686 
5687 const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym) {
5688  upb_value v;
5689  return upb_strtable_lookup(&s->syms, sym, &v) ?
5690  unpack_def(v, UPB_DEFTYPE_ENUM) : NULL;
5691 }
5692 
5693 const upb_filedef *upb_symtab_lookupfile(const upb_symtab *s, const char *name) {
5694  upb_value v;
5695  return upb_strtable_lookup(&s->files, name, &v) ? upb_value_getconstptr(v)
5696  : NULL;
5697 }
5698 
5700  const upb_symtab *s, const char *name, size_t len) {
5701  upb_value v;
5702  return upb_strtable_lookup2(&s->files, name, len, &v) ?
5703  upb_value_getconstptr(v) : NULL;
5704 }
5705 
5707  return (int)upb_strtable_count(&s->files);
5708 }
5709 
5710 /* Code to build defs from descriptor protos. *********************************/
5711 
5712 /* There is a question of how much validation to do here. It will be difficult
5713  * to perfectly match the amount of validation performed by proto2. But since
5714  * this code is used to directly build defs from Ruby (for example) we do need
5715  * to validate important constraints like uniqueness of names and numbers. */
5716 
5717 #define CHK_OOM(x) if (!(x)) { symtab_oomerr(ctx); }
5718 
5719 typedef struct {
5721  upb_filedef *file; /* File we are building. */
5722  upb_arena *arena; /* Allocate defs here. */
5723  const upb_msglayout **layouts; /* NULL if we should build layouts. */
5724  upb_status *status; /* Record errors here. */
5725  jmp_buf err; /* longjmp() on error. */
5726 } symtab_addctx;
5727 
5729 static void symtab_errf(symtab_addctx *ctx, const char *fmt, ...) {
5730  va_list argp;
5731  va_start(argp, fmt);
5732  upb_status_vseterrf(ctx->status, fmt, argp);
5733  va_end(argp);
5734  UPB_LONGJMP(ctx->err, 1);
5735 }
5736 
5739  upb_status_setoom(ctx->status);
5740  UPB_LONGJMP(ctx->err, 1);
5741 }
5742 
5744  void *ret = upb_arena_malloc(ctx->arena, bytes);
5745  if (!ret) symtab_oomerr(ctx);
5746  return ret;
5747 }
5748 
5749 static void check_ident(symtab_addctx *ctx, upb_strview name, bool full) {
5750  const char *str = name.data;
5751  size_t len = name.size;
5752  bool start = true;
5753  size_t i;
5754  for (i = 0; i < len; i++) {
5755  char c = str[i];
5756  if (c == '.') {
5757  if (start || !full) {
5758  symtab_errf(ctx, "invalid name: unexpected '.' (%.*s)", (int)len, str);
5759  }
5760  start = true;
5761  } else if (start) {
5762  if (!upb_isletter(c)) {
5763  symtab_errf(
5764  ctx,
5765  "invalid name: path components must start with a letter (%.*s)",
5766  (int)len, str);
5767  }
5768  start = false;
5769  } else {
5770  if (!upb_isalphanum(c)) {
5771  symtab_errf(ctx, "invalid name: non-alphanumeric character (%.*s)",
5772  (int)len, str);
5773  }
5774  }
5775  }
5776  if (start) {
5777  symtab_errf(ctx, "invalid name: empty part (%.*s)", (int)len, str);
5778  }
5779 }
5780 
5781 static size_t div_round_up(size_t n, size_t d) {
5782  return (n + d - 1) / d;
5783 }
5784 
5786  switch (type) {
5787  case UPB_TYPE_DOUBLE:
5788  case UPB_TYPE_INT64:
5789  case UPB_TYPE_UINT64:
5790  return 8;
5791  case UPB_TYPE_ENUM:
5792  case UPB_TYPE_INT32:
5793  case UPB_TYPE_UINT32:
5794  case UPB_TYPE_FLOAT:
5795  return 4;
5796  case UPB_TYPE_BOOL:
5797  return 1;
5798  case UPB_TYPE_MESSAGE:
5799  return sizeof(void*);
5800  case UPB_TYPE_BYTES:
5801  case UPB_TYPE_STRING:
5802  return sizeof(upb_strview);
5803  }
5804  UPB_UNREACHABLE();
5805 }
5806 
5809  upb_map_entry ent;
5810  UPB_ASSERT(sizeof(ent.k) == sizeof(ent.v));
5811  return sizeof(ent.k);
5812  } else if (upb_fielddef_isseq(f)) {
5813  return sizeof(void*);
5814  } else {
5816  }
5817 }
5818 
5820  uint32_t ret;
5821 
5822  l->size = UPB_ALIGN_UP(l->size, size);
5823  ret = l->size;
5824  l->size += size;
5825  return ret;
5826 }
5827 
5828 static int field_number_cmp(const void *p1, const void *p2) {
5829  const upb_msglayout_field *f1 = p1;
5830  const upb_msglayout_field *f2 = p2;
5831  return f1->number - f2->number;
5832 }
5833 
5836  int i;
5837  int n = upb_msgdef_numfields(m);
5838  int dense_below = 0;
5839  for (i = 0; i < n; i++) {
5841  UPB_ASSERT(f);
5842  f->layout_index = i;
5843  if (i < UINT8_MAX && fields[i].number == i + 1 &&
5844  (i == 0 || fields[i-1].number == i)) {
5845  dense_below = i + 1;
5846  }
5847  }
5848  l->dense_below = dense_below;
5849 }
5850 
5852  field->number = upb_fielddef_number(f);
5853  field->descriptortype = upb_fielddef_descriptortype(f);
5854 
5855  if (field->descriptortype == UPB_DTYPE_STRING &&
5856  f->file->syntax == UPB_SYNTAX_PROTO2) {
5857  /* See TableDescriptorType() in upbc/generator.cc for details and
5858  * rationale. */
5859  field->descriptortype = UPB_DTYPE_BYTES;
5860  }
5861 
5862  if (upb_fielddef_ismap(f)) {
5863  field->mode = _UPB_MODE_MAP;
5864  } else if (upb_fielddef_isseq(f)) {
5865  field->mode = _UPB_MODE_ARRAY;
5866  } else {
5867  field->mode = _UPB_MODE_SCALAR;
5868  }
5869 
5870  if (upb_fielddef_packed(f)) {
5871  field->mode |= _UPB_MODE_IS_PACKED;
5872  }
5873 }
5874 
5875 /* This function is the dynamic equivalent of message_layout.{cc,h} in upbc.
5876  * It computes a dynamic layout for all of the fields in |m|. */
5877 static void make_layout(symtab_addctx *ctx, const upb_msgdef *m) {
5878  upb_msglayout *l = (upb_msglayout*)m->layout;
5880  upb_msg_oneof_iter oit;
5881  size_t hasbit;
5882  size_t field_count = upb_msgdef_numfields(m);
5883  size_t submsg_count = 0;
5884  const upb_msglayout **submsgs;
5886 
5887  memset(l, 0, sizeof(*l) + sizeof(_upb_fasttable_entry));
5888 
5889  /* Count sub-messages. */
5890  for (size_t i = 0; i < field_count; i++) {
5891  if (upb_fielddef_issubmsg(&m->fields[i])) {
5892  submsg_count++;
5893  }
5894  }
5895 
5896  fields = symtab_alloc(ctx, field_count * sizeof(*fields));
5897  submsgs = symtab_alloc(ctx, submsg_count * sizeof(*submsgs));
5898 
5899  l->field_count = upb_msgdef_numfields(m);
5900  l->fields = fields;
5901  l->submsgs = submsgs;
5902  l->table_mask = 0;
5903 
5904  /* TODO(haberman): initialize fast tables so that reflection-based parsing
5905  * can get the same speeds as linked-in types. */
5906  l->fasttable[0].field_parser = &fastdecode_generic;
5907  l->fasttable[0].field_data = 0;
5908 
5909  if (upb_msgdef_mapentry(m)) {
5910  /* TODO(haberman): refactor this method so this special case is more
5911  * elegant. */
5912  const upb_fielddef *key = upb_msgdef_itof(m, 1);
5913  const upb_fielddef *val = upb_msgdef_itof(m, 2);
5914  fields[0].number = 1;
5915  fields[1].number = 2;
5916  fields[0].mode = _UPB_MODE_SCALAR;
5917  fields[1].mode = _UPB_MODE_SCALAR;
5918  fields[0].presence = 0;
5919  fields[1].presence = 0;
5920  fields[0].descriptortype = upb_fielddef_descriptortype(key);
5921  fields[1].descriptortype = upb_fielddef_descriptortype(val);
5922  fields[0].offset = 0;
5923  fields[1].offset = sizeof(upb_strview);
5924  fields[1].submsg_index = 0;
5925 
5926  if (upb_fielddef_type(val) == UPB_TYPE_MESSAGE) {
5927  submsgs[0] = upb_fielddef_msgsubdef(val)->layout;
5928  }
5929 
5930  l->field_count = 2;
5931  l->size = 2 * sizeof(upb_strview);
5932  l->size = UPB_ALIGN_UP(l->size, 8);
5933  return;
5934  }
5935 
5936  /* Allocate data offsets in three stages:
5937  *
5938  * 1. hasbits.
5939  * 2. regular fields.
5940  * 3. oneof fields.
5941  *
5942  * OPT: There is a lot of room for optimization here to minimize the size.
5943  */
5944 
5945  /* Allocate hasbits and set basic field attributes. */
5946  submsg_count = 0;
5947  for (upb_msg_field_begin(&it, m), hasbit = 0;
5949  upb_msg_field_next(&it)) {
5952 
5954 
5955  if (upb_fielddef_issubmsg(f)) {
5956  const upb_msgdef *subm = upb_fielddef_msgsubdef(f);
5957  field->submsg_index = submsg_count++;
5958  submsgs[field->submsg_index] = subm->layout;
5959  }
5960 
5962  /* We don't use hasbit 0, so that 0 can indicate "no presence" in the
5963  * table. This wastes one hasbit, but we don't worry about it for now. */
5964  field->presence = ++hasbit;
5965  } else {
5966  field->presence = 0;
5967  }
5968  }
5969 
5970  /* Account for space used by hasbits. */
5971  l->size = div_round_up(hasbit + 1, 8);
5972 
5973  /* Allocate non-oneof fields. */
5975  upb_msg_field_next(&it)) {
5976  const upb_fielddef* f = upb_msg_iter_field(&it);
5977  size_t field_size = upb_msg_fielddefsize(f);
5978  size_t index = upb_fielddef_index(f);
5979 
5981  /* Oneofs are handled separately below. */
5982  continue;
5983  }
5984 
5985  fields[index].offset = upb_msglayout_place(l, field_size);
5986  }
5987 
5988  /* Allocate oneof fields. Each oneof field consists of a uint32 for the case
5989  * and space for the actual data. */
5990  for (upb_msg_oneof_begin(&oit, m); !upb_msg_oneof_done(&oit);
5991  upb_msg_oneof_next(&oit)) {
5992  const upb_oneofdef* o = upb_msg_iter_oneof(&oit);
5993  upb_oneof_iter fit;
5994 
5995  size_t case_size = sizeof(uint32_t); /* Could potentially optimize this. */
5996  size_t field_size = 0;
5997  uint32_t case_offset;
5998  uint32_t data_offset;
5999 
6000  if (upb_oneofdef_issynthetic(o)) continue;
6001 
6002  /* Calculate field size: the max of all field sizes. */
6003  for (upb_oneof_begin(&fit, o);
6004  !upb_oneof_done(&fit);
6005  upb_oneof_next(&fit)) {
6006  const upb_fielddef* f = upb_oneof_iter_field(&fit);
6007  field_size = UPB_MAX(field_size, upb_msg_fielddefsize(f));
6008  }
6009 
6010  /* Align and allocate case offset. */
6011  case_offset = upb_msglayout_place(l, case_size);
6012  data_offset = upb_msglayout_place(l, field_size);
6013 
6014  for (upb_oneof_begin(&fit, o);
6015  !upb_oneof_done(&fit);
6016  upb_oneof_next(&fit)) {
6017  const upb_fielddef* f = upb_oneof_iter_field(&fit);
6018  fields[upb_fielddef_index(f)].offset = data_offset;
6019  fields[upb_fielddef_index(f)].presence = ~case_offset;
6020  }
6021  }
6022 
6023  /* Size of the entire structure should be a multiple of its greatest
6024  * alignment. TODO: track overall alignment for real? */
6025  l->size = UPB_ALIGN_UP(l->size, 8);
6026 
6027  /* Sort fields by number. */
6030 }
6031 
6032 static char *strviewdup(symtab_addctx *ctx, upb_strview view) {
6033  return upb_strdup2(view.data, view.size, ctx->arena);
6034 }
6035 
6036 static bool streql2(const char *a, size_t n, const char *b) {
6037  return n == strlen(b) && memcmp(a, b, n) == 0;
6038 }
6039 
6040 static bool streql_view(upb_strview view, const char *b) {
6041  return streql2(view.data, view.size, b);
6042 }
6043 
6044 static const char *makefullname(symtab_addctx *ctx, const char *prefix,
6045  upb_strview name) {
6046  if (prefix) {
6047  /* ret = prefix + '.' + name; */
6048  size_t n = strlen(prefix);
6049  char *ret = symtab_alloc(ctx, n + name.size + 2);
6050  strcpy(ret, prefix);
6051  ret[n] = '.';
6052  memcpy(&ret[n + 1], name.data, name.size);
6053  ret[n + 1 + name.size] = '\0';
6054  return ret;
6055  } else {
6056  return strviewdup(ctx, name);
6057  }
6058 }
6059 
6061  int i;
6062  int synthetic_count = 0;
6063  upb_oneofdef *mutable_oneofs = (upb_oneofdef*)m->oneofs;
6064 
6065  for (i = 0; i < m->oneof_count; i++) {
6066  upb_oneofdef *o = &mutable_oneofs[i];
6067 
6068  if (o->synthetic && o->field_count != 1) {
6069  symtab_errf(ctx, "Synthetic oneofs must have one field, not %d: %s",
6070  o->field_count, upb_oneofdef_name(o));
6071  }
6072 
6073  if (o->synthetic) {
6074  synthetic_count++;
6075  } else if (synthetic_count != 0) {
6076  symtab_errf(ctx, "Synthetic oneofs must be after all other oneofs: %s",
6077  upb_oneofdef_name(o));
6078  }
6079 
6080  o->fields = symtab_alloc(ctx, sizeof(upb_fielddef *) * o->field_count);
6081  o->field_count = 0;
6082  }
6083 
6084  for (i = 0; i < m->field_count; i++) {
6085  const upb_fielddef *f = &m->fields[i];
6086  upb_oneofdef *o = (upb_oneofdef*)f->oneof;
6087  if (o) {
6088  o->fields[o->field_count++] = f;
6089  }
6090  }
6091 
6092  m->real_oneof_count = m->oneof_count - synthetic_count;
6093 }
6094 
6095 size_t getjsonname(const char *name, char *buf, size_t len) {
6096  size_t src, dst = 0;
6097  bool ucase_next = false;
6098 
6099 #define WRITE(byte) \
6100  ++dst; \
6101  if (dst < len) buf[dst - 1] = byte; \
6102  else if (dst == len) buf[dst - 1] = '\0'
6103 
6104  if (!name) {
6105  WRITE('\0');
6106  return 0;
6107  }
6108 
6109  /* Implement the transformation as described in the spec:
6110  * 1. upper case all letters after an underscore.
6111  * 2. remove all underscores.
6112  */
6113  for (src = 0; name[src]; src++) {
6114  if (name[src] == '_') {
6115  ucase_next = true;
6116  continue;
6117  }
6118 
6119  if (ucase_next) {
6120  WRITE(toupper(name[src]));
6121  ucase_next = false;
6122  } else {
6123  WRITE(name[src]);
6124  }
6125  }
6126 
6127  WRITE('\0');
6128  return dst;
6129 
6130 #undef WRITE
6131 }
6132 
6133 static char* makejsonname(symtab_addctx *ctx, const char* name) {
6134  size_t size = getjsonname(name, NULL, 0);
6135  char* json_name = symtab_alloc(ctx, size);
6136  getjsonname(name, json_name, size);
6137  return json_name;
6138 }
6139 
6140 static void symtab_add(symtab_addctx *ctx, const char *name, upb_value v) {
6141  if (upb_strtable_lookup(&ctx->symtab->syms, name, NULL)) {
6142  symtab_errf(ctx, "duplicate symbol '%s'", name);
6143  }
6144  size_t len = strlen(name);
6146  ctx->symtab->arena));
6147 }
6148 
6149 /* Given a symbol and the base symbol inside which it is defined, find the
6150  * symbol's definition in t. */
6151 static const void *symtab_resolve(symtab_addctx *ctx, const upb_fielddef *f,
6152  const char *base, upb_strview sym,
6153  upb_deftype_t type) {
6154  const upb_strtable *t = &ctx->symtab->syms;
6155  if(sym.size == 0) goto notfound;
6156  if(sym.data[0] == '.') {
6157  /* Symbols starting with '.' are absolute, so we do a single lookup.
6158  * Slice to omit the leading '.' */
6159  upb_value v;
6160  if (!upb_strtable_lookup2(t, sym.data + 1, sym.size - 1, &v)) {
6161  goto notfound;
6162  }
6163 
6164  const void *ret = unpack_def(v, type);
6165  if (!ret) {
6166  symtab_errf(ctx, "type mismatch when resolving field %s, name %s",
6167  f->full_name, sym.data);
6168  }
6169  return ret;
6170  } else {
6171  /* Remove components from base until we find an entry or run out.
6172  * TODO: This branch is totally broken, but currently not used. */
6173  (void)base;
6174  UPB_ASSERT(false);
6175  goto notfound;
6176  }
6177 
6178 notfound:
6179  symtab_errf(ctx, "couldn't resolve name '" UPB_STRVIEW_FORMAT "'",
6180  UPB_STRVIEW_ARGS(sym));
6181 }
6182 
6183 static void create_oneofdef(
6185  const google_protobuf_OneofDescriptorProto *oneof_proto) {
6186  upb_oneofdef *o;
6188  upb_value v;
6189 
6190  o = (upb_oneofdef*)&m->oneofs[m->oneof_count++];
6191  o->parent = m;
6192  o->full_name = makefullname(ctx, m->full_name, name);
6193  o->field_count = 0;
6194  o->synthetic = false;
6195 
6197  symtab_add(ctx, o->full_name, v);
6198  CHK_OOM(upb_strtable_insert(&m->ntof, name.data, name.size, v, ctx->arena));
6199 
6200  CHK_OOM(upb_inttable_init(&o->itof, ctx->arena));
6201  CHK_OOM(upb_strtable_init(&o->ntof, 4, ctx->arena));
6202 }
6203 
6204 static str_t *newstr(symtab_addctx *ctx, const char *data, size_t len) {
6205  str_t *ret = symtab_alloc(ctx, sizeof(*ret) + len);
6206  if (!ret) return NULL;
6207  ret->len = len;
6208  if (len) memcpy(ret->str, data, len);
6209  ret->str[len] = '\0';
6210  return ret;
6211 }
6212 
6213 static void parse_default(symtab_addctx *ctx, const char *str, size_t len,
6214  upb_fielddef *f) {
6215  char *end;
6216  char nullz[64];
6217  errno = 0;
6218 
6219  switch (upb_fielddef_type(f)) {
6220  case UPB_TYPE_INT32:
6221  case UPB_TYPE_INT64:
6222  case UPB_TYPE_UINT32:
6223  case UPB_TYPE_UINT64:
6224  case UPB_TYPE_DOUBLE:
6225  case UPB_TYPE_FLOAT:
6226  /* Standard C number parsing functions expect null-terminated strings. */
6227  if (len >= sizeof(nullz) - 1) {
6228  symtab_errf(ctx, "Default too long: %.*s", (int)len, str);
6229  }
6230  memcpy(nullz, str, len);
6231  nullz[len] = '\0';
6232  str = nullz;
6233  break;
6234  default:
6235  break;
6236  }
6237 
6238  switch (upb_fielddef_type(f)) {
6239  case UPB_TYPE_INT32: {
6240  long val = strtol(str, &end, 0);
6241  if (val > INT32_MAX || val < INT32_MIN || errno == ERANGE || *end) {
6242  goto invalid;
6243  }
6244  f->defaultval.sint = val;
6245  break;
6246  }
6247  case UPB_TYPE_ENUM: {
6248  const upb_enumdef *e = f->sub.enumdef;
6249  int32_t val;
6250  if (!upb_enumdef_ntoi(e, str, len, &val)) {
6251  goto invalid;
6252  }
6253  f->defaultval.sint = val;
6254  break;
6255  }
6256  case UPB_TYPE_INT64: {
6257  long long val = strtoll(str, &end, 0);
6258  if (val > INT64_MAX || val < INT64_MIN || errno == ERANGE || *end) {
6259  goto invalid;
6260  }
6261  f->defaultval.sint = val;
6262  break;
6263  }
6264  case UPB_TYPE_UINT32: {
6265  unsigned long val = strtoul(str, &end, 0);
6266  if (val > UINT32_MAX || errno == ERANGE || *end) {
6267  goto invalid;
6268  }
6269  f->defaultval.uint = val;
6270  break;
6271  }
6272  case UPB_TYPE_UINT64: {
6273  unsigned long long val = strtoull(str, &end, 0);
6274  if (val > UINT64_MAX || errno == ERANGE || *end) {
6275  goto invalid;
6276  }
6277  f->defaultval.uint = val;
6278  break;
6279  }
6280  case UPB_TYPE_DOUBLE: {
6281  double val = strtod(str, &end);
6282  if (errno == ERANGE || *end) {
6283  goto invalid;
6284  }
6285  f->defaultval.dbl = val;
6286  break;
6287  }
6288  case UPB_TYPE_FLOAT: {
6289  float val = strtof(str, &end);
6290  if (errno == ERANGE || *end) {
6291  goto invalid;
6292  }
6293  f->defaultval.flt = val;
6294  break;
6295  }
6296  case UPB_TYPE_BOOL: {
6297  if (streql2(str, len, "false")) {
6298  f->defaultval.boolean = false;
6299  } else if (streql2(str, len, "true")) {
6300  f->defaultval.boolean = true;
6301  } else {
6302  }
6303  break;
6304  }
6305  case UPB_TYPE_STRING:
6306  f->defaultval.str = newstr(ctx, str, len);
6307  break;
6308  case UPB_TYPE_BYTES:
6309  /* XXX: need to interpret the C-escaped value. */
6310  f->defaultval.str = newstr(ctx, str, len);
6311  break;
6312  case UPB_TYPE_MESSAGE:
6313  /* Should not have a default value. */
6314  symtab_errf(ctx, "Message should not have a default (%s)",
6316  }
6317 
6318  return;
6319 
6320 invalid:
6321  symtab_errf(ctx, "Invalid default '%.*s' for field %s", (int)len, str,
6323 }
6324 
6326  switch (upb_fielddef_type(f)) {
6327  case UPB_TYPE_INT32:
6328  case UPB_TYPE_INT64:
6329  case UPB_TYPE_ENUM:
6330  f->defaultval.sint = 0;
6331  break;
6332  case UPB_TYPE_UINT64:
6333  case UPB_TYPE_UINT32:
6334  f->defaultval.uint = 0;
6335  break;
6336  case UPB_TYPE_DOUBLE:
6337  case UPB_TYPE_FLOAT:
6338  f->defaultval.dbl = 0;
6339  break;
6340  case UPB_TYPE_STRING:
6341  case UPB_TYPE_BYTES:
6342  f->defaultval.str = newstr(ctx, NULL, 0);
6343  break;
6344  case UPB_TYPE_BOOL:
6345  f->defaultval.boolean = false;
6346  break;
6347  case UPB_TYPE_MESSAGE:
6348  break;
6349  }
6350 }
6351 
6352 static void create_fielddef(
6353  symtab_addctx *ctx, const char *prefix, upb_msgdef *m,
6354  const google_protobuf_FieldDescriptorProto *field_proto) {
6355  upb_fielddef *f;
6357  upb_strview name;
6358  const char *full_name;
6359  const char *json_name;
6360  const char *shortname;
6361  uint32_t field_number;
6362 
6364  symtab_errf(ctx, "field has no name (%s)", upb_msgdef_fullname(m));
6365  }
6366 
6368  check_ident(ctx, name, false);
6369  full_name = makefullname(ctx, prefix, name);
6370  shortname = shortdefname(full_name);
6371 
6373  json_name = strviewdup(
6375  } else {
6376  json_name = makejsonname(ctx, shortname);
6377  }
6378 
6379  field_number = google_protobuf_FieldDescriptorProto_number(field_proto);
6380 
6381  if (field_number == 0 || field_number > UPB_MAX_FIELDNUMBER) {
6382  symtab_errf(ctx, "invalid field number (%u)", field_number);
6383  }
6384 
6385  if (m) {
6386  /* direct message field. */
6387  upb_value v, field_v, json_v;
6388  size_t json_size;
6389 
6390  f = (upb_fielddef*)&m->fields[m->field_count];
6391  f->index_ = m->field_count++;
6392  f->msgdef = m;
6393  f->is_extension_ = false;
6394 
6395  if (upb_strtable_lookup(&m->ntof, shortname, NULL)) {
6396  symtab_errf(ctx, "duplicate field name (%s)", shortname);
6397  }
6398 
6399  if (upb_strtable_lookup(&m->ntof, json_name, NULL)) {
6400  symtab_errf(ctx, "duplicate json_name (%s)", json_name);
6401  }
6402 
6403  if (upb_inttable_lookup(&m->itof, field_number, NULL)) {
6404  symtab_errf(ctx, "duplicate field number (%u)", field_number);
6405  }
6406 
6407  field_v = pack_def(f, UPB_DEFTYPE_FIELD);
6409  v = upb_value_constptr(f);
6410  json_size = strlen(json_name);
6411 
6412  CHK_OOM(upb_strtable_insert(&m->ntof, name.data, name.size, field_v,
6413  ctx->arena));
6414  CHK_OOM(upb_inttable_insert(&m->itof, field_number, v, ctx->arena));
6415 
6416  if (strcmp(shortname, json_name) != 0) {
6417  upb_strtable_insert(&m->ntof, json_name, json_size, json_v, ctx->arena);
6418  }
6419 
6420  if (ctx->layouts) {
6421  const upb_msglayout_field *fields = m->layout->fields;
6422  int count = m->layout->field_count;
6423  bool found = false;
6424  int i;
6425  for (i = 0; i < count; i++) {
6426  if (fields[i].number == field_number) {
6427  f->layout_index = i;
6428  found = true;
6429  break;
6430  }
6431  }
6432  UPB_ASSERT(found);
6433  }
6434  } else {
6435  /* extension field. */
6436  f = (upb_fielddef*)&ctx->file->exts[ctx->file->ext_count++];
6437  f->is_extension_ = true;
6438  symtab_add(ctx, full_name, pack_def(f, UPB_DEFTYPE_FIELD));
6439  }
6440 
6441  f->full_name = full_name;
6442  f->json_name = json_name;
6443  f->file = ctx->file;
6444  f->type_ = (int)google_protobuf_FieldDescriptorProto_type(field_proto);
6445  f->label_ = (int)google_protobuf_FieldDescriptorProto_label(field_proto);
6446  f->number_ = field_number;
6447  f->oneof = NULL;
6448  f->proto3_optional_ =
6450 
6451  /* We can't resolve the subdef or (in the case of extensions) the containing
6452  * message yet, because it may not have been defined yet. We stash a pointer
6453  * to the field_proto until later when we can properly resolve it. */
6454  f->sub.unresolved = field_proto;
6455 
6456  if (f->label_ == UPB_LABEL_REQUIRED && f->file->syntax == UPB_SYNTAX_PROTO3) {
6457  symtab_errf(ctx, "proto3 fields cannot be required (%s)", f->full_name);
6458  }
6459 
6461  int oneof_index =
6463  upb_oneofdef *oneof;
6464  upb_value v = upb_value_constptr(f);
6465 
6467  symtab_errf(ctx, "fields in oneof must have OPTIONAL label (%s)",
6468  f->full_name);
6469  }
6470 
6471  if (!m) {
6472  symtab_errf(ctx, "oneof_index provided for extension field (%s)",
6473  f->full_name);
6474  }
6475 
6476  if (oneof_index >= m->oneof_count) {
6477  symtab_errf(ctx, "oneof_index out of range (%s)", f->full_name);
6478  }
6479 
6480  oneof = (upb_oneofdef *)&m->oneofs[oneof_index];
6481  f->oneof = oneof;
6482 
6483  oneof->field_count++;
6484  if (f->proto3_optional_) {
6485  oneof->synthetic = true;
6486  }
6487  CHK_OOM(upb_inttable_insert(&oneof->itof, f->number_, v, ctx->arena));
6488  CHK_OOM(
6489  upb_strtable_insert(&oneof->ntof, name.data, name.size, v, ctx->arena));
6490  } else {
6491  f->oneof = NULL;
6492  if (f->proto3_optional_) {
6493  symtab_errf(ctx, "field with proto3_optional was not in a oneof (%s)",
6494  f->full_name);
6495  }
6496  }
6497 
6500 
6503  } else {
6504  /* Repeated fields default to packed for proto3 only. */
6505  f->packed_ = upb_fielddef_isprimitive(f) &&
6506  f->label_ == UPB_LABEL_REPEATED && f->file->syntax == UPB_SYNTAX_PROTO3;
6507  }
6508 
6509  if (options) {
6511  } else {
6512  f->lazy_ = false;
6513  }
6514 }
6515 
6516 static void create_enumdef(
6517  symtab_addctx *ctx, const char *prefix,
6518  const google_protobuf_EnumDescriptorProto *enum_proto) {
6519  upb_enumdef *e;
6521  upb_strview name;
6522  size_t i, n;
6523 
6525  check_ident(ctx, name, false);
6526 
6527  e = (upb_enumdef*)&ctx->file->enums[ctx->file->enum_count++];
6528  e->full_name = makefullname(ctx, prefix, name);
6529  symtab_add(ctx, e->full_name, pack_def(e, UPB_DEFTYPE_ENUM));
6530 
6532  CHK_OOM(upb_strtable_init(&e->ntoi, n, ctx->arena));
6533  CHK_OOM(upb_inttable_init(&e->iton, ctx->arena));
6534 
6535  e->file = ctx->file;
6536  e->defaultval = 0;
6537 
6538  if (n == 0) {
6539  symtab_errf(ctx, "enums must contain at least one value (%s)",
6540  e->full_name);
6541  }
6542 
6543  for (i = 0; i < n; i++) {
6546  char *name2 = strviewdup(ctx, name);
6548  upb_value v = upb_value_int32(num);
6549 
6550  if (i == 0 && e->file->syntax == UPB_SYNTAX_PROTO3 && num != 0) {
6551  symtab_errf(ctx, "for proto3, the first enum value must be zero (%s)",
6552  e->full_name);
6553  }
6554 
6555  if (upb_strtable_lookup(&e->ntoi, name2, NULL)) {
6556  symtab_errf(ctx, "duplicate enum label '%s'", name2);
6557  }
6558 
6559  CHK_OOM(name2)
6560  CHK_OOM(upb_strtable_insert(&e->ntoi, name2, strlen(name2), v, ctx->arena));
6561 
6562  if (!upb_inttable_lookup(&e->iton, num, NULL)) {
6563  upb_value v = upb_value_cstr(name2);
6564  CHK_OOM(upb_inttable_insert(&e->iton, num, v, ctx->arena));
6565  }
6566  }
6567 
6568  upb_inttable_compact(&e->iton, ctx->arena);
6569 }
6570 
6571 static void create_msgdef(symtab_addctx *ctx, const char *prefix,
6572  const google_protobuf_DescriptorProto *msg_proto) {
6573  upb_msgdef *m;
6575  const google_protobuf_OneofDescriptorProto *const *oneofs;
6577  const google_protobuf_EnumDescriptorProto *const *enums;
6578  const google_protobuf_DescriptorProto *const *msgs;
6579  size_t i, n_oneof, n_field, n;
6580  upb_strview name;
6581 
6583  check_ident(ctx, name, false);
6584 
6585  m = (upb_msgdef*)&ctx->file->msgs[ctx->file->msg_count++];
6586  m->full_name = makefullname(ctx, prefix, name);
6587  symtab_add(ctx, m->full_name, pack_def(m, UPB_DEFTYPE_MSG));
6588 
6589  oneofs = google_protobuf_DescriptorProto_oneof_decl(msg_proto, &n_oneof);
6590  fields = google_protobuf_DescriptorProto_field(msg_proto, &n_field);
6591 
6592  CHK_OOM(upb_inttable_init(&m->itof, ctx->arena));
6593  CHK_OOM(upb_strtable_init(&m->ntof, n_oneof + n_field, ctx->arena));
6594 
6595  m->file = ctx->file;
6596  m->map_entry = false;
6597 
6599 
6600  if (options) {
6602  }
6603 
6604  if (ctx->layouts) {
6605  m->layout = *ctx->layouts;
6606  ctx->layouts++;
6607  } else {
6608  /* Allocate now (to allow cross-linking), populate later. */
6609  m->layout = symtab_alloc(
6610  ctx, sizeof(*m->layout) + sizeof(_upb_fasttable_entry));
6611  }
6612 
6613  m->oneof_count = 0;
6614  m->oneofs = symtab_alloc(ctx, sizeof(*m->oneofs) * n_oneof);
6615  for (i = 0; i < n_oneof; i++) {
6616  create_oneofdef(ctx, m, oneofs[i]);
6617  }
6618 
6619  m->field_count = 0;
6620  m->fields = symtab_alloc(ctx, sizeof(*m->fields) * n_field);
6621  for (i = 0; i < n_field; i++) {
6622  create_fielddef(ctx, m->full_name, m, fields[i]);
6623  }
6624 
6625  finalize_oneofs(ctx, m);
6627  upb_inttable_compact(&m->itof, ctx->arena);
6628 
6629  /* This message is built. Now build nested messages and enums. */
6630 
6631  enums = google_protobuf_DescriptorProto_enum_type(msg_proto, &n);
6632  for (i = 0; i < n; i++) {
6633  create_enumdef(ctx, m->full_name, enums[i]);
6634  }
6635 
6636  msgs = google_protobuf_DescriptorProto_nested_type(msg_proto, &n);
6637  for (i = 0; i < n; i++) {
6638  create_msgdef(ctx, m->full_name, msgs[i]);
6639  }
6640 }
6641 
6643  upb_filedef *file) {
6644  const google_protobuf_DescriptorProto *const *msgs;
6645  size_t i, n;
6646 
6647  file->msg_count++;
6648 
6649  msgs = google_protobuf_DescriptorProto_nested_type(msg_proto, &n);
6650  for (i = 0; i < n; i++) {
6651  count_types_in_msg(msgs[i], file);
6652  }
6653 
6655  file->enum_count += n;
6656 
6658  file->ext_count += n;
6659 }
6660 
6662  const google_protobuf_FileDescriptorProto *file_proto,
6663  upb_filedef *file) {
6664  const google_protobuf_DescriptorProto *const *msgs;
6665  size_t i, n;
6666 
6668  for (i = 0; i < n; i++) {
6669  count_types_in_msg(msgs[i], file);
6670  }
6671 
6673  file->enum_count += n;
6674 
6676  file->ext_count += n;
6677 }
6678 
6679 static void resolve_fielddef(symtab_addctx *ctx, const char *prefix,
6680  upb_fielddef *f) {
6681  upb_strview name;
6682  const google_protobuf_FieldDescriptorProto *field_proto = f->sub.unresolved;
6683 
6684  if (f->is_extension_) {
6686  symtab_errf(ctx, "extension for field '%s' had no extendee",
6687  f->full_name);
6688  }
6689 
6691  f->msgdef = symtab_resolve(ctx, f, prefix, name, UPB_DEFTYPE_MSG);
6692  }
6693 
6694  if ((upb_fielddef_issubmsg(f) || f->type_ == UPB_DESCRIPTOR_TYPE_ENUM) &&
6696  symtab_errf(ctx, "field '%s' is missing type name", f->full_name);
6697  }
6698 
6700 
6701  if (upb_fielddef_issubmsg(f)) {
6702  f->sub.msgdef = symtab_resolve(ctx, f, prefix, name, UPB_DEFTYPE_MSG);
6703  } else if (f->type_ == UPB_DESCRIPTOR_TYPE_ENUM) {
6704  f->sub.enumdef = symtab_resolve(ctx, f, prefix, name, UPB_DEFTYPE_ENUM);
6705  }
6706 
6707  /* Have to delay resolving of the default value until now because of the enum
6708  * case, since enum defaults are specified with a label. */
6710  upb_strview defaultval =
6712 
6713  if (f->file->syntax == UPB_SYNTAX_PROTO3) {
6714  symtab_errf(ctx, "proto3 fields cannot have explicit defaults (%s)",
6715  f->full_name);
6716  }
6717 
6718  if (upb_fielddef_issubmsg(f)) {
6719  symtab_errf(ctx, "message fields cannot have explicit defaults (%s)",
6720  f->full_name);
6721  }
6722 
6723  parse_default(ctx, defaultval.data, defaultval.size, f);
6724  } else {
6726  }
6727 }
6728 
6729 static void build_filedef(
6731  const google_protobuf_FileDescriptorProto *file_proto) {
6732  const google_protobuf_FileOptions *file_options_proto;
6733  const google_protobuf_DescriptorProto *const *msgs;
6734  const google_protobuf_EnumDescriptorProto *const *enums;
6735  const google_protobuf_FieldDescriptorProto *const *exts;
6736  const upb_strview* strs;
6737  size_t i, n;
6738 
6739  file->symtab = ctx->symtab;
6740 
6741  /* One pass to count and allocate. */
6742  file->msg_count = 0;
6743  file->enum_count = 0;
6744  file->ext_count = 0;
6745  count_types_in_file(file_proto, file);
6746  file->msgs = symtab_alloc(ctx, sizeof(*file->msgs) * file->msg_count);
6747  file->enums = symtab_alloc(ctx, sizeof(*file->enums) * file->enum_count);
6748  file->exts = symtab_alloc(ctx, sizeof(*file->exts) * file->ext_count);
6749 
6750  /* In the second pass we increment these as defs are added. */
6751  file->msg_count = 0;
6752  file->enum_count = 0;
6753  file->ext_count = 0;
6754 
6756  symtab_errf(ctx, "File has no name");
6757  }
6758 
6759  file->name =
6761  file->phpprefix = NULL;
6762  file->phpnamespace = NULL;
6763 
6765  upb_strview package =
6766  google_protobuf_FileDescriptorProto_package(file_proto);
6767  check_ident(ctx, package, true);
6768  file->package = strviewdup(ctx, package);
6769  } else {
6770  file->package = NULL;
6771  }
6772 
6776 
6777  if (streql_view(syntax, "proto2")) {
6778  file->syntax = UPB_SYNTAX_PROTO2;
6779  } else if (streql_view(syntax, "proto3")) {
6780  file->syntax = UPB_SYNTAX_PROTO3;
6781  } else {
6782  symtab_errf(ctx, "Invalid syntax '" UPB_STRVIEW_FORMAT "'",
6784  }
6785  } else {
6786  file->syntax = UPB_SYNTAX_PROTO2;
6787  }
6788 
6789  /* Read options. */
6790  file_options_proto = google_protobuf_FileDescriptorProto_options(file_proto);
6791  if (file_options_proto) {
6792  if (google_protobuf_FileOptions_has_php_class_prefix(file_options_proto)) {
6793  file->phpprefix = strviewdup(
6794  ctx,
6795  google_protobuf_FileOptions_php_class_prefix(file_options_proto));
6796  }
6797  if (google_protobuf_FileOptions_has_php_namespace(file_options_proto)) {
6798  file->phpnamespace = strviewdup(
6799  ctx, google_protobuf_FileOptions_php_namespace(file_options_proto));
6800  }
6801  }
6802 
6803  /* Verify dependencies. */
6805  file->deps = symtab_alloc(ctx, sizeof(*file->deps) * n);
6806 
6807  for (i = 0; i < n; i++) {
6808  upb_strview dep_name = strs[i];
6809  upb_value v;
6810  if (!upb_strtable_lookup2(&ctx->symtab->files, dep_name.data,
6811  dep_name.size, &v)) {
6812  symtab_errf(ctx,
6813  "Depends on file '" UPB_STRVIEW_FORMAT
6814  "', but it has not been loaded",
6815  UPB_STRVIEW_ARGS(dep_name));
6816  }
6817  file->deps[i] = upb_value_getconstptr(v);
6818  }
6819 
6820  /* Create messages. */
6822  for (i = 0; i < n; i++) {
6823  create_msgdef(ctx, file->package, msgs[i]);
6824  }
6825 
6826  /* Create enums. */
6827  enums = google_protobuf_FileDescriptorProto_enum_type(file_proto, &n);
6828  for (i = 0; i < n; i++) {
6829  create_enumdef(ctx, file->package, enums[i]);
6830  }
6831 
6832  /* Create extensions. */
6833  exts = google_protobuf_FileDescriptorProto_extension(file_proto, &n);
6834  file->exts = symtab_alloc(ctx, sizeof(*file->exts) * n);
6835  for (i = 0; i < n; i++) {
6836  create_fielddef(ctx, file->package, NULL, exts[i]);
6837  }
6838 
6839  /* Now that all names are in the table, build layouts and resolve refs. */
6840  for (i = 0; i < (size_t)file->ext_count; i++) {
6841  resolve_fielddef(ctx, file->package, (upb_fielddef*)&file->exts[i]);
6842  }
6843 
6844  for (i = 0; i < (size_t)file->msg_count; i++) {
6845  const upb_msgdef *m = &file->msgs[i];
6846  int j;
6847  for (j = 0; j < m->field_count; j++) {
6848  resolve_fielddef(ctx, m->full_name, (upb_fielddef*)&m->fields[j]);
6849  }
6850  }
6851 
6852  if (!ctx->layouts) {
6853  for (i = 0; i < (size_t)file->msg_count; i++) {
6854  const upb_msgdef *m = &file->msgs[i];
6855  make_layout(ctx, m);
6856  }
6857  }
6858 }
6859 
6861  int i;
6862  for (i = 0; i < file->msg_count; i++) {
6863  const char *name = file->msgs[i].full_name;
6864  upb_strtable_remove(&s->syms, name, strlen(name), NULL);
6865  }
6866  for (i = 0; i < file->enum_count; i++) {
6867  const char *name = file->enums[i].full_name;
6868  upb_strtable_remove(&s->syms, name, strlen(name), NULL);
6869  }
6870  for (i = 0; i < file->ext_count; i++) {
6871  const char *name = file->exts[i].full_name;
6872  upb_strtable_remove(&s->syms, name, strlen(name), NULL);
6873  }
6874 }
6875 
6877  upb_symtab *s, const google_protobuf_FileDescriptorProto *file_proto,
6878  const upb_msglayout **layouts, upb_status *status) {
6881 
6882  if (upb_strtable_lookup2(&s->files, name.data, name.size, NULL)) {
6883  upb_status_seterrf(status, "duplicate file name (%.*s)",
6885  return NULL;
6886  }
6887 
6888  ctx.symtab = s;
6889  ctx.layouts = layouts;
6890  ctx.status = status;
6891  ctx.file = NULL;
6892  ctx.arena = upb_arena_new();
6893 
6894  if (!ctx.arena) {
6896  return NULL;
6897  }
6898 
6899  if (UPB_UNLIKELY(UPB_SETJMP(ctx.err))) {
6901  if (ctx.file) {
6902  remove_filedef(s, ctx.file);
6903  ctx.file = NULL;
6904  }
6905  } else {
6906  ctx.file = symtab_alloc(&ctx, sizeof(*ctx.file));
6907  build_filedef(&ctx, ctx.file, file_proto);
6908  upb_strtable_insert(&s->files, name.data, name.size,
6909  upb_value_constptr(ctx.file), ctx.arena);
6911  upb_arena_fuse(s->arena, ctx.arena);
6912  }
6913 
6915  return ctx.file;
6916 }
6917 
6919  upb_symtab *s, const google_protobuf_FileDescriptorProto *file_proto,
6920  upb_status *status) {
6921  return _upb_symtab_addfile(s, file_proto, NULL, status);
6922 }
6923 
6924 /* Include here since we want most of this file to be stdio-free. */
6925 #include <stdio.h>
6926 
6928  /* Since this function should never fail (it would indicate a bug in upb) we
6929  * print errors to stderr instead of returning error status to the user. */
6930  upb_def_init **deps = init->deps;
6932  upb_arena *arena;
6934 
6936 
6937  if (upb_strtable_lookup(&s->files, init->filename, NULL)) {
6938  return true;
6939  }
6940 
6941  arena = upb_arena_new();
6942 
6943  for (; *deps; deps++) {
6944  if (!_upb_symtab_loaddefinit(s, *deps)) goto err;
6945  }
6946 
6948  init->descriptor.data, init->descriptor.size, NULL, UPB_DECODE_ALIAS,
6949  arena);
6950  s->bytes_loaded += init->descriptor.size;
6951 
6952  if (!file) {
6954  &status,
6955  "Failed to parse compiled-in descriptor for file '%s'. This should "
6956  "never happen.",
6957  init->filename);
6958  goto err;
6959  }
6960 
6961  if (!_upb_symtab_addfile(s, file, init->layouts, &status)) goto err;
6962 
6964  return true;
6965 
6966 err:
6967  fprintf(stderr, "Error loading compiled-in descriptor: %s\n",
6970  return false;
6971 }
6972 
6974  return s->bytes_loaded;
6975 }
6976 
6978  return s->arena;
6979 }
6980 
6981 #undef CHK_OOM
6982 
6985 #include <string.h>
6986 
6987 
6988 static size_t get_field_size(const upb_msglayout_field *f) {
6989  static unsigned char sizes[] = {
6990  0,/* 0 */
6991  8, /* UPB_DESCRIPTOR_TYPE_DOUBLE */
6992  4, /* UPB_DESCRIPTOR_TYPE_FLOAT */
6993  8, /* UPB_DESCRIPTOR_TYPE_INT64 */
6994  8, /* UPB_DESCRIPTOR_TYPE_UINT64 */
6995  4, /* UPB_DESCRIPTOR_TYPE_INT32 */
6996  8, /* UPB_DESCRIPTOR_TYPE_FIXED64 */
6997  4, /* UPB_DESCRIPTOR_TYPE_FIXED32 */
6998  1, /* UPB_DESCRIPTOR_TYPE_BOOL */
6999  sizeof(upb_strview), /* UPB_DESCRIPTOR_TYPE_STRING */
7000  sizeof(void*), /* UPB_DESCRIPTOR_TYPE_GROUP */
7001  sizeof(void*), /* UPB_DESCRIPTOR_TYPE_MESSAGE */
7002  sizeof(upb_strview), /* UPB_DESCRIPTOR_TYPE_BYTES */
7003  4, /* UPB_DESCRIPTOR_TYPE_UINT32 */
7004  4, /* UPB_DESCRIPTOR_TYPE_ENUM */
7005  4, /* UPB_DESCRIPTOR_TYPE_SFIXED32 */
7006  8, /* UPB_DESCRIPTOR_TYPE_SFIXED64 */
7007  4, /* UPB_DESCRIPTOR_TYPE_SINT32 */
7008  8, /* UPB_DESCRIPTOR_TYPE_SINT64 */
7009  };
7010  return _upb_repeated_or_map(f) ? sizeof(void *) : sizes[f->descriptortype];
7011 }
7012 
7013 /* Strings/bytes are special-cased in maps. */
7014 static char _upb_fieldtype_to_mapsize[12] = {
7015  0,
7016  1, /* UPB_TYPE_BOOL */
7017  4, /* UPB_TYPE_FLOAT */
7018  4, /* UPB_TYPE_INT32 */
7019  4, /* UPB_TYPE_UINT32 */
7020  4, /* UPB_TYPE_ENUM */
7021  sizeof(void*), /* UPB_TYPE_MESSAGE */
7022  8, /* UPB_TYPE_DOUBLE */
7023  8, /* UPB_TYPE_INT64 */
7024  8, /* UPB_TYPE_UINT64 */
7025  0, /* UPB_TYPE_STRING */
7026  0, /* UPB_TYPE_BYTES */
7027 };
7028 
7029 static const char _upb_fieldtype_to_sizelg2[12] = {
7030  0,
7031  0, /* UPB_TYPE_BOOL */
7032  2, /* UPB_TYPE_FLOAT */
7033  2, /* UPB_TYPE_INT32 */
7034  2, /* UPB_TYPE_UINT32 */
7035  2, /* UPB_TYPE_ENUM */
7036  UPB_SIZE(2, 3), /* UPB_TYPE_MESSAGE */
7037  3, /* UPB_TYPE_DOUBLE */
7038  3, /* UPB_TYPE_INT64 */
7039  3, /* UPB_TYPE_UINT64 */
7040  UPB_SIZE(3, 4), /* UPB_TYPE_STRING */
7041  UPB_SIZE(3, 4), /* UPB_TYPE_BYTES */
7042 };
7043 
7047  return _upb_msg_new(upb_msgdef_layout(m), a);
7048 }
7049 
7050 static bool in_oneof(const upb_msglayout_field *field) {
7051  return field->presence < 0;
7052 }
7053 
7056  const char *mem = UPB_PTR_AT(msg, field->offset, char);
7057  upb_msgval val = {0};
7058  memcpy(&val, mem, get_field_size(field));
7059  return val;
7060 }
7061 
7062 bool upb_msg_has(const upb_msg *msg, const upb_fielddef *f) {
7064  if (in_oneof(field)) {
7065  return _upb_getoneofcase_field(msg, field) == field->number;
7066  } else if (field->presence > 0) {
7067  return _upb_hasbit_field(msg, field);
7068  } else {
7069  UPB_ASSERT(field->descriptortype == UPB_DESCRIPTOR_TYPE_MESSAGE ||
7070  field->descriptortype == UPB_DESCRIPTOR_TYPE_GROUP);
7071  return _upb_msg_getraw(msg, f).msg_val != NULL;
7072  }
7073 }
7074 
7076  const upb_oneofdef *o) {
7077  const upb_fielddef *f = upb_oneofdef_field(o, 0);
7078  if (upb_oneofdef_issynthetic(o)) {
7080  return upb_msg_has(msg, f) ? f : NULL;
7081  } else {
7083  uint32_t oneof_case = _upb_getoneofcase_field(msg, field);
7084  f = oneof_case ? upb_oneofdef_itof(o, oneof_case) : NULL;
7085  UPB_ASSERT((f != NULL) == (oneof_case != 0));
7086  return f;
7087  }
7088 }
7089 
7092  return _upb_msg_getraw(msg, f);
7093  } else {
7094  return upb_fielddef_default(f);
7095  }
7096 }
7097 
7099  upb_arena *a) {
7102  char *mem = UPB_PTR_AT(msg, field->offset, char);
7103  bool wrong_oneof =
7105 
7106  memcpy(&ret, mem, sizeof(void*));
7107 
7108  if (a && (!ret.msg || wrong_oneof)) {
7109  if (upb_fielddef_ismap(f)) {
7110  const upb_msgdef *entry = upb_fielddef_msgsubdef(f);
7114  } else if (upb_fielddef_isseq(f)) {
7115  ret.array = upb_array_new(a, upb_fielddef_type(f));
7116  } else {
7119  }
7120 
7121  memcpy(mem, &ret, sizeof(void*));
7122 
7123  if (wrong_oneof) {
7124  *_upb_oneofcase_field(msg, field) = field->number;
7125  } else if (field->presence > 0) {
7127  }
7128  }
7129  return ret;
7130 }
7131 
7133  upb_arena *a) {
7135  char *mem = UPB_PTR_AT(msg, field->offset, char);
7136  UPB_UNUSED(a); /* We reserve the right to make set insert into a map. */
7137  memcpy(mem, &val, get_field_size(field));
7138  if (field->presence > 0) {
7140  } else if (in_oneof(field)) {
7141  *_upb_oneofcase_field(msg, field) = field->number;
7142  }
7143 }
7144 
7147  char *mem = UPB_PTR_AT(msg, field->offset, char);
7148 
7149  if (field->presence > 0) {
7151  } else if (in_oneof(field)) {
7152  uint32_t *oneof_case = _upb_oneofcase_field(msg, field);
7153  if (*oneof_case != field->number) return;
7154  *oneof_case = 0;
7155  }
7156 
7158 }
7159 
7162 }
7163 
7164 bool upb_msg_next(const upb_msg *msg, const upb_msgdef *m,
7165  const upb_symtab *ext_pool, const upb_fielddef **out_f,
7166  upb_msgval *out_val, size_t *iter) {
7167  int i = *iter;
7168  int n = upb_msgdef_fieldcount(m);
7169  const upb_msgval zero = {0};
7170  UPB_UNUSED(ext_pool);
7171  while (++i < n) {
7172  const upb_fielddef *f = upb_msgdef_field(m, i);
7173  upb_msgval val = _upb_msg_getraw(msg, f);
7174 
7175  /* Skip field if unset or empty. */
7176  if (upb_fielddef_haspresence(f)) {
7177  if (!upb_msg_has(msg, f)) continue;
7178  } else {
7179  upb_msgval test = val;
7181  /* Clear string pointer, only size matters (ptr could be non-NULL). */
7182  test.str_val.data = NULL;
7183  }
7184  /* Continue if NULL or 0. */
7185  if (memcmp(&test, &zero, sizeof(test)) == 0) continue;
7186 
7187  /* Continue on empty array or map. */
7188  if (upb_fielddef_ismap(f)) {
7189  if (upb_map_size(test.map_val) == 0) continue;
7190  } else if (upb_fielddef_isseq(f)) {
7191  if (upb_array_size(test.array_val) == 0) continue;
7192  }
7193  }
7194 
7195  *out_val = val;
7196  *out_f = f;
7197  *iter = i;
7198  return true;
7199  }
7200  *iter = i;
7201  return false;
7202 }
7203 
7205  size_t iter = UPB_MSG_BEGIN;
7206  const upb_fielddef *f;
7207  upb_msgval val;
7208  bool ret = true;
7209 
7210  if (--depth == 0) return false;
7211 
7213 
7214  while (upb_msg_next(msg, m, NULL /*ext_pool*/, &f, &val, &iter)) {
7215  const upb_msgdef *subm = upb_fielddef_msgsubdef(f);
7216  if (!subm) continue;
7217  if (upb_fielddef_ismap(f)) {
7218  const upb_fielddef *val_f = upb_msgdef_itof(subm, 2);
7219  const upb_msgdef *val_m = upb_fielddef_msgsubdef(val_f);
7220  upb_map *map = (upb_map*)val.map_val;
7221  size_t iter = UPB_MAP_BEGIN;
7222 
7223  if (!val_m) continue;
7224 
7225  while (upb_mapiter_next(map, &iter)) {
7226  upb_msgval map_val = upb_mapiter_value(map, iter);
7227  if (!_upb_msg_discardunknown((upb_msg*)map_val.msg_val, val_m, depth)) {
7228  ret = false;
7229  }
7230  }
7231  } else if (upb_fielddef_isseq(f)) {
7232  const upb_array *arr = val.array_val;
7233  size_t i, n = upb_array_size(arr);
7234  for (i = 0; i < n; i++) {
7235  upb_msgval elem = upb_array_get(arr, i);
7236  if (!_upb_msg_discardunknown((upb_msg*)elem.msg_val, subm, depth)) {
7237  ret = false;
7238  }
7239  }
7240  } else {
7241  if (!_upb_msg_discardunknown((upb_msg*)val.msg_val, subm, depth)) {
7242  ret = false;
7243  }
7244  }
7245  }
7246 
7247  return ret;
7248 }
7249 
7250 bool upb_msg_discardunknown(upb_msg *msg, const upb_msgdef *m, int maxdepth) {
7251  return _upb_msg_discardunknown(msg, m, maxdepth);
7252 }
7253 
7258 }
7259 
7260 size_t upb_array_size(const upb_array *arr) {
7261  return arr->len;
7262 }
7263 
7264 upb_msgval upb_array_get(const upb_array *arr, size_t i) {
7265  upb_msgval ret;
7266  const char* data = _upb_array_constptr(arr);
7267  int lg2 = arr->data & 7;
7268  UPB_ASSERT(i < arr->len);
7269  memcpy(&ret, data + (i << lg2), 1 << lg2);
7270  return ret;
7271 }
7272 
7273 void upb_array_set(upb_array *arr, size_t i, upb_msgval val) {
7274  char* data = _upb_array_ptr(arr);
7275  int lg2 = arr->data & 7;
7276  UPB_ASSERT(i < arr->len);
7277  memcpy(data + (i << lg2), &val, 1 << lg2);
7278 }
7279 
7281  if (!upb_array_resize(arr, arr->len + 1, arena)) {
7282  return false;
7283  }
7284  upb_array_set(arr, arr->len - 1, val);
7285  return true;
7286 }
7287 
7289  return _upb_array_resize(arr, size, arena);
7290 }
7291 
7298 }
7299 
7300 size_t upb_map_size(const upb_map *map) {
7301  return _upb_map_size(map);
7302 }
7303 
7305  return _upb_map_get(map, &key, map->key_size, val, map->val_size);
7306 }
7307 
7310 }
7311 
7313  upb_arena *arena) {
7314  return _upb_map_set(map, &key, map->key_size, &val, map->val_size, arena);
7315 }
7316 
7318  return _upb_map_delete(map, &key, map->key_size);
7319 }
7320 
7321 bool upb_mapiter_next(const upb_map *map, size_t *iter) {
7322  return _upb_map_next(map, iter);
7323 }
7324 
7325 bool upb_mapiter_done(const upb_map *map, size_t iter) {
7328  i.t = &map->table;
7329  i.index = iter;
7330  return upb_strtable_done(&i);
7331 }
7332 
7333 /* Returns the key and value for this entry of the map. */
7336  upb_msgval ret;
7337  i.t = &map->table;
7338  i.index = iter;
7340  return ret;
7341 }
7342 
7345  upb_msgval ret;
7346  i.t = &map->table;
7347  i.index = iter;
7349  return ret;
7350 }
7351 
7352 /* void upb_mapiter_setvalue(upb_map *map, size_t iter, upb_msgval value); */
7353 
7356 #include <errno.h>
7357 #include <float.h>
7358 #include <inttypes.h>
7359 #include <limits.h>
7360 #include <math.h>
7361 #include <setjmp.h>
7362 #include <stdlib.h>
7363 #include <string.h>
7364 
7365 
7366 /* Special header, must be included last. */
7367 
7368 typedef struct {
7369  const char *ptr, *end;
7370  upb_arena *arena; /* TODO: should we have a tmp arena for tmp data? */
7372  int depth;
7374  jmp_buf err;
7375  int line;
7376  const char *line_begin;
7377  bool is_first;
7378  int options;
7380 } jsondec;
7381 
7383 
7384 /* Forward declarations of mutually-recursive functions. */
7385 static void jsondec_wellknown(jsondec *d, upb_msg *msg, const upb_msgdef *m);
7386 static upb_msgval jsondec_value(jsondec *d, const upb_fielddef *f);
7387 static void jsondec_wellknownvalue(jsondec *d, upb_msg *msg,
7388  const upb_msgdef *m);
7389 static void jsondec_object(jsondec *d, upb_msg *msg, const upb_msgdef *m);
7390 
7391 static bool jsondec_streql(upb_strview str, const char *lit) {
7392  return str.size == strlen(lit) && memcmp(str.data, lit, str.size) == 0;
7393 }
7394 
7395 static bool jsondec_isnullvalue(const upb_fielddef *f) {
7396  return upb_fielddef_type(f) == UPB_TYPE_ENUM &&
7398  "google.protobuf.NullValue") == 0;
7399 }
7400 
7401 static bool jsondec_isvalue(const upb_fielddef *f) {
7402  return (upb_fielddef_type(f) == UPB_TYPE_MESSAGE &&
7406 }
7407 
7408 UPB_NORETURN static void jsondec_err(jsondec *d, const char *msg) {
7409  upb_status_seterrf(d->status, "Error parsing JSON @%d:%d: %s", d->line,
7410  (int)(d->ptr - d->line_begin), msg);
7411  UPB_LONGJMP(d->err, 1);
7412 }
7413 
7414 UPB_PRINTF(2, 3)
7415 UPB_NORETURN static void jsondec_errf(jsondec *d, const char *fmt, ...) {
7416  va_list argp;
7417  upb_status_seterrf(d->status, "Error parsing JSON @%d:%d: ", d->line,
7418  (int)(d->ptr - d->line_begin));
7419  va_start(argp, fmt);
7420  upb_status_vappenderrf(d->status, fmt, argp);
7421  va_end(argp);
7422  UPB_LONGJMP(d->err, 1);
7423 }
7424 
7425 static void jsondec_skipws(jsondec *d) {
7426  while (d->ptr != d->end) {
7427  switch (*d->ptr) {
7428  case '\n':
7429  d->line++;
7430  d->line_begin = d->ptr;
7431  /* Fallthrough. */
7432  case '\r':
7433  case '\t':
7434  case ' ':
7435  d->ptr++;
7436  break;
7437  default:
7438  return;
7439  }
7440  }
7441  jsondec_err(d, "Unexpected EOF");
7442 }
7443 
7444 static bool jsondec_tryparsech(jsondec *d, char ch) {
7445  if (d->ptr == d->end || *d->ptr != ch) return false;
7446  d->ptr++;
7447  return true;
7448 }
7449 
7450 static void jsondec_parselit(jsondec *d, const char *lit) {
7451  size_t avail = d->end - d->ptr;
7452  size_t len = strlen(lit);
7453  if (avail < len || memcmp(d->ptr, lit, len) != 0) {
7454  jsondec_errf(d, "Expected: '%s'", lit);
7455  }
7456  d->ptr += len;
7457 }
7458 
7459 static void jsondec_wsch(jsondec *d, char ch) {
7460  jsondec_skipws(d);
7461  if (!jsondec_tryparsech(d, ch)) {
7462  jsondec_errf(d, "Expected: '%c'", ch);
7463  }
7464 }
7465 
7466 static void jsondec_true(jsondec *d) { jsondec_parselit(d, "true"); }
7467 static void jsondec_false(jsondec *d) { jsondec_parselit(d, "false"); }
7468 static void jsondec_null(jsondec *d) { jsondec_parselit(d, "null"); }
7469 
7470 static void jsondec_entrysep(jsondec *d) {
7471  jsondec_skipws(d);
7472  jsondec_parselit(d, ":");
7473 }
7474 
7475 static int jsondec_rawpeek(jsondec *d) {
7476  switch (*d->ptr) {
7477  case '{':
7478  return JD_OBJECT;
7479  case '[':
7480  return JD_ARRAY;
7481  case '"':
7482  return JD_STRING;
7483  case '-':
7484  case '0':
7485  case '1':
7486  case '2':
7487  case '3':
7488  case '4':
7489  case '5':
7490  case '6':
7491  case '7':
7492  case '8':
7493  case '9':
7494  return JD_NUMBER;
7495  case 't':
7496  return JD_TRUE;
7497  case 'f':
7498  return JD_FALSE;
7499  case 'n':
7500  return JD_NULL;
7501  default:
7502  jsondec_errf(d, "Unexpected character: '%c'", *d->ptr);
7503  }
7504 }
7505 
7506 /* JSON object/array **********************************************************/
7507 
7508 /* These are used like so:
7509  *
7510  * jsondec_objstart(d);
7511  * while (jsondec_objnext(d)) {
7512  * ...
7513  * }
7514  * jsondec_objend(d) */
7515 
7516 static int jsondec_peek(jsondec *d) {
7517  jsondec_skipws(d);
7518  return jsondec_rawpeek(d);
7519 }
7520 
7521 static void jsondec_push(jsondec *d) {
7522  if (--d->depth < 0) {
7523  jsondec_err(d, "Recursion limit exceeded");
7524  }
7525  d->is_first = true;
7526 }
7527 
7528 static bool jsondec_seqnext(jsondec *d, char end_ch) {
7529  bool is_first = d->is_first;
7530  d->is_first = false;
7531  jsondec_skipws(d);
7532  if (*d->ptr == end_ch) return false;
7533  if (!is_first) jsondec_parselit(d, ",");
7534  return true;
7535 }
7536 
7537 static void jsondec_arrstart(jsondec *d) {
7538  jsondec_push(d);
7539  jsondec_wsch(d, '[');
7540 }
7541 
7542 static void jsondec_arrend(jsondec *d) {
7543  d->depth++;
7544  jsondec_wsch(d, ']');
7545 }
7546 
7547 static bool jsondec_arrnext(jsondec *d) {
7548  return jsondec_seqnext(d, ']');
7549 }
7550 
7551 static void jsondec_objstart(jsondec *d) {
7552  jsondec_push(d);
7553  jsondec_wsch(d, '{');
7554 }
7555 
7556 static void jsondec_objend(jsondec *d) {
7557  d->depth++;
7558  jsondec_wsch(d, '}');
7559 }
7560 
7561 static bool jsondec_objnext(jsondec *d) {
7562  if (!jsondec_seqnext(d, '}')) return false;
7563  if (jsondec_peek(d) != JD_STRING) {
7564  jsondec_err(d, "Object must start with string");
7565  }
7566  return true;
7567 }
7568 
7569 /* JSON number ****************************************************************/
7570 
7572  const char *start = d->ptr;
7573 
7574  while (d->ptr < d->end) {
7575  if (*d->ptr < '0' || *d->ptr > '9') {
7576  break;
7577  }
7578  d->ptr++;
7579  }
7580 
7581  return d->ptr != start;
7582 }
7583 
7585  if (!jsondec_tryskipdigits(d)) {
7586  jsondec_err(d, "Expected one or more digits");
7587  }
7588 }
7589 
7590 static double jsondec_number(jsondec *d) {
7591  const char *start = d->ptr;
7592 
7593  assert(jsondec_rawpeek(d) == JD_NUMBER);
7594 
7595  /* Skip over the syntax of a number, as specified by JSON. */
7596  if (*d->ptr == '-') d->ptr++;
7597 
7598  if (jsondec_tryparsech(d, '0')) {
7599  if (jsondec_tryskipdigits(d)) {
7600  jsondec_err(d, "number cannot have leading zero");
7601  }
7602  } else {
7604  }
7605 
7606  if (d->ptr == d->end) goto parse;
7607  if (jsondec_tryparsech(d, '.')) {
7609  }
7610  if (d->ptr == d->end) goto parse;
7611 
7612  if (*d->ptr == 'e' || *d->ptr == 'E') {
7613  d->ptr++;
7614  if (d->ptr == d->end) {
7615  jsondec_err(d, "Unexpected EOF in number");
7616  }
7617  if (*d->ptr == '+' || *d->ptr == '-') {
7618  d->ptr++;
7619  }
7621  }
7622 
7623 parse:
7624  /* Having verified the syntax of a JSON number, use strtod() to parse
7625  * (strtod() accepts a superset of JSON syntax). */
7626  errno = 0;
7627  {
7628  char* end;
7629  double val = strtod(start, &end);
7630  assert(end == d->ptr);
7631 
7632  /* Currently the min/max-val conformance tests fail if we check this. Does
7633  * this mean the conformance tests are wrong or strtod() is wrong, or
7634  * something else? Investigate further. */
7635  /*
7636  if (errno == ERANGE) {
7637  jsondec_err(d, "Number out of range");
7638  }
7639  */
7640 
7641  if (val > DBL_MAX || val < -DBL_MAX) {
7642  jsondec_err(d, "Number out of range");
7643  }
7644 
7645  return val;
7646  }
7647 }
7648 
7649 /* JSON string ****************************************************************/
7650 
7651 static char jsondec_escape(jsondec *d) {
7652  switch (*d->ptr++) {
7653  case '"':
7654  return '\"';
7655  case '\\':
7656  return '\\';
7657  case '/':
7658  return '/';
7659  case 'b':
7660  return '\b';
7661  case 'f':
7662  return '\f';
7663  case 'n':
7664  return '\n';
7665  case 'r':
7666  return '\r';
7667  case 't':
7668  return '\t';
7669  default:
7670  jsondec_err(d, "Invalid escape char");
7671  }
7672 }
7673 
7675  uint32_t cp = 0;
7676  const char *end;
7677 
7678  if (d->end - d->ptr < 4) {
7679  jsondec_err(d, "EOF inside string");
7680  }
7681 
7682  end = d->ptr + 4;
7683  while (d->ptr < end) {
7684  char ch = *d->ptr++;
7685  if (ch >= '0' && ch <= '9') {
7686  ch -= '0';
7687  } else if (ch >= 'a' && ch <= 'f') {
7688  ch = ch - 'a' + 10;
7689  } else if (ch >= 'A' && ch <= 'F') {
7690  ch = ch - 'A' + 10;
7691  } else {
7692  jsondec_err(d, "Invalid hex digit");
7693  }
7694  cp = (cp << 4) | ch;
7695  }
7696 
7697  return cp;
7698 }
7699 
7700 /* Parses a \uXXXX unicode escape (possibly a surrogate pair). */
7701 static size_t jsondec_unicode(jsondec *d, char* out) {
7703  if (cp >= 0xd800 && cp <= 0xdbff) {
7704  /* Surrogate pair: two 16-bit codepoints become a 32-bit codepoint. */
7705  uint32_t high = cp;
7706  uint32_t low;
7707  jsondec_parselit(d, "\\u");
7708  low = jsondec_codepoint(d);
7709  if (low < 0xdc00 || low > 0xdfff) {
7710  jsondec_err(d, "Invalid low surrogate");
7711  }
7712  cp = (high & 0x3ff) << 10;
7713  cp |= (low & 0x3ff);
7714  cp += 0x10000;
7715  } else if (cp >= 0xdc00 && cp <= 0xdfff) {
7716  jsondec_err(d, "Unpaired low surrogate");
7717  }
7718 
7719  /* Write to UTF-8 */
7720  if (cp <= 0x7f) {
7721  out[0] = cp;
7722  return 1;
7723  } else if (cp <= 0x07FF) {
7724  out[0] = ((cp >> 6) & 0x1F) | 0xC0;
7725  out[1] = ((cp >> 0) & 0x3F) | 0x80;
7726  return 2;
7727  } else if (cp <= 0xFFFF) {
7728  out[0] = ((cp >> 12) & 0x0F) | 0xE0;
7729  out[1] = ((cp >> 6) & 0x3F) | 0x80;
7730  out[2] = ((cp >> 0) & 0x3F) | 0x80;
7731  return 3;
7732  } else if (cp < 0x10FFFF) {
7733  out[0] = ((cp >> 18) & 0x07) | 0xF0;
7734  out[1] = ((cp >> 12) & 0x3f) | 0x80;
7735  out[2] = ((cp >> 6) & 0x3f) | 0x80;
7736  out[3] = ((cp >> 0) & 0x3f) | 0x80;
7737  return 4;
7738  } else {
7739  jsondec_err(d, "Invalid codepoint");
7740  }
7741 }
7742 
7743 static void jsondec_resize(jsondec *d, char **buf, char **end, char **buf_end) {
7744  size_t oldsize = *buf_end - *buf;
7745  size_t len = *end - *buf;
7746  size_t size = UPB_MAX(8, 2 * oldsize);
7747 
7748  *buf = upb_arena_realloc(d->arena, *buf, len, size);
7749  if (!*buf) jsondec_err(d, "Out of memory");
7750 
7751  *end = *buf + len;
7752  *buf_end = *buf + size;
7753 }
7754 
7756  char *buf = NULL;
7757  char *end = NULL;
7758  char *buf_end = NULL;
7759 
7760  jsondec_skipws(d);
7761 
7762  if (*d->ptr++ != '"') {
7763  jsondec_err(d, "Expected string");
7764  }
7765 
7766  while (d->ptr < d->end) {
7767  char ch = *d->ptr++;
7768 
7769  if (end == buf_end) {
7770  jsondec_resize(d, &buf, &end, &buf_end);
7771  }
7772 
7773  switch (ch) {
7774  case '"': {
7775  upb_strview ret;
7776  ret.data = buf;
7777  ret.size = end - buf;
7778  *end = '\0'; /* Needed for possible strtod(). */
7779  return ret;
7780  }
7781  case '\\':
7782  if (d->ptr == d->end) goto eof;
7783  if (*d->ptr == 'u') {
7784  d->ptr++;
7785  if (buf_end - end < 4) {
7786  /* Allow space for maximum-sized code point (4 bytes). */
7787  jsondec_resize(d, &buf, &end, &buf_end);
7788  }
7789  end += jsondec_unicode(d, end);
7790  } else {
7791  *end++ = jsondec_escape(d);
7792  }
7793  break;
7794  default:
7795  if ((unsigned char)*d->ptr < 0x20) {
7796  jsondec_err(d, "Invalid char in JSON string");
7797  }
7798  *end++ = ch;
7799  break;
7800  }
7801  }
7802 
7803 eof:
7804  jsondec_err(d, "EOF inside string");
7805 }
7806 
7807 static void jsondec_skipval(jsondec *d) {
7808  switch (jsondec_peek(d)) {
7809  case JD_OBJECT:
7811  while (jsondec_objnext(d)) {
7812  jsondec_string(d);
7814  jsondec_skipval(d);
7815  }
7816  jsondec_objend(d);
7817  break;
7818  case JD_ARRAY:
7820  while (jsondec_arrnext(d)) {
7821  jsondec_skipval(d);
7822  }
7823  jsondec_arrend(d);
7824  break;
7825  case JD_TRUE:
7826  jsondec_true(d);
7827  break;
7828  case JD_FALSE:
7829  jsondec_false(d);
7830  break;
7831  case JD_NULL:
7832  jsondec_null(d);
7833  break;
7834  case JD_STRING:
7835  jsondec_string(d);
7836  break;
7837  case JD_NUMBER:
7838  jsondec_number(d);
7839  break;
7840  }
7841 }
7842 
7843 /* Base64 decoding for bytes fields. ******************************************/
7844 
7845 static unsigned int jsondec_base64_tablelookup(const char ch) {
7846  /* Table includes the normal base64 chars plus the URL-safe variant. */
7847  const signed char table[256] = {
7848  -1, -1, -1, -1, -1, -1, -1,
7849  -1, -1, -1, -1, -1, -1, -1,
7850  -1, -1, -1, -1, -1, -1, -1,
7851  -1, -1, -1, -1, -1, -1, -1,
7852  -1, -1, -1, -1, -1, -1, -1,
7853  -1, -1, -1, -1, -1, -1, -1,
7854  -1, 62 /*+*/, -1, 62 /*-*/, -1, 63 /*/ */, 52 /*0*/,
7855  53 /*1*/, 54 /*2*/, 55 /*3*/, 56 /*4*/, 57 /*5*/, 58 /*6*/, 59 /*7*/,
7856  60 /*8*/, 61 /*9*/, -1, -1, -1, -1, -1,
7857  -1, -1, 0 /*A*/, 1 /*B*/, 2 /*C*/, 3 /*D*/, 4 /*E*/,
7858  5 /*F*/, 6 /*G*/, 07 /*H*/, 8 /*I*/, 9 /*J*/, 10 /*K*/, 11 /*L*/,
7859  12 /*M*/, 13 /*N*/, 14 /*O*/, 15 /*P*/, 16 /*Q*/, 17 /*R*/, 18 /*S*/,
7860  19 /*T*/, 20 /*U*/, 21 /*V*/, 22 /*W*/, 23 /*X*/, 24 /*Y*/, 25 /*Z*/,
7861  -1, -1, -1, -1, 63 /*_*/, -1, 26 /*a*/,
7862  27 /*b*/, 28 /*c*/, 29 /*d*/, 30 /*e*/, 31 /*f*/, 32 /*g*/, 33 /*h*/,
7863  34 /*i*/, 35 /*j*/, 36 /*k*/, 37 /*l*/, 38 /*m*/, 39 /*n*/, 40 /*o*/,
7864  41 /*p*/, 42 /*q*/, 43 /*r*/, 44 /*s*/, 45 /*t*/, 46 /*u*/, 47 /*v*/,
7865  48 /*w*/, 49 /*x*/, 50 /*y*/, 51 /*z*/, -1, -1, -1,
7866  -1, -1, -1, -1, -1, -1, -1,
7867  -1, -1, -1, -1, -1, -1, -1,
7868  -1, -1, -1, -1, -1, -1, -1,
7869  -1, -1, -1, -1, -1, -1, -1,
7870  -1, -1, -1, -1, -1, -1, -1,
7871  -1, -1, -1, -1, -1, -1, -1,
7872  -1, -1, -1, -1, -1, -1, -1,
7873  -1, -1, -1, -1, -1, -1, -1,
7874  -1, -1, -1, -1, -1, -1, -1,
7875  -1, -1, -1, -1, -1, -1, -1,
7876  -1, -1, -1, -1, -1, -1, -1,
7877  -1, -1, -1, -1, -1, -1, -1,
7878  -1, -1, -1, -1, -1, -1, -1,
7879  -1, -1, -1, -1, -1, -1, -1,
7880  -1, -1, -1, -1, -1, -1, -1,
7881  -1, -1, -1, -1, -1, -1, -1,
7882  -1, -1, -1, -1, -1, -1, -1,
7883  -1, -1, -1, -1, -1, -1, -1,
7884  -1, -1, -1, -1};
7885 
7886  /* Sign-extend return value so high bit will be set on any unexpected char. */
7887  return table[(unsigned)ch];
7888 }
7889 
7890 static char *jsondec_partialbase64(jsondec *d, const char *ptr, const char *end,
7891  char *out) {
7892  int32_t val = -1;
7893 
7894  switch (end - ptr) {
7895  case 2:
7896  val = jsondec_base64_tablelookup(ptr[0]) << 18 |
7897  jsondec_base64_tablelookup(ptr[1]) << 12;
7898  out[0] = val >> 16;
7899  out += 1;
7900  break;
7901  case 3:
7902  val = jsondec_base64_tablelookup(ptr[0]) << 18 |
7903  jsondec_base64_tablelookup(ptr[1]) << 12 |
7905  out[0] = val >> 16;
7906  out[1] = (val >> 8) & 0xff;
7907  out += 2;
7908  break;
7909  }
7910 
7911  if (val < 0) {
7912  jsondec_err(d, "Corrupt base64");
7913  }
7914 
7915  return out;
7916 }
7917 
7919  /* We decode in place. This is safe because this is a new buffer (not
7920  * aliasing the input) and because base64 decoding shrinks 4 bytes into 3. */
7921  char *out = (char*)str.data;
7922  const char *ptr = str.data;
7923  const char *end = ptr + str.size;
7924  const char *end4 = ptr + (str.size & -4); /* Round down to multiple of 4. */
7925 
7926  for (; ptr < end4; ptr += 4, out += 3) {
7927  int val = jsondec_base64_tablelookup(ptr[0]) << 18 |
7928  jsondec_base64_tablelookup(ptr[1]) << 12 |
7929  jsondec_base64_tablelookup(ptr[2]) << 6 |
7931 
7932  if (val < 0) {
7933  /* Junk chars or padding. Remove trailing padding, if any. */
7934  if (end - ptr == 4 && ptr[3] == '=') {
7935  if (ptr[2] == '=') {
7936  end -= 2;
7937  } else {
7938  end -= 1;
7939  }
7940  }
7941  break;
7942  }
7943 
7944  out[0] = val >> 16;
7945  out[1] = (val >> 8) & 0xff;
7946  out[2] = val & 0xff;
7947  }
7948 
7949  if (ptr < end) {
7950  /* Process remaining chars. We do not require padding. */
7952  }
7953 
7954  return out - str.data;
7955 }
7956 
7957 /* Low-level integer parsing **************************************************/
7958 
7959 /* We use these hand-written routines instead of strto[u]l() because the "long
7960  * long" variants aren't in c89. Also our version allows setting a ptr limit. */
7961 
7962 static const char *jsondec_buftouint64(jsondec *d, const char *ptr,
7963  const char *end, uint64_t *val) {
7964  uint64_t u64 = 0;
7965  while (ptr < end) {
7966  unsigned ch = *ptr - '0';
7967  if (ch >= 10) break;
7968  if (u64 > UINT64_MAX / 10 || u64 * 10 > UINT64_MAX - ch) {
7969  jsondec_err(d, "Integer overflow");
7970  }
7971  u64 *= 10;
7972  u64 += ch;
7973  ptr++;
7974  }
7975 
7976  *val = u64;
7977  return ptr;
7978 }
7979 
7980 static const char *jsondec_buftoint64(jsondec *d, const char *ptr,
7981  const char *end, int64_t *val) {
7982  bool neg = false;
7983  uint64_t u64;
7984 
7985  if (ptr != end && *ptr == '-') {
7986  ptr++;
7987  neg = true;
7988  }
7989 
7990  ptr = jsondec_buftouint64(d, ptr, end, &u64);
7991  if (u64 > (uint64_t)INT64_MAX + neg) {
7992  jsondec_err(d, "Integer overflow");
7993  }
7994 
7995  *val = neg ? -u64 : u64;
7996  return ptr;
7997 }
7998 
8000  const char *end = str.data + str.size;
8001  uint64_t ret;
8002  if (jsondec_buftouint64(d, str.data, end, &ret) != end) {
8003  jsondec_err(d, "Non-number characters in quoted integer");
8004  }
8005  return ret;
8006 }
8007 
8009  const char *end = str.data + str.size;
8010  int64_t ret;
8011  if (jsondec_buftoint64(d, str.data, end, &ret) != end) {
8012  jsondec_err(d, "Non-number characters in quoted integer");
8013  }
8014  return ret;
8015 }
8016 
8017 /* Primitive value types ******************************************************/
8018 
8019 /* Parse INT32 or INT64 value. */
8021  upb_msgval val;
8022 
8023  switch (jsondec_peek(d)) {
8024  case JD_NUMBER: {
8025  double dbl = jsondec_number(d);
8026  if (dbl > 9223372036854774784.0 || dbl < -9223372036854775808.0) {
8027  jsondec_err(d, "JSON number is out of range.");
8028  }
8029  val.int64_val = dbl; /* must be guarded, overflow here is UB */
8030  if (val.int64_val != dbl) {
8031  jsondec_errf(d, "JSON number was not integral (%f != %" PRId64 ")", dbl,
8032  val.int64_val);
8033  }
8034  break;
8035  }
8036  case JD_STRING: {
8039  break;
8040  }
8041  default:
8042  jsondec_err(d, "Expected number or string");
8043  }
8044 
8046  if (val.int64_val > INT32_MAX || val.int64_val < INT32_MIN) {
8047  jsondec_err(d, "Integer out of range.");
8048  }
8049  val.int32_val = (int32_t)val.int64_val;
8050  }
8051 
8052  return val;
8053 }
8054 
8055 /* Parse UINT32 or UINT64 value. */
8057  upb_msgval val = {0};
8058 
8059  switch (jsondec_peek(d)) {
8060  case JD_NUMBER: {
8061  double dbl = jsondec_number(d);
8062  if (dbl > 18446744073709549568.0 || dbl < 0) {
8063  jsondec_err(d, "JSON number is out of range.");
8064  }
8065  val.uint64_val = dbl; /* must be guarded, overflow here is UB */
8066  if (val.uint64_val != dbl) {
8067  jsondec_errf(d, "JSON number was not integral (%f != %" PRIu64 ")", dbl,
8068  val.uint64_val);
8069  }
8070  break;
8071  }
8072  case JD_STRING: {
8075  break;
8076  }
8077  default:
8078  jsondec_err(d, "Expected number or string");
8079  }
8080 
8082  if (val.uint64_val > UINT32_MAX) {
8083  jsondec_err(d, "Integer out of range.");
8084  }
8085  val.uint32_val = (uint32_t)val.uint64_val;
8086  }
8087 
8088  return val;
8089 }
8090 
8091 /* Parse DOUBLE or FLOAT value. */
8093  upb_strview str;
8094  upb_msgval val = {0};
8095 
8096  switch (jsondec_peek(d)) {
8097  case JD_NUMBER:
8098  val.double_val = jsondec_number(d);
8099  break;
8100  case JD_STRING:
8101  str = jsondec_string(d);
8102  if (jsondec_streql(str, "NaN")) {
8103  val.double_val = NAN;
8104  } else if (jsondec_streql(str, "Infinity")) {
8105  val.double_val = INFINITY;
8106  } else if (jsondec_streql(str, "-Infinity")) {
8107  val.double_val = -INFINITY;
8108  } else {
8109  val.double_val = strtod(str.data, NULL);
8110  }
8111  break;
8112  default:
8113  jsondec_err(d, "Expected number or string");
8114  }
8115 
8117  if (val.double_val != INFINITY && val.double_val != -INFINITY &&
8118  (val.double_val > FLT_MAX || val.double_val < -FLT_MAX)) {
8119  jsondec_err(d, "Float out of range");
8120  }
8121  val.float_val = val.double_val;
8122  }
8123 
8124  return val;
8125 }
8126 
8127 /* Parse STRING or BYTES value. */
8129  upb_msgval val;
8130  val.str_val = jsondec_string(d);
8132  val.str_val.size = jsondec_base64(d, val.str_val);
8133  }
8134  return val;
8135 }
8136 
8138  switch (jsondec_peek(d)) {
8139  case JD_STRING: {
8142  upb_msgval val;
8143  if (!upb_enumdef_ntoi(e, str.data, str.size, &val.int32_val)) {
8144  if (d->options & UPB_JSONDEC_IGNOREUNKNOWN) {
8145  val.int32_val = 0;
8146  } else {
8147  jsondec_errf(d, "Unknown enumerator: '" UPB_STRVIEW_FORMAT "'",
8149  }
8150  }
8151  return val;
8152  }
8153  case JD_NULL: {
8154  if (jsondec_isnullvalue(f)) {
8155  upb_msgval val;
8156  jsondec_null(d);
8157  val.int32_val = 0;
8158  return val;
8159  }
8160  }
8161  /* Fallthrough. */
8162  default:
8163  return jsondec_int(d, f);
8164  }
8165 }
8166 
8168  bool is_map_key = upb_fielddef_number(f) == 1 &&
8170  upb_msgval val;
8171 
8172  if (is_map_key) {
8174  if (jsondec_streql(str, "true")) {
8175  val.bool_val = true;
8176  } else if (jsondec_streql(str, "false")) {
8177  val.bool_val = false;
8178  } else {
8179  jsondec_err(d, "Invalid boolean map key");
8180  }
8181  } else {
8182  switch (jsondec_peek(d)) {
8183  case JD_TRUE:
8184  val.bool_val = true;
8185  jsondec_true(d);
8186  break;
8187  case JD_FALSE:
8188  val.bool_val = false;
8189  jsondec_false(d);
8190  break;
8191  default:
8192  jsondec_err(d, "Expected true or false");
8193  }
8194  }
8195 
8196  return val;
8197 }
8198 
8199 /* Composite types (array/message/map) ****************************************/
8200 
8201 static void jsondec_array(jsondec *d, upb_msg *msg, const upb_fielddef *f) {
8202  upb_array *arr = upb_msg_mutable(msg, f, d->arena).array;
8203 
8205  while (jsondec_arrnext(d)) {
8207  upb_array_append(arr, elem, d->arena);
8208  }
8209  jsondec_arrend(d);
8210 }
8211 
8212 static void jsondec_map(jsondec *d, upb_msg *msg, const upb_fielddef *f) {
8213  upb_map *map = upb_msg_mutable(msg, f, d->arena).map;
8214  const upb_msgdef *entry = upb_fielddef_msgsubdef(f);
8215  const upb_fielddef *key_f = upb_msgdef_itof(entry, 1);
8216  const upb_fielddef *val_f = upb_msgdef_itof(entry, 2);
8217 
8219  while (jsondec_objnext(d)) {
8220  upb_msgval key, val;
8221  key = jsondec_value(d, key_f);
8223  val = jsondec_value(d, val_f);
8224  upb_map_set(map, key, val, d->arena);
8225  }
8226  jsondec_objend(d);
8227 }
8228 
8229 static void jsondec_tomsg(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
8231  jsondec_object(d, msg, m);
8232  } else {
8233  jsondec_wellknown(d, msg, m);
8234  }
8235 }
8236 
8239  upb_msg *msg = upb_msg_new(m, d->arena);
8240  upb_msgval val;
8241 
8242  jsondec_tomsg(d, msg, m);
8243  val.msg_val = msg;
8244  return val;
8245 }
8246 
8247 static void jsondec_field(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
8248  upb_strview name;
8249  const upb_fielddef *f;
8250  const upb_fielddef *preserved;
8251 
8252  name = jsondec_string(d);
8254  f = upb_msgdef_lookupjsonname(m, name.data, name.size);
8255 
8256  if (!f) {
8257  if ((d->options & UPB_JSONDEC_IGNOREUNKNOWN) == 0) {
8258  jsondec_errf(d, "No such field: " UPB_STRVIEW_FORMAT,
8260  }
8261  jsondec_skipval(d);
8262  return;
8263  }
8264 
8265  if (jsondec_peek(d) == JD_NULL && !jsondec_isvalue(f)) {
8266  /* JSON "null" indicates a default value, so no need to set anything. */
8267  jsondec_null(d);
8268  return;
8269  }
8270 
8273  jsondec_err(d, "More than one field for this oneof.");
8274  }
8275 
8276  preserved = d->debug_field;
8277  d->debug_field = f;
8278 
8279  if (upb_fielddef_ismap(f)) {
8280  jsondec_map(d, msg, f);
8281  } else if (upb_fielddef_isseq(f)) {
8282  jsondec_array(d, msg, f);
8283  } else if (upb_fielddef_issubmsg(f)) {
8284  upb_msg *submsg = upb_msg_mutable(msg, f, d->arena).msg;
8285  const upb_msgdef *subm = upb_fielddef_msgsubdef(f);
8286  jsondec_tomsg(d, submsg, subm);
8287  } else {
8288  upb_msgval val = jsondec_value(d, f);
8289  upb_msg_set(msg, f, val, d->arena);
8290  }
8291 
8292  d->debug_field = preserved;
8293 }
8294 
8295 static void jsondec_object(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
8297  while (jsondec_objnext(d)) {
8298  jsondec_field(d, msg, m);
8299  }
8300  jsondec_objend(d);
8301 }
8302 
8304  switch (upb_fielddef_type(f)) {
8305  case UPB_TYPE_BOOL:
8306  return jsondec_bool(d, f);
8307  case UPB_TYPE_FLOAT:
8308  case UPB_TYPE_DOUBLE:
8309  return jsondec_double(d, f);
8310  case UPB_TYPE_UINT32:
8311  case UPB_TYPE_UINT64:
8312  return jsondec_uint(d, f);
8313  case UPB_TYPE_INT32:
8314  case UPB_TYPE_INT64:
8315  return jsondec_int(d, f);
8316  case UPB_TYPE_STRING:
8317  case UPB_TYPE_BYTES:
8318  return jsondec_strfield(d, f);
8319  case UPB_TYPE_ENUM:
8320  return jsondec_enum(d, f);
8321  case UPB_TYPE_MESSAGE:
8322  return jsondec_msg(d, f);
8323  default:
8324  UPB_UNREACHABLE();
8325  }
8326 }
8327 
8328 /* Well-known types ***********************************************************/
8329 
8330 static int jsondec_tsdigits(jsondec *d, const char **ptr, size_t digits,
8331  const char *after) {
8332  uint64_t val;
8333  const char *p = *ptr;
8334  const char *end = p + digits;
8335  size_t after_len = after ? strlen(after) : 0;
8336 
8337  UPB_ASSERT(digits <= 9); /* int can't overflow. */
8338 
8339  if (jsondec_buftouint64(d, p, end, &val) != end ||
8340  (after_len && memcmp(end, after, after_len) != 0)) {
8341  jsondec_err(d, "Malformed timestamp");
8342  }
8343 
8344  UPB_ASSERT(val < INT_MAX);
8345 
8346  *ptr = end + after_len;
8347  return (int)val;
8348 }
8349 
8350 static int jsondec_nanos(jsondec *d, const char **ptr, const char *end) {
8351  uint64_t nanos = 0;
8352  const char *p = *ptr;
8353 
8354  if (p != end && *p == '.') {
8355  const char *nano_end = jsondec_buftouint64(d, p + 1, end, &nanos);
8356  int digits = (int)(nano_end - p - 1);
8357  int exp_lg10 = 9 - digits;
8358  if (digits > 9) {
8359  jsondec_err(d, "Too many digits for partial seconds");
8360  }
8361  while (exp_lg10--) nanos *= 10;
8362  *ptr = nano_end;
8363  }
8364 
8365  UPB_ASSERT(nanos < INT_MAX);
8366 
8367  return (int)nanos;
8368 }
8369 
8370 /* jsondec_epochdays(1970, 1, 1) == 1970-01-01 == 0. */
8371 int jsondec_epochdays(int y, int m, int d) {
8372  const uint32_t year_base = 4800; /* Before min year, multiple of 400. */
8373  const uint32_t m_adj = m - 3; /* March-based month. */
8374  const uint32_t carry = m_adj > (uint32_t)m ? 1 : 0;
8375  const uint32_t adjust = carry ? 12 : 0;
8376  const uint32_t y_adj = y + year_base - carry;
8377  const uint32_t month_days = ((m_adj + adjust) * 62719 + 769) / 2048;
8378  const uint32_t leap_days = y_adj / 4 - y_adj / 100 + y_adj / 400;
8379  return y_adj * 365 + leap_days + month_days + (d - 1) - 2472632;
8380 }
8381 
8382 static int64_t jsondec_unixtime(int y, int m, int d, int h, int min, int s) {
8383  return (int64_t)jsondec_epochdays(y, m, d) * 86400 + h * 3600 + min * 60 + s;
8384 }
8385 
8386 static void jsondec_timestamp(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
8388  upb_msgval nanos;
8390  const char *ptr = str.data;
8391  const char *end = ptr + str.size;
8392 
8393  if (str.size < 20) goto malformed;
8394 
8395  {
8396  /* 1972-01-01T01:00:00 */
8397  int year = jsondec_tsdigits(d, &ptr, 4, "-");
8398  int mon = jsondec_tsdigits(d, &ptr, 2, "-");
8399  int day = jsondec_tsdigits(d, &ptr, 2, "T");
8400  int hour = jsondec_tsdigits(d, &ptr, 2, ":");
8401  int min = jsondec_tsdigits(d, &ptr, 2, ":");
8402  int sec = jsondec_tsdigits(d, &ptr, 2, NULL);
8403 
8404  seconds.int64_val = jsondec_unixtime(year, mon, day, hour, min, sec);
8405  }
8406 
8407  nanos.int32_val = jsondec_nanos(d, &ptr, end);
8408 
8409  {
8410  /* [+-]08:00 or Z */
8411  int ofs_hour = 0;
8412  int ofs_min = 0;
8413  bool neg = false;
8414 
8415  if (ptr == end) goto malformed;
8416 
8417  switch (*ptr++) {
8418  case '-':
8419  neg = true;
8420  /* fallthrough */
8421  case '+':
8422  if ((end - ptr) != 5) goto malformed;
8423  ofs_hour = jsondec_tsdigits(d, &ptr, 2, ":");
8424  ofs_min = jsondec_tsdigits(d, &ptr, 2, NULL);
8425  ofs_min = ((ofs_hour * 60) + ofs_min) * 60;
8426  seconds.int64_val += (neg ? ofs_min : -ofs_min);
8427  break;
8428  case 'Z':
8429  if (ptr != end) goto malformed;
8430  break;
8431  default:
8432  goto malformed;
8433  }
8434  }
8435 
8436  if (seconds.int64_val < -62135596800) {
8437  jsondec_err(d, "Timestamp out of range");
8438  }
8439 
8440  upb_msg_set(msg, upb_msgdef_itof(m, 1), seconds, d->arena);
8441  upb_msg_set(msg, upb_msgdef_itof(m, 2), nanos, d->arena);
8442  return;
8443 
8444 malformed:
8445  jsondec_err(d, "Malformed timestamp");
8446 }
8447 
8448 static void jsondec_duration(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
8450  upb_msgval nanos;
8452  const char *ptr = str.data;
8453  const char *end = ptr + str.size;
8454  const int64_t max = (uint64_t)3652500 * 86400;
8455 
8456  /* "3.000000001s", "3s", etc. */
8457  ptr = jsondec_buftoint64(d, ptr, end, &seconds.int64_val);
8458  nanos.int32_val = jsondec_nanos(d, &ptr, end);
8459 
8460  if (end - ptr != 1 || *ptr != 's') {
8461  jsondec_err(d, "Malformed duration");
8462  }
8463 
8464  if (seconds.int64_val < -max || seconds.int64_val > max) {
8465  jsondec_err(d, "Duration out of range");
8466  }
8467 
8468  if (seconds.int64_val < 0) {
8469  nanos.int32_val = - nanos.int32_val;
8470  }
8471 
8472  upb_msg_set(msg, upb_msgdef_itof(m, 1), seconds, d->arena);
8473  upb_msg_set(msg, upb_msgdef_itof(m, 2), nanos, d->arena);
8474 }
8475 
8476 static void jsondec_listvalue(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
8477  const upb_fielddef *values_f = upb_msgdef_itof(m, 1);
8478  const upb_msgdef *value_m = upb_fielddef_msgsubdef(values_f);
8479  upb_array *values = upb_msg_mutable(msg, values_f, d->arena).array;
8480 
8482  while (jsondec_arrnext(d)) {
8483  upb_msg *value_msg = upb_msg_new(value_m, d->arena);
8484  upb_msgval value;
8485  value.msg_val = value_msg;
8486  upb_array_append(values, value, d->arena);
8487  jsondec_wellknownvalue(d, value_msg, value_m);
8488  }
8489  jsondec_arrend(d);
8490 }
8491 
8492 static void jsondec_struct(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
8493  const upb_fielddef *fields_f = upb_msgdef_itof(m, 1);
8494  const upb_msgdef *entry_m = upb_fielddef_msgsubdef(fields_f);
8495  const upb_fielddef *value_f = upb_msgdef_itof(entry_m, 2);
8496  const upb_msgdef *value_m = upb_fielddef_msgsubdef(value_f);
8497  upb_map *fields = upb_msg_mutable(msg, fields_f, d->arena).map;
8498 
8500  while (jsondec_objnext(d)) {
8501  upb_msgval key, value;
8502  upb_msg *value_msg = upb_msg_new(value_m, d->arena);
8503  key.str_val = jsondec_string(d);
8504  value.msg_val = value_msg;
8505  upb_map_set(fields, key, value, d->arena);
8507  jsondec_wellknownvalue(d, value_msg, value_m);
8508  }
8509  jsondec_objend(d);
8510 }
8511 
8513  const upb_msgdef *m) {
8514  upb_msgval val;
8515  const upb_fielddef *f;
8516  upb_msg *submsg;
8517 
8518  switch (jsondec_peek(d)) {
8519  case JD_NUMBER:
8520  /* double number_value = 2; */
8521  f = upb_msgdef_itof(m, 2);
8522  val.double_val = jsondec_number(d);
8523  break;
8524  case JD_STRING:
8525  /* string string_value = 3; */
8526  f = upb_msgdef_itof(m, 3);
8527  val.str_val = jsondec_string(d);
8528  break;
8529  case JD_FALSE:
8530  /* bool bool_value = 4; */
8531  f = upb_msgdef_itof(m, 4);
8532  val.bool_val = false;
8533  jsondec_false(d);
8534  break;
8535  case JD_TRUE:
8536  /* bool bool_value = 4; */
8537  f = upb_msgdef_itof(m, 4);
8538  val.bool_val = true;
8539  jsondec_true(d);
8540  break;
8541  case JD_NULL:
8542  /* NullValue null_value = 1; */
8543  f = upb_msgdef_itof(m, 1);
8544  val.int32_val = 0;
8545  jsondec_null(d);
8546  break;
8547  /* Note: these cases return, because upb_msg_mutable() is enough. */
8548  case JD_OBJECT:
8549  /* Struct struct_value = 5; */
8550  f = upb_msgdef_itof(m, 5);
8551  submsg = upb_msg_mutable(msg, f, d->arena).msg;
8553  return;
8554  case JD_ARRAY:
8555  /* ListValue list_value = 6; */
8556  f = upb_msgdef_itof(m, 6);
8557  submsg = upb_msg_mutable(msg, f, d->arena).msg;
8559  return;
8560  default:
8561  UPB_UNREACHABLE();
8562  }
8563 
8564  upb_msg_set(msg, f, val, d->arena);
8565 }
8566 
8567 static upb_strview jsondec_mask(jsondec *d, const char *buf, const char *end) {
8568  /* FieldMask fields grow due to inserted '_' characters, so we can't do the
8569  * transform in place. */
8570  const char *ptr = buf;
8571  upb_strview ret;
8572  char *out;
8573 
8574  ret.size = end - ptr;
8575  while (ptr < end) {
8576  ret.size += (*ptr >= 'A' && *ptr <= 'Z');
8577  ptr++;
8578  }
8579 
8580  out = upb_arena_malloc(d->arena, ret.size);
8581  ptr = buf;
8582  ret.data = out;
8583 
8584  while (ptr < end) {
8585  char ch = *ptr++;
8586  if (ch >= 'A' && ch <= 'Z') {
8587  *out++ = '_';
8588  *out++ = ch + 32;
8589  } else if (ch == '_') {
8590  jsondec_err(d, "field mask may not contain '_'");
8591  } else {
8592  *out++ = ch;
8593  }
8594  }
8595 
8596  return ret;
8597 }
8598 
8599 static void jsondec_fieldmask(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
8600  /* repeated string paths = 1; */
8601  const upb_fielddef *paths_f = upb_msgdef_itof(m, 1);
8602  upb_array *arr = upb_msg_mutable(msg, paths_f, d->arena).array;
8604  const char *ptr = str.data;
8605  const char *end = ptr + str.size;
8606  upb_msgval val;
8607 
8608  while (ptr < end) {
8609  const char *elem_end = memchr(ptr, ',', end - ptr);
8610  if (elem_end) {
8611  val.str_val = jsondec_mask(d, ptr, elem_end);
8612  ptr = elem_end + 1;
8613  } else {
8614  val.str_val = jsondec_mask(d, ptr, end);
8615  ptr = end;
8616  }
8617  upb_array_append(arr, val, d->arena);
8618  }
8619 }
8620 
8621 static void jsondec_anyfield(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
8623  /* For regular types: {"@type": "[user type]", "f1": <V1>, "f2": <V2>}
8624  * where f1, f2, etc. are the normal fields of this type. */
8625  jsondec_field(d, msg, m);
8626  } else {
8627  /* For well-known types: {"@type": "[well-known type]", "value": <X>}
8628  * where <X> is whatever encoding the WKT normally uses. */
8631  if (!jsondec_streql(str, "value")) {
8632  jsondec_err(d, "Key for well-known type must be 'value'");
8633  }
8634  jsondec_wellknown(d, msg, m);
8635  }
8636 }
8637 
8639  const upb_msgdef *m) {
8640  const upb_fielddef *type_url_f = upb_msgdef_itof(m, 1);
8641  const upb_msgdef *type_m;
8643  const char *end = type_url.data + type_url.size;
8644  const char *ptr = end;
8645  upb_msgval val;
8646 
8647  val.str_val = type_url;
8648  upb_msg_set(msg, type_url_f, val, d->arena);
8649 
8650  /* Find message name after the last '/' */
8651  while (ptr > type_url.data && *--ptr != '/') {}
8652 
8653  if (ptr == type_url.data || ptr == end) {
8654  jsondec_err(d, "Type url must have at least one '/' and non-empty host");
8655  }
8656 
8657  ptr++;
8658  type_m = upb_symtab_lookupmsg2(d->any_pool, ptr, end - ptr);
8659 
8660  if (!type_m) {
8661  jsondec_err(d, "Type was not found");
8662  }
8663 
8664  return type_m;
8665 }
8666 
8667 static void jsondec_any(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
8668  /* string type_url = 1;
8669  * bytes value = 2; */
8670  const upb_fielddef *value_f = upb_msgdef_itof(m, 2);
8671  upb_msg *any_msg;
8672  const upb_msgdef *any_m = NULL;
8673  const char *pre_type_data = NULL;
8674  const char *pre_type_end = NULL;
8675  upb_msgval encoded;
8676 
8678 
8679  /* Scan looking for "@type", which is not necessarily first. */
8680  while (!any_m && jsondec_objnext(d)) {
8681  const char *start = d->ptr;
8684  if (jsondec_streql(name, "@type")) {
8685  any_m = jsondec_typeurl(d, msg, m);
8686  if (pre_type_data) {
8687  pre_type_end = start;
8688  while (*pre_type_end != ',') pre_type_end--;
8689  }
8690  } else {
8691  if (!pre_type_data) pre_type_data = start;
8692  jsondec_skipval(d);
8693  }
8694  }
8695 
8696  if (!any_m) {
8697  jsondec_err(d, "Any object didn't contain a '@type' field");
8698  }
8699 
8700  any_msg = upb_msg_new(any_m, d->arena);
8701 
8702  if (pre_type_data) {
8703  size_t len = pre_type_end - pre_type_data + 1;
8704  char *tmp = upb_arena_malloc(d->arena, len);
8705  const char *saved_ptr = d->ptr;
8706  const char *saved_end = d->end;
8707  memcpy(tmp, pre_type_data, len - 1);
8708  tmp[len - 1] = '}';
8709  d->ptr = tmp;
8710  d->end = tmp + len;
8711  d->is_first = true;
8712  while (jsondec_objnext(d)) {
8713  jsondec_anyfield(d, any_msg, any_m);
8714  }
8715  d->ptr = saved_ptr;
8716  d->end = saved_end;
8717  }
8718 
8719  while (jsondec_objnext(d)) {
8720  jsondec_anyfield(d, any_msg, any_m);
8721  }
8722 
8723  jsondec_objend(d);
8724 
8725  encoded.str_val.data = upb_encode(any_msg, upb_msgdef_layout(any_m), d->arena,
8726  &encoded.str_val.size);
8727  upb_msg_set(msg, value_f, encoded, d->arena);
8728 }
8729 
8730 static void jsondec_wrapper(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
8731  const upb_fielddef *value_f = upb_msgdef_itof(m, 1);
8732  upb_msgval val = jsondec_value(d, value_f);
8733  upb_msg_set(msg, value_f, val, d->arena);
8734 }
8735 
8736 static void jsondec_wellknown(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
8737  switch (upb_msgdef_wellknowntype(m)) {
8738  case UPB_WELLKNOWN_ANY:
8739  jsondec_any(d, msg, m);
8740  break;
8742  jsondec_fieldmask(d, msg, m);
8743  break;
8745  jsondec_duration(d, msg, m);
8746  break;
8748  jsondec_timestamp(d, msg, m);
8749  break;
8750  case UPB_WELLKNOWN_VALUE:
8752  break;
8754  jsondec_listvalue(d, msg, m);
8755  break;
8756  case UPB_WELLKNOWN_STRUCT:
8757  jsondec_struct(d, msg, m);
8758  break;
8768  jsondec_wrapper(d, msg, m);
8769  break;
8770  default:
8771  UPB_UNREACHABLE();
8772  }
8773 }
8774 
8775 bool upb_json_decode(const char *buf, size_t size, upb_msg *msg,
8776  const upb_msgdef *m, const upb_symtab *any_pool,
8778  jsondec d;
8779 
8780  if (size == 0) return true;
8781 
8782  d.ptr = buf;
8783  d.end = buf + size;
8784  d.arena = arena;
8785  d.any_pool = any_pool;
8786  d.status = status;
8787  d.options = options;
8788  d.depth = 64;
8789  d.line = 1;
8790  d.line_begin = d.ptr;
8791  d.debug_field = NULL;
8792  d.is_first = false;
8793 
8794  if (UPB_SETJMP(d.err)) return false;
8795 
8796  jsondec_tomsg(&d, msg, m);
8797  return true;
8798 }
8799 
8802 #include <ctype.h>
8803 #include <float.h>
8804 #include <inttypes.h>
8805 #include <math.h>
8806 #include <setjmp.h>
8807 #include <stdarg.h>
8808 #include <stdio.h>
8809 #include <string.h>
8810 
8811 
8812 /* Must be last. */
8813 
8814 typedef struct {
8815  char *buf, *ptr, *end;
8816  size_t overflow;
8818  int options;
8820  jmp_buf err;
8823 } jsonenc;
8824 
8825 static void jsonenc_msg(jsonenc *e, const upb_msg *msg, const upb_msgdef *m);
8826 static void jsonenc_scalar(jsonenc *e, upb_msgval val, const upb_fielddef *f);
8827 static void jsonenc_msgfield(jsonenc *e, const upb_msg *msg,
8828  const upb_msgdef *m);
8829 static void jsonenc_msgfields(jsonenc *e, const upb_msg *msg,
8830  const upb_msgdef *m, bool first);
8831 static void jsonenc_value(jsonenc *e, const upb_msg *msg, const upb_msgdef *m);
8832 
8833 UPB_NORETURN static void jsonenc_err(jsonenc *e, const char *msg) {
8834  upb_status_seterrmsg(e->status, msg);
8835  longjmp(e->err, 1);
8836 }
8837 
8838 UPB_PRINTF(2, 3)
8839 UPB_NORETURN static void jsonenc_errf(jsonenc *e, const char *fmt, ...) {
8840  va_list argp;
8841  va_start(argp, fmt);
8842  upb_status_vseterrf(e->status, fmt, argp);
8843  va_end(argp);
8844  longjmp(e->err, 1);
8845 }
8846 
8848  /* Create lazily, since it's only needed for Any */
8849  if (!e->arena) {
8850  e->arena = upb_arena_new();
8851  }
8852  return e->arena;
8853 }
8854 
8855 static void jsonenc_putbytes(jsonenc *e, const void *data, size_t len) {
8856  size_t have = e->end - e->ptr;
8857  if (UPB_LIKELY(have >= len)) {
8858  memcpy(e->ptr, data, len);
8859  e->ptr += len;
8860  } else {
8861  if (have) {
8862  memcpy(e->ptr, data, have);
8863  e->ptr += have;
8864  }
8865  e->overflow += (len - have);
8866  }
8867 }
8868 
8869 static void jsonenc_putstr(jsonenc *e, const char *str) {
8870  jsonenc_putbytes(e, str, strlen(str));
8871 }
8872 
8873 UPB_PRINTF(2, 3)
8874 static void jsonenc_printf(jsonenc *e, const char *fmt, ...) {
8875  size_t n;
8876  size_t have = e->end - e->ptr;
8877  va_list args;
8878 
8879  va_start(args, fmt);
8880  n = vsnprintf(e->ptr, have, fmt, args);
8881  va_end(args);
8882 
8883  if (UPB_LIKELY(have > n)) {
8884  e->ptr += n;
8885  } else {
8886  e->ptr = UPB_PTRADD(e->ptr, have);
8887  e->overflow += (n - have);
8888  }
8889 }
8890 
8891 static void jsonenc_nanos(jsonenc *e, int32_t nanos) {
8892  int digits = 9;
8893 
8894  if (nanos == 0) return;
8895  if (nanos < 0 || nanos >= 1000000000) {
8896  jsonenc_err(e, "error formatting timestamp as JSON: invalid nanos");
8897  }
8898 
8899  while (nanos % 1000 == 0) {
8900  nanos /= 1000;
8901  digits -= 3;
8902  }
8903 
8904  jsonenc_printf(e, ".%.*" PRId32, digits, nanos);
8905 }
8906 
8907 static void jsonenc_timestamp(jsonenc *e, const upb_msg *msg,
8908  const upb_msgdef *m) {
8909  const upb_fielddef *seconds_f = upb_msgdef_itof(m, 1);
8910  const upb_fielddef *nanos_f = upb_msgdef_itof(m, 2);
8911  int64_t seconds = upb_msg_get(msg, seconds_f).int64_val;
8912  int32_t nanos = upb_msg_get(msg, nanos_f).int32_val;
8913  int L, N, I, J, K, hour, min, sec;
8914 
8915  if (seconds < -62135596800) {
8916  jsonenc_err(e,
8917  "error formatting timestamp as JSON: minimum acceptable value "
8918  "is 0001-01-01T00:00:00Z");
8919  } else if (seconds > 253402300799) {
8920  jsonenc_err(e,
8921  "error formatting timestamp as JSON: maximum acceptable value "
8922  "is 9999-12-31T23:59:59Z");
8923  }
8924 
8925  /* Julian Day -> Y/M/D, Algorithm from:
8926  * Fliegel, H. F., and Van Flandern, T. C., "A Machine Algorithm for
8927  * Processing Calendar Dates," Communications of the Association of
8928  * Computing Machines, vol. 11 (1968), p. 657. */
8929  L = (int)(seconds / 86400) + 68569 + 2440588;
8930  N = 4 * L / 146097;
8931  L = L - (146097 * N + 3) / 4;
8932  I = 4000 * (L + 1) / 1461001;
8933  L = L - 1461 * I / 4 + 31;
8934  J = 80 * L / 2447;
8935  K = L - 2447 * J / 80;
8936  L = J / 11;
8937  J = J + 2 - 12 * L;
8938  I = 100 * (N - 49) + I + L;
8939 
8940  sec = seconds % 60;
8941  min = (seconds / 60) % 60;
8942  hour = (seconds / 3600) % 24;
8943 
8944  jsonenc_printf(e, "\"%04d-%02d-%02dT%02d:%02d:%02d", I, J, K, hour, min, sec);
8945  jsonenc_nanos(e, nanos);
8946  jsonenc_putstr(e, "Z\"");
8947 }
8948 
8949 static void jsonenc_duration(jsonenc *e, const upb_msg *msg, const upb_msgdef *m) {
8950  const upb_fielddef *seconds_f = upb_msgdef_itof(m, 1);
8951  const upb_fielddef *nanos_f = upb_msgdef_itof(m, 2);
8952  int64_t seconds = upb_msg_get(msg, seconds_f).int64_val;
8953  int32_t nanos = upb_msg_get(msg, nanos_f).int32_val;
8954 
8955  if (seconds > 315576000000 || seconds < -315576000000 ||
8956  (seconds < 0) != (nanos < 0)) {
8957  jsonenc_err(e, "bad duration");
8958  }
8959 
8960  if (nanos < 0) {
8961  nanos = -nanos;
8962  }
8963 
8964  jsonenc_printf(e, "\"%" PRId64, seconds);
8965  jsonenc_nanos(e, nanos);
8966  jsonenc_putstr(e, "s\"");
8967 }
8968 
8969 static void jsonenc_enum(int32_t val, const upb_fielddef *f, jsonenc *e) {
8970  const upb_enumdef *e_def = upb_fielddef_enumsubdef(f);
8971 
8972  if (strcmp(upb_enumdef_fullname(e_def), "google.protobuf.NullValue") == 0) {
8973  jsonenc_putstr(e, "null");
8974  } else {
8975  const char *name = upb_enumdef_iton(e_def, val);
8976 
8977  if (name) {
8978  jsonenc_printf(e, "\"%s\"", name);
8979  } else {
8980  jsonenc_printf(e, "%" PRId32, val);
8981  }
8982  }
8983 }
8984 
8986  /* This is the regular base64, not the "web-safe" version. */
8987  static const char base64[] =
8988  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
8989  const unsigned char *ptr = (unsigned char*)str.data;
8990  const unsigned char *end = UPB_PTRADD(ptr, str.size);
8991  char buf[4];
8992 
8993  jsonenc_putstr(e, "\"");
8994 
8995  while (end - ptr >= 3) {
8996  buf[0] = base64[ptr[0] >> 2];
8997  buf[1] = base64[((ptr[0] & 0x3) << 4) | (ptr[1] >> 4)];
8998  buf[2] = base64[((ptr[1] & 0xf) << 2) | (ptr[2] >> 6)];
8999  buf[3] = base64[ptr[2] & 0x3f];
9000  jsonenc_putbytes(e, buf, 4);
9001  ptr += 3;
9002  }
9003 
9004  switch (end - ptr) {
9005  case 2:
9006  buf[0] = base64[ptr[0] >> 2];
9007  buf[1] = base64[((ptr[0] & 0x3) << 4) | (ptr[1] >> 4)];
9008  buf[2] = base64[(ptr[1] & 0xf) << 2];
9009  buf[3] = '=';
9010  jsonenc_putbytes(e, buf, 4);
9011  break;
9012  case 1:
9013  buf[0] = base64[ptr[0] >> 2];
9014  buf[1] = base64[((ptr[0] & 0x3) << 4)];
9015  buf[2] = '=';
9016  buf[3] = '=';
9017  jsonenc_putbytes(e, buf, 4);
9018  break;
9019  }
9020 
9021  jsonenc_putstr(e, "\"");
9022 }
9023 
9025  const char *ptr = str.data;
9026  const char *end = UPB_PTRADD(ptr, str.size);
9027 
9028  while (ptr < end) {
9029  switch (*ptr) {
9030  case '\n':
9031  jsonenc_putstr(e, "\\n");
9032  break;
9033  case '\r':
9034  jsonenc_putstr(e, "\\r");
9035  break;
9036  case '\t':
9037  jsonenc_putstr(e, "\\t");
9038  break;
9039  case '\"':
9040  jsonenc_putstr(e, "\\\"");
9041  break;
9042  case '\f':
9043  jsonenc_putstr(e, "\\f");
9044  break;
9045  case '\b':
9046  jsonenc_putstr(e, "\\b");
9047  break;
9048  case '\\':
9049  jsonenc_putstr(e, "\\\\");
9050  break;
9051  default:
9052  if ((uint8_t)*ptr < 0x20) {
9053  jsonenc_printf(e, "\\u%04x", (int)(uint8_t)*ptr);
9054  } else {
9055  /* This could be a non-ASCII byte. We rely on the string being valid
9056  * UTF-8. */
9057  jsonenc_putbytes(e, ptr, 1);
9058  }
9059  break;
9060  }
9061  ptr++;
9062  }
9063 }
9064 
9066  jsonenc_putstr(e, "\"");
9067  jsonenc_stringbody(e, str);
9068  jsonenc_putstr(e, "\"");
9069 }
9070 
9071 static void jsonenc_double(jsonenc *e, const char *fmt, double val) {
9072  if (val == INFINITY) {
9073  jsonenc_putstr(e, "\"Infinity\"");
9074  } else if (val == -INFINITY) {
9075  jsonenc_putstr(e, "\"-Infinity\"");
9076  } else if (val != val) {
9077  jsonenc_putstr(e, "\"NaN\"");
9078  } else {
9079  char *p = e->ptr;
9080  jsonenc_printf(e, fmt, val);
9081 
9082  /* printf() is dependent on locales; sadly there is no easy and portable way
9083  * to avoid this. This little post-processing step will translate 1,2 -> 1.2
9084  * since JSON needs the latter. Arguably a hack, but it is simple and the
9085  * alternatives are far more complicated, platform-dependent, and/or larger
9086  * in code size. */
9087  for (char *end = e->ptr; p < end; p++) {
9088  if (*p == ',') *p = '.';
9089  }
9090  }
9091 }
9092 
9093 static void jsonenc_wrapper(jsonenc *e, const upb_msg *msg,
9094  const upb_msgdef *m) {
9095  const upb_fielddef *val_f = upb_msgdef_itof(m, 1);
9096  upb_msgval val = upb_msg_get(msg, val_f);
9097  jsonenc_scalar(e, val, val_f);
9098 }
9099 
9101  /* Find last '/', if any. */
9102  const char *end = type_url.data + type_url.size;
9103  const char *ptr = end;
9104  const upb_msgdef *ret;
9105 
9106  if (!e->ext_pool) {
9107  jsonenc_err(e, "Tried to encode Any, but no symtab was provided");
9108  }
9109 
9110  if (type_url.size == 0) goto badurl;
9111 
9112  while (true) {
9113  if (--ptr == type_url.data) {
9114  /* Type URL must contain at least one '/', with host before. */
9115  goto badurl;
9116  }
9117  if (*ptr == '/') {
9118  ptr++;
9119  break;
9120  }
9121  }
9122 
9123  ret = upb_symtab_lookupmsg2(e->ext_pool, ptr, end - ptr);
9124 
9125  if (!ret) {
9126  jsonenc_errf(e, "Couldn't find Any type: %.*s", (int)(end - ptr), ptr);
9127  }
9128 
9129  return ret;
9130 
9131 badurl:
9132  jsonenc_errf(
9133  e, "Bad type URL: " UPB_STRVIEW_FORMAT, UPB_STRVIEW_ARGS(type_url));
9134 }
9135 
9136 static void jsonenc_any(jsonenc *e, const upb_msg *msg, const upb_msgdef *m) {
9137  const upb_fielddef *type_url_f = upb_msgdef_itof(m, 1);
9138  const upb_fielddef *value_f = upb_msgdef_itof(m, 2);
9139  upb_strview type_url = upb_msg_get(msg, type_url_f).str_val;
9140  upb_strview value = upb_msg_get(msg, value_f).str_val;
9141  const upb_msgdef *any_m = jsonenc_getanymsg(e, type_url);
9142  const upb_msglayout *any_layout = upb_msgdef_layout(any_m);
9144  upb_msg *any = upb_msg_new(any_m, arena);
9145 
9146  if (!upb_decode(value.data, value.size, any, any_layout, arena)) {
9147  jsonenc_err(e, "Error decoding message in Any");
9148  }
9149 
9150  jsonenc_putstr(e, "{\"@type\":");
9152 
9154  /* Regular messages: {"@type": "...","foo": 1, "bar": 2} */
9155  jsonenc_msgfields(e, any, any_m, false);
9156  } else {
9157  /* Well-known type: {"@type": "...","value": <well-known encoding>} */
9158  jsonenc_putstr(e, ",\"value\":");
9159  jsonenc_msgfield(e, any, any_m);
9160  }
9161 
9162  jsonenc_putstr(e, "}");
9163 }
9164 
9165 static void jsonenc_putsep(jsonenc *e, const char *str, bool *first) {
9166  if (*first) {
9167  *first = false;
9168  } else {
9169  jsonenc_putstr(e, str);
9170  }
9171 }
9172 
9174  const char *ptr = path.data;
9175  const char *end = ptr + path.size;
9176 
9177  while (ptr < end) {
9178  char ch = *ptr;
9179 
9180  if (ch >= 'A' && ch <= 'Z') {
9181  jsonenc_err(e, "Field mask element may not have upper-case letter.");
9182  } else if (ch == '_') {
9183  if (ptr == end - 1 || *(ptr + 1) < 'a' || *(ptr + 1) > 'z') {
9184  jsonenc_err(e, "Underscore must be followed by a lowercase letter.");
9185  }
9186  ch = *++ptr - 32;
9187  }
9188 
9189  jsonenc_putbytes(e, &ch, 1);
9190  ptr++;
9191  }
9192 }
9193 
9194 static void jsonenc_fieldmask(jsonenc *e, const upb_msg *msg,
9195  const upb_msgdef *m) {
9196  const upb_fielddef *paths_f = upb_msgdef_itof(m, 1);
9197  const upb_array *paths = upb_msg_get(msg, paths_f).array_val;
9198  bool first = true;
9199  size_t i, n = 0;
9200 
9201  if (paths) n = upb_array_size(paths);
9202 
9203  jsonenc_putstr(e, "\"");
9204 
9205  for (i = 0; i < n; i++) {
9206  jsonenc_putsep(e, ",", &first);
9207  jsonenc_fieldpath(e, upb_array_get(paths, i).str_val);
9208  }
9209 
9210  jsonenc_putstr(e, "\"");
9211 }
9212 
9213 static void jsonenc_struct(jsonenc *e, const upb_msg *msg,
9214  const upb_msgdef *m) {
9215  const upb_fielddef *fields_f = upb_msgdef_itof(m, 1);
9216  const upb_map *fields = upb_msg_get(msg, fields_f).map_val;
9217  const upb_msgdef *entry_m = upb_fielddef_msgsubdef(fields_f);
9218  const upb_fielddef *value_f = upb_msgdef_itof(entry_m, 2);
9219  size_t iter = UPB_MAP_BEGIN;
9220  bool first = true;
9221 
9222  jsonenc_putstr(e, "{");
9223 
9224  if (fields) {
9225  while (upb_mapiter_next(fields, &iter)) {
9228 
9229  jsonenc_putsep(e, ",", &first);
9230  jsonenc_string(e, key.str_val);
9231  jsonenc_putstr(e, ":");
9232  jsonenc_value(e, val.msg_val, upb_fielddef_msgsubdef(value_f));
9233  }
9234  }
9235 
9236  jsonenc_putstr(e, "}");
9237 }
9238 
9239 static void jsonenc_listvalue(jsonenc *e, const upb_msg *msg,
9240  const upb_msgdef *m) {
9241  const upb_fielddef *values_f = upb_msgdef_itof(m, 1);
9242  const upb_msgdef *values_m = upb_fielddef_msgsubdef(values_f);
9243  const upb_array *values = upb_msg_get(msg, values_f).array_val;
9244  size_t i;
9245  bool first = true;
9246 
9247  jsonenc_putstr(e, "[");
9248 
9249  if (values) {
9250  const size_t size = upb_array_size(values);
9251  for (i = 0; i < size; i++) {
9253 
9254  jsonenc_putsep(e, ",", &first);
9255  jsonenc_value(e, elem.msg_val, values_m);
9256  }
9257  }
9258 
9259  jsonenc_putstr(e, "]");
9260 }
9261 
9262 static void jsonenc_value(jsonenc *e, const upb_msg *msg, const upb_msgdef *m) {
9263  /* TODO(haberman): do we want a reflection method to get oneof case? */
9264  size_t iter = UPB_MSG_BEGIN;
9265  const upb_fielddef *f;
9266  upb_msgval val;
9267 
9268  if (!upb_msg_next(msg, m, NULL, &f, &val, &iter)) {
9269  jsonenc_err(e, "No value set in Value proto");
9270  }
9271 
9272  switch (upb_fielddef_number(f)) {
9273  case 1:
9274  jsonenc_putstr(e, "null");
9275  break;
9276  case 2:
9277  jsonenc_double(e, "%.17g", val.double_val);
9278  break;
9279  case 3:
9280  jsonenc_string(e, val.str_val);
9281  break;
9282  case 4:
9283  jsonenc_putstr(e, val.bool_val ? "true" : "false");
9284  break;
9285  case 5:
9287  break;
9288  case 6:
9290  break;
9291  }
9292 }
9293 
9294 static void jsonenc_msgfield(jsonenc *e, const upb_msg *msg,
9295  const upb_msgdef *m) {
9296  switch (upb_msgdef_wellknowntype(m)) {
9298  jsonenc_msg(e, msg, m);
9299  break;
9300  case UPB_WELLKNOWN_ANY:
9301  jsonenc_any(e, msg, m);
9302  break;
9304  jsonenc_fieldmask(e, msg, m);
9305  break;
9307  jsonenc_duration(e, msg, m);
9308  break;
9310  jsonenc_timestamp(e, msg, m);
9311  break;
9321  jsonenc_wrapper(e, msg, m);
9322  break;
9323  case UPB_WELLKNOWN_VALUE:
9324  jsonenc_value(e, msg, m);
9325  break;
9327  jsonenc_listvalue(e, msg, m);
9328  break;
9329  case UPB_WELLKNOWN_STRUCT:
9330  jsonenc_struct(e, msg, m);
9331  break;
9332  }
9333 }
9334 
9335 static void jsonenc_scalar(jsonenc *e, upb_msgval val, const upb_fielddef *f) {
9336  switch (upb_fielddef_type(f)) {
9337  case UPB_TYPE_BOOL:
9338  jsonenc_putstr(e, val.bool_val ? "true" : "false");
9339  break;
9340  case UPB_TYPE_FLOAT:
9341  jsonenc_double(e, "%.9g", val.float_val);
9342  break;
9343  case UPB_TYPE_DOUBLE:
9344  jsonenc_double(e, "%.17g", val.double_val);
9345  break;
9346  case UPB_TYPE_INT32:
9347  jsonenc_printf(e, "%" PRId32, val.int32_val);
9348  break;
9349  case UPB_TYPE_UINT32:
9350  jsonenc_printf(e, "%" PRIu32, val.uint32_val);
9351  break;
9352  case UPB_TYPE_INT64:
9353  jsonenc_printf(e, "\"%" PRId64 "\"", val.int64_val);
9354  break;
9355  case UPB_TYPE_UINT64:
9356  jsonenc_printf(e, "\"%" PRIu64 "\"", val.uint64_val);
9357  break;
9358  case UPB_TYPE_STRING:
9359  jsonenc_string(e, val.str_val);
9360  break;
9361  case UPB_TYPE_BYTES:
9362  jsonenc_bytes(e, val.str_val);
9363  break;
9364  case UPB_TYPE_ENUM:
9365  jsonenc_enum(val.int32_val, f, e);
9366  break;
9367  case UPB_TYPE_MESSAGE:
9369  break;
9370  }
9371 }
9372 
9373 static void jsonenc_mapkey(jsonenc *e, upb_msgval val, const upb_fielddef *f) {
9374  jsonenc_putstr(e, "\"");
9375 
9376  switch (upb_fielddef_type(f)) {
9377  case UPB_TYPE_BOOL:
9378  jsonenc_putstr(e, val.bool_val ? "true" : "false");
9379  break;
9380  case UPB_TYPE_INT32:
9381  jsonenc_printf(e, "%" PRId32, val.int32_val);
9382  break;
9383  case UPB_TYPE_UINT32:
9384  jsonenc_printf(e, "%" PRIu32, val.uint32_val);
9385  break;
9386  case UPB_TYPE_INT64:
9387  jsonenc_printf(e, "%" PRId64, val.int64_val);
9388  break;
9389  case UPB_TYPE_UINT64:
9390  jsonenc_printf(e, "%" PRIu64, val.uint64_val);
9391  break;
9392  case UPB_TYPE_STRING:
9393  jsonenc_stringbody(e, val.str_val);
9394  break;
9395  default:
9396  UPB_UNREACHABLE();
9397  }
9398 
9399  jsonenc_putstr(e, "\":");
9400 }
9401 
9402 static void jsonenc_array(jsonenc *e, const upb_array *arr,
9403  const upb_fielddef *f) {
9404  size_t i;
9405  size_t size = arr ? upb_array_size(arr) : 0;
9406  bool first = true;
9407 
9408  jsonenc_putstr(e, "[");
9409 
9410  for (i = 0; i < size; i++) {
9411  jsonenc_putsep(e, ",", &first);
9412  jsonenc_scalar(e, upb_array_get(arr, i), f);
9413  }
9414 
9415  jsonenc_putstr(e, "]");
9416 }
9417 
9418 static void jsonenc_map(jsonenc *e, const upb_map *map, const upb_fielddef *f) {
9419  const upb_msgdef *entry = upb_fielddef_msgsubdef(f);
9420  const upb_fielddef *key_f = upb_msgdef_itof(entry, 1);
9421  const upb_fielddef *val_f = upb_msgdef_itof(entry, 2);
9422  size_t iter = UPB_MAP_BEGIN;
9423  bool first = true;
9424 
9425  jsonenc_putstr(e, "{");
9426 
9427  if (map) {
9428  while (upb_mapiter_next(map, &iter)) {
9429  jsonenc_putsep(e, ",", &first);
9430  jsonenc_mapkey(e, upb_mapiter_key(map, iter), key_f);
9432  }
9433  }
9434 
9435  jsonenc_putstr(e, "}");
9436 }
9437 
9438 static void jsonenc_fieldval(jsonenc *e, const upb_fielddef *f,
9439  upb_msgval val, bool *first) {
9440  const char *name;
9441 
9442  if (e->options & UPB_JSONENC_PROTONAMES) {
9444  } else {
9446  }
9447 
9448  jsonenc_putsep(e, ",", first);
9449  jsonenc_printf(e, "\"%s\":", name);
9450 
9451  if (upb_fielddef_ismap(f)) {
9452  jsonenc_map(e, val.map_val, f);
9453  } else if (upb_fielddef_isseq(f)) {
9454  jsonenc_array(e, val.array_val, f);
9455  } else {
9456  jsonenc_scalar(e, val, f);
9457  }
9458 }
9459 
9460 static void jsonenc_msgfields(jsonenc *e, const upb_msg *msg,
9461  const upb_msgdef *m, bool first) {
9462  upb_msgval val;
9463  const upb_fielddef *f;
9464 
9465  if (e->options & UPB_JSONENC_EMITDEFAULTS) {
9466  /* Iterate over all fields. */
9467  int i = 0;
9468  int n = upb_msgdef_fieldcount(m);
9469  for (i = 0; i < n; i++) {
9470  f = upb_msgdef_field(m, i);
9473  }
9474  }
9475  } else {
9476  /* Iterate over non-empty fields. */
9477  size_t iter = UPB_MSG_BEGIN;
9478  while (upb_msg_next(msg, m, e->ext_pool, &f, &val, &iter)) {
9479  jsonenc_fieldval(e, f, val, &first);
9480  }
9481  }
9482 }
9483 
9484 static void jsonenc_msg(jsonenc *e, const upb_msg *msg, const upb_msgdef *m) {
9485  jsonenc_putstr(e, "{");
9486  jsonenc_msgfields(e, msg, m, true);
9487  jsonenc_putstr(e, "}");
9488 }
9489 
9490 static size_t jsonenc_nullz(jsonenc *e, size_t size) {
9491  size_t ret = e->ptr - e->buf + e->overflow;
9492 
9493  if (size > 0) {
9494  if (e->ptr == e->end) e->ptr--;
9495  *e->ptr = '\0';
9496  }
9497 
9498  return ret;
9499 }
9500 
9501 size_t upb_json_encode(const upb_msg *msg, const upb_msgdef *m,
9502  const upb_symtab *ext_pool, int options, char *buf,
9503  size_t size, upb_status *status) {
9504  jsonenc e;
9505 
9506  e.buf = buf;
9507  e.ptr = buf;
9508  e.end = UPB_PTRADD(buf, size);
9509  e.overflow = 0;
9510  e.options = options;
9511  e.ext_pool = ext_pool;
9512  e.status = status;
9513  e.arena = NULL;
9514 
9515  if (setjmp(e.err)) return -1;
9516 
9517  jsonenc_msgfield(&e, msg, m);
9518  if (e.arena) upb_arena_free(e.arena);
9519  return jsonenc_nullz(&e, size);
9520 }
9521 
9523 /* See port_def.inc. This should #undef all macros #defined there. */
9524 
9525 #undef UPB_SIZE
9526 #undef UPB_PTR_AT
9527 #undef UPB_READ_ONEOF
9528 #undef UPB_WRITE_ONEOF
9529 #undef UPB_MAPTYPE_STRING
9530 #undef UPB_INLINE
9531 #undef UPB_ALIGN_UP
9532 #undef UPB_ALIGN_DOWN
9533 #undef UPB_ALIGN_MALLOC
9534 #undef UPB_ALIGN_OF
9535 #undef UPB_LIKELY
9536 #undef UPB_UNLIKELY
9537 #undef UPB_FORCEINLINE
9538 #undef UPB_NOINLINE
9539 #undef UPB_NORETURN
9540 #undef UPB_PRINTF
9541 #undef UPB_MAX
9542 #undef UPB_MIN
9543 #undef UPB_UNUSED
9544 #undef UPB_ASSUME
9545 #undef UPB_ASSERT
9546 #undef UPB_UNREACHABLE
9547 #undef UPB_SETJMP
9548 #undef UPB_LONGJMP
9549 #undef UPB_PTRADD
9550 #undef UPB_MUSTTAIL
9551 #undef UPB_FASTTABLE_SUPPORTED
9552 #undef UPB_FASTTABLE
9553 #undef UPB_FASTTABLE_INIT
9554 #undef UPB_POISON_MEMORY_REGION
9555 #undef UPB_UNPOISON_MEMORY_REGION
9556 #undef UPB_ASAN
upb_fielddef_enumsubdef
const upb_enumdef * upb_fielddef_enumsubdef(const upb_fielddef *f)
Definition: php-upb.c:5295
jsondec_enum
static upb_msgval jsondec_enum(jsondec *d, const upb_fielddef *f)
Definition: php-upb.c:8137
cmp_fields
int cmp_fields(const void *p1, const void *p2)
Definition: php-upb.c:5017
xds_interop_client.str
str
Definition: xds_interop_client.py:487
google_protobuf_UninterpretedOption_submsgs
static const upb_msglayout *const google_protobuf_UninterpretedOption_submsgs[1]
Definition: php-upb.c:4371
upb_syntax_t
upb_syntax_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2971
UPB_INLINE
#define UPB_INLINE
Definition: php-upb.c:90
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
memblock_reserve
static const size_t memblock_reserve
Definition: php-upb.c:2761
upb_fielddef_number
uint32_t upb_fielddef_number(const upb_fielddef *f)
Definition: php-upb.c:5179
google_protobuf_GeneratedCodeInfo__fields
static const upb_msglayout_field google_protobuf_GeneratedCodeInfo__fields[1]
Definition: php-upb.c:4434
upb_map_entry::k
union upb_map_entry::@434 k
jsondec_typeurl
static const upb_msgdef * jsondec_typeurl(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8638
wireval::uint64_val
uint64_t uint64_val
Definition: php-upb.c:395
absl::time_internal::cctz::seconds
std::chrono::duration< std::int_fast64_t > seconds
Definition: abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h:40
upb_strtable_insert
bool upb_strtable_insert(upb_strtable *t, const char *k, size_t len, upb_value v, upb_arena *a)
Definition: php-upb.c:2310
upb_msg_iter_field
upb_fielddef * upb_msg_iter_field(const upb_msg_field_iter *iter)
Definition: php-upb.c:5489
MIN_DENSITY
static const double MIN_DENSITY
Definition: php-upb.c:1871
layouts
static const upb_msglayout * layouts[27]
Definition: php-upb.c:4496
UPB_DTYPE_DOUBLE
@ UPB_DTYPE_DOUBLE
Definition: php-upb.h:554
_upb_symtab_arena
upb_arena * _upb_symtab_arena(const upb_symtab *s)
Definition: php-upb.c:6977
ctx::arena
upb_Arena * arena
Definition: conformance_upb.c:84
google_protobuf_FieldDescriptorProto_oneof_index
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_oneof_index(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:1012
UPB_SYNTAX_PROTO2
@ UPB_SYNTAX_PROTO2
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2972
upb_decode
bool upb_decode(const char *buf, size_t size, void *msg, const upb_msglayout *l, upb_arena *arena)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:742
upb_mutmsgval::msg
upb_msg * msg
Definition: php-upb.h:4628
_upb_lg2ceilsize
UPB_INLINE int _upb_lg2ceilsize(int x)
Definition: php-upb.h:609
UPB_TYPE_UINT64
@ UPB_TYPE_UINT64
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:487
mem_block::cleanups
uint32_t cleanups
Definition: php-upb.c:2752
upb_oneofdef::synthetic
bool synthetic
Definition: php-upb.c:4924
decode_tomsg
static const char * decode_tomsg(upb_decstate *d, const char *ptr, upb_msg *msg, upb_msglayout const *const *submsgs, const upb_msglayout_field *field, wireval *val, int op)
Definition: php-upb.c:756
upb_inttable_lookup
bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v)
Definition: php-upb.c:2502
fixed32_ok
static const unsigned fixed32_ok
Definition: php-upb.c:311
upb_fielddef_descriptortype
upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f)
Definition: php-upb.c:5167
upb_arena_malloc
UPB_INLINE void * upb_arena_malloc(upb_arena *a, size_t size)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:383
dst
static const char dst[]
Definition: test-fs-copyfile.c:37
jsondec_objend
static void jsondec_objend(jsondec *d)
Definition: php-upb.c:7556
upb_strtable_iter_key
upb_strview upb_strtable_iter_key(const upb_strtable_iter *i)
Definition: php-upb.c:2362
isfull
static bool isfull(upb_table *t)
Definition: php-upb.c:1946
_upb_fasttable_entry
Definition: php-upb.h:1128
test_server.argp
argp
Definition: test_server.py:33
vsnprintf
int __cdecl vsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
Definition: libc.cpp:135
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
_upb_clearhas_field
UPB_INLINE void _upb_clearhas_field(const upb_msg *msg, const upb_msglayout_field *f)
Definition: php-upb.h:1296
upb_symtab_lookupfile
const upb_filedef * upb_symtab_lookupfile(const upb_symtab *s, const char *name)
Definition: php-upb.c:5693
upb_msgdef::map_entry
bool map_entry
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2978
upb_enumdef_numvals
int upb_enumdef_numvals(const upb_enumdef *e)
Definition: php-upb.c:5090
upb_arena
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2252
google_protobuf_FieldDescriptorProto_proto3_optional
UPB_INLINE bool google_protobuf_FieldDescriptorProto_proto3_optional(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:1032
inttable_val
static upb_tabval * inttable_val(upb_inttable *t, uintptr_t key)
Definition: php-upb.c:2404
upb_msglayout_field::offset
uint16_t offset
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:558
OP_VARPCK_LG2
#define OP_VARPCK_LG2(n)
Definition: php-upb.c:326
upb_symtab_new
upb_symtab * upb_symtab_new(void)
Definition: php-upb.c:5655
jsonenc_listvalue
static void jsonenc_listvalue(jsonenc *e, const upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:9239
regen-readme.it
it
Definition: regen-readme.py:15
google_protobuf_FieldDescriptorProto_msginit
const upb_msglayout google_protobuf_FieldDescriptorProto_msginit
Definition: php-upb.c:4119
upb_oneofdef_itof
const upb_fielddef * upb_oneofdef_itof(const upb_oneofdef *o, uint32_t num)
Definition: php-upb.c:5574
decode_tryfastdispatch
static UPB_FORCEINLINE bool decode_tryfastdispatch(upb_decstate *d, const char **ptr, upb_msg *msg, const upb_msglayout *layout)
Definition: php-upb.c:813
findentry_mutable
static upb_tabent * findentry_mutable(upb_table *t, lookupkey_t key, uint32_t hash, eqlfunc_t *eql)
Definition: php-upb.c:1998
upb_inttable_count
size_t upb_inttable_count(const upb_inttable *t)
Definition: php-upb.c:2419
encode_double
static void encode_double(upb_encstate *e, double d)
Definition: php-upb.c:1117
google_protobuf_EnumOptions_msginit
const upb_msglayout google_protobuf_EnumOptions_msginit
Definition: php-upb.c:4319
Wyhash
static uint64_t Wyhash(const void *data, size_t len, uint64_t seed, const uint64_t salt[])
Definition: php-upb.c:2180
upb_arena_allocblock
static bool upb_arena_allocblock(upb_arena *a, size_t size)
Definition: php-upb.c:2794
_upb_lg2ceil
UPB_INLINE int _upb_lg2ceil(int x)
Definition: php-upb.h:598
jsondec_resize
static void jsondec_resize(jsondec *d, char **buf, char **end, char **buf_end)
Definition: php-upb.c:7743
upb_symtab_lookupenum
const upb_enumdef * upb_symtab_lookupenum(const upb_symtab *s, const char *sym)
Definition: php-upb.c:5687
jsondec_uint
static upb_msgval jsondec_uint(jsondec *d, const upb_fielddef *f)
Definition: php-upb.c:8056
google_protobuf_FileDescriptorProto_dependency
UPB_INLINE upb_StringView const * google_protobuf_FileDescriptorProto_dependency(const google_protobuf_FileDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:272
google_protobuf_ServiceOptions_submsgs
static const upb_msglayout *const google_protobuf_ServiceOptions_submsgs[1]
Definition: php-upb.c:4340
google_protobuf_FieldDescriptorProto_options
const UPB_INLINE google_protobuf_FieldOptions * google_protobuf_FieldDescriptorProto_options(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:1002
upb_label_t
upb_label_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:491
upb_msglayout::fields
const upb_msglayout_field * fields
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:567
encode_longvarint
static UPB_NOINLINE void encode_longvarint(upb_encstate *e, uint64_t val)
Definition: php-upb.c:1096
jsonenc_msgfields
static void jsonenc_msgfields(jsonenc *e, const upb_msg *msg, const upb_msgdef *m, bool first)
Definition: php-upb.c:9460
upb_fielddef_defaultdouble
double upb_fielddef_defaultdouble(const upb_fielddef *f)
Definition: php-upb.c:5272
streql
static bool streql(upb_tabkey k1, lookupkey_t k2)
Definition: php-upb.c:2274
upb_msg_oneof_iter_isequal
bool upb_msg_oneof_iter_isequal(const upb_msg_oneof_iter *iter1, const upb_msg_oneof_iter *iter2)
Definition: php-upb.c:5531
upb_enumdef_ntoi
bool upb_enumdef_ntoi(const upb_enumdef *def, const char *name, size_t len, int32_t *num)
Definition: php-upb.c:5102
ctx
Definition: benchmark-async.c:30
const
#define const
Definition: bloaty/third_party/zlib/zconf.h:230
upb_oneof_iter_field
upb_fielddef * upb_oneof_iter_field(const upb_oneof_iter *iter)
Definition: php-upb.c:5592
jsondec::status
upb_status * status
Definition: php-upb.c:7373
field_number_cmp
static int field_number_cmp(const void *p1, const void *p2)
Definition: php-upb.c:5828
JD_FALSE
@ JD_FALSE
Definition: php-upb.c:7382
upb_fielddef_checktype
bool upb_fielddef_checktype(int32_t type)
Definition: php-upb.c:5340
_upb_msg_clear
void _upb_msg_clear(upb_msg *msg, const upb_msglayout *l)
Definition: php-upb.c:1496
_upb_fieldtype_to_sizelg2
static const char _upb_fieldtype_to_sizelg2[12]
Definition: php-upb.c:7029
upb_json_decode
bool upb_json_decode(const char *buf, size_t size, upb_msg *msg, const upb_msgdef *m, const upb_symtab *any_pool, int options, upb_arena *arena, upb_status *status)
Definition: php-upb.c:8775
UPB_TYPE_FLOAT
@ UPB_TYPE_FLOAT
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:476
upb_msgdef_oneofcount
int upb_msgdef_oneofcount(const upb_msgdef *m)
Definition: php-upb.c:5437
UPB_WELLKNOWN_STRINGVALUE
@ UPB_WELLKNOWN_STRINGVALUE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2994
_upb_arena_slowmalloc
void * _upb_arena_slowmalloc(upb_arena *a, size_t size)
Definition: php-upb.c:2804
UPB_WELLKNOWN_DOUBLEVALUE
@ UPB_WELLKNOWN_DOUBLEVALUE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2987
upb_msgval::array_val
const upb_array * array_val
Definition: php-upb.h:4622
_upb_array_tagptr
UPB_INLINE uintptr_t _upb_array_tagptr(void *ptr, int elem_size_lg2)
Definition: php-upb.h:1345
memset
return memset(p, 0, total)
upb_symtab_filecount
int upb_symtab_filecount(const upb_symtab *s)
Definition: php-upb.c:5706
upb_inttable_init
bool upb_inttable_init(upb_inttable *t, upb_arena *a)
Definition: php-upb.c:2458
encode_scalar
static void encode_scalar(upb_encstate *e, const void *_field_mem, const upb_msglayout *m, const upb_msglayout_field *f, bool skip_zero_value)
Definition: php-upb.c:1156
delim_ops
static const int8_t delim_ops[37]
Definition: php-upb.c:350
upb_status
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:197
file
const grpc_generator::File * file
Definition: python_private_generator.h:38
upb_fielddef_type
upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f)
Definition: php-upb.c:5132
UPB_DTYPE_SFIXED32
@ UPB_DTYPE_SFIXED32
Definition: php-upb.h:568
UPB_SIZE
#define UPB_SIZE(size32, size64)
Definition: php-upb.c:65
google_protobuf_EnumDescriptorProto_submsgs
static const upb_msglayout *const google_protobuf_EnumDescriptorProto_submsgs[3]
Definition: php-upb.c:4140
upb_filedef::ext_count
int ext_count
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3015
UPB_DESCRIPTOR_TYPE_STRING
@ UPB_DESCRIPTOR_TYPE_STRING
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:507
fill_fieldlayout
static void fill_fieldlayout(upb_msglayout_field *field, const upb_fielddef *f)
Definition: php-upb.c:5851
jsondec::line_begin
const char * line_begin
Definition: php-upb.c:7376
decode_readstr
static const char * decode_readstr(upb_decstate *d, const char *ptr, int size, upb_strview *str)
Definition: php-upb.c:577
google_protobuf_FieldOptions_lazy
UPB_INLINE bool google_protobuf_FieldOptions_lazy(const google_protobuf_FieldOptions *msg)
Definition: descriptor.upb.h:2156
upb_fielddef_defaultuint64
uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f)
Definition: php-upb.c:5252
upb_cleanup_func
void upb_cleanup_func(void *ud)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:362
upb_msglayout_field::descriptortype
uint8_t descriptortype
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:561
upb_filedef::exts
const upb_fielddef * exts
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3010
UPB_STRVIEW_INIT
#define UPB_STRVIEW_INIT(ptr, len)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:277
upb_msgdef::well_known_type
upb_wellknowntype_t well_known_type
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2979
upb_extreg
Definition: php-upb.c:1793
upb_fielddef::msgdef
const upb_msgdef * msgdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2936
upb_tabent_isempty
UPB_INLINE bool upb_tabent_isempty(const upb_tabent *e)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:871
upb_enumdef_iton
const char * upb_enumdef_iton(const upb_enumdef *def, int32_t num)
Definition: php-upb.c:5112
upb_msg_field_iter_isequal
bool upb_msg_field_iter_isequal(const upb_msg_field_iter *iter1, const upb_msg_field_iter *iter2)
Definition: php-upb.c:5497
upb_msgval::map_val
const upb_map * map_val
Definition: php-upb.h:4620
upb_msgval::uint64_val
uint64_t uint64_val
Definition: php-upb.h:4619
upb_symtab_lookupmsg2
const upb_msgdef * upb_symtab_lookupmsg2(const upb_symtab *s, const char *sym, size_t len)
Definition: php-upb.c:5680
upb_fielddef_issubmsg
bool upb_fielddef_issubmsg(const upb_fielddef *f)
Definition: php-upb.c:5303
_upb_sortedmap::end
int end
Definition: php-upb.h:1697
google_protobuf_MethodOptions_submsgs
static const upb_msglayout *const google_protobuf_MethodOptions_submsgs[1]
Definition: php-upb.c:4355
encode_map
static void encode_map(upb_encstate *e, const upb_msg *msg, const upb_msglayout *m, const upb_msglayout_field *f)
Definition: php-upb.c:1364
uint16_t
unsigned short uint16_t
Definition: stdint-msvc2008.h:79
DECODE_NOGROUP
#define DECODE_NOGROUP
Definition: php-upb.h:1770
upb_msgdef_file
const upb_filedef * upb_msgdef_file(const upb_msgdef *m)
Definition: php-upb.c:5353
upb_arrhas
static bool upb_arrhas(upb_tabval key)
Definition: php-upb.c:1941
_upb_sortedmap::start
int start
Definition: php-upb.h:1695
upb_msgdef_isnumberwrapper
bool upb_msgdef_isnumberwrapper(const upb_msgdef *m)
Definition: php-upb.c:5467
upb_enum_iter_name
const char * upb_enum_iter_name(upb_enum_iter *iter)
Definition: php-upb.c:5117
jsondec_epochdays
int jsondec_epochdays(int y, int m, int d)
Definition: php-upb.c:8371
upb_filedef::msgs
const upb_msgdef * msgs
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3008
upb_symtab_lookupfile2
const upb_filedef * upb_symtab_lookupfile2(const upb_symtab *s, const char *name, size_t len)
Definition: php-upb.c:5699
upb_msgdef::field_count
int field_count
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2974
xds_manager.f1
f1
Definition: xds_manager.py:42
upb_filedef_phpnamespace
const char * upb_filedef_phpnamespace(const upb_filedef *f)
Definition: php-upb.c:5614
assign_msg_wellknowntype
static void assign_msg_wellknowntype(upb_msgdef *m)
Definition: php-upb.c:5027
_upb_be_swap64
UPB_INLINE uint64_t _upb_be_swap64(uint64_t val)
Definition: php-upb.h:590
upb_msg_whichoneof
const upb_fielddef * upb_msg_whichoneof(const upb_msg *msg, const upb_oneofdef *o)
Definition: php-upb.c:7075
decode_poplimit
UPB_INLINE void decode_poplimit(upb_decstate *d, const char *ptr, int saved_delta)
Definition: php-upb.h:1908
google_protobuf_UninterpretedOption_NamePart__fields
static const upb_msglayout_field google_protobuf_UninterpretedOption_NamePart__fields[2]
Definition: php-upb.c:4391
google_protobuf_EnumValueDescriptorProto
struct google_protobuf_EnumValueDescriptorProto google_protobuf_EnumValueDescriptorProto
Definition: descriptor.upb.h:60
realloc_internal
static bool realloc_internal(upb_msg *msg, size_t need, upb_arena *arena)
Definition: php-upb.c:1501
WRITE
#define WRITE(byte)
decode_vret
Definition: php-upb.c:447
test
Definition: spinlock_test.cc:36
desctype_to_elem_size_lg2
static const uint8_t desctype_to_elem_size_lg2[]
Definition: php-upb.c:266
jsondec_unixtime
static int64_t jsondec_unixtime(int y, int m, int d, int h, int min, int s)
Definition: php-upb.c:8382
jsondec_buftoint64
static const char * jsondec_buftoint64(jsondec *d, const char *ptr, const char *end, int64_t *val)
Definition: php-upb.c:7980
upb_map_entry::v
union upb_map_entry::@435 v
y
const double y
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3611
upb_msgdef_realoneofcount
int upb_msgdef_realoneofcount(const upb_msgdef *m)
Definition: php-upb.c:5441
upb_value
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:681
_upb_array_resize_fallback
void * _upb_array_resize_fallback(upb_array **arr_ptr, size_t size, int elem_size_lg2, upb_arena *arena)
Definition: php-upb.c:1637
upb_symtab_addfile
const upb_filedef * upb_symtab_addfile(upb_symtab *s, const google_protobuf_FileDescriptorProto *file_proto, upb_status *status)
Definition: php-upb.c:6918
jsondec_base64_tablelookup
static unsigned int jsondec_base64_tablelookup(const char ch)
Definition: php-upb.c:7845
upb_def_init
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:3769
ext
void * ext
Definition: x509v3.h:87
upb_oneofdef::itof
upb_inttable itof
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2997
_upb_mapsorter
Definition: php-upb.h:1688
upb_fielddef_containingtype
const upb_msgdef * upb_fielddef_containingtype(const upb_fielddef *f)
Definition: php-upb.c:5207
google_protobuf_FieldDescriptorProto_default_value
UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_default_value(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:993
upb_msg_oneof_next
void upb_msg_oneof_next(upb_msg_oneof_iter *iter)
Definition: php-upb.c:5511
INT64_MAX
#define INT64_MAX
Definition: stdint-msvc2008.h:139
upb_fieldtype_t
upb_fieldtype_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:472
UPB_MAX
#define UPB_MAX(x, y)
Definition: php-upb.c:125
JD_NUMBER
@ JD_NUMBER
Definition: php-upb.c:7382
string.h
copy
static int copy(grpc_slice_buffer *input, grpc_slice_buffer *output)
Definition: message_compress.cc:145
options
double_dict options[]
Definition: capstone_test.c:55
create_msgdef
static void create_msgdef(symtab_addctx *ctx, const char *prefix, const google_protobuf_DescriptorProto *msg_proto)
Definition: php-upb.c:6571
upb_fielddef::full_name
const char * full_name
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2937
google_protobuf_FileDescriptorProto__fields
static const upb_msglayout_field google_protobuf_FileDescriptorProto__fields[12]
Definition: php-upb.c:4010
jsondec_push
static void jsondec_push(jsondec *d)
Definition: php-upb.c:7521
upb_oneofdef::fields
const upb_fielddef ** fields
Definition: php-upb.c:4925
_upb_map_next
UPB_INLINE void * _upb_map_next(const upb_map *map, size_t *iter)
Definition: php-upb.h:1578
upb_mutmsgval
Definition: php-upb.h:4626
google_protobuf_GeneratedCodeInfo_Annotation__fields
static const upb_msglayout_field google_protobuf_GeneratedCodeInfo_Annotation__fields[4]
Definition: php-upb.c:4444
jsondec_arrend
static void jsondec_arrend(jsondec *d)
Definition: php-upb.c:7542
seed
static const uint8_t seed[20]
Definition: dsa_test.cc:79
encode_err
static UPB_NORETURN void encode_err(upb_encstate *e)
Definition: php-upb.c:1042
upb_arena_alloc
UPB_INLINE upb_alloc * upb_arena_alloc(upb_arena *a)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:379
google_protobuf_MethodDescriptorProto__fields
static const upb_msglayout_field google_protobuf_MethodDescriptorProto__fields[6]
Definition: php-upb.c:4208
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
parse_default
static void parse_default(symtab_addctx *ctx, const char *str, size_t len, upb_fielddef *f)
Definition: php-upb.c:6213
upb_msgdef_ntof
const upb_fielddef * upb_msgdef_ntof(const upb_msgdef *m, const char *name, size_t len)
Definition: php-upb.c:5371
upb_fielddef_checkdescriptortype
bool upb_fielddef_checkdescriptortype(int32_t type)
Definition: php-upb.c:5343
jsondec_rawpeek
static int jsondec_rawpeek(jsondec *d)
Definition: php-upb.c:7475
upb_symtab_free
void upb_symtab_free(upb_symtab *s)
Definition: php-upb.c:5650
jsondec_int
static upb_msgval jsondec_int(jsondec *d, const upb_fielddef *f)
Definition: php-upb.c:8020
upb_extreg::arena
upb_arena * arena
Definition: php-upb.c:1794
UPB_DEFTYPE_ENUM
@ UPB_DEFTYPE_ENUM
Definition: php-upb.c:4962
UPB_WIRE_TYPE_END_GROUP
@ UPB_WIRE_TYPE_END_GROUP
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:465
check
static void check(upb_inttable *t)
Definition: php-upb.c:2423
google_protobuf_EnumDescriptorProto_value
const UPB_INLINE google_protobuf_EnumValueDescriptorProto *const * google_protobuf_EnumDescriptorProto_value(const google_protobuf_EnumDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:1206
UPB_ALIGN_UP
#define UPB_ALIGN_UP(size, align)
Definition: php-upb.c:93
jsondec_field
static void jsondec_field(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8247
elem
Timer elem
Definition: event_engine/iomgr_event_engine/timer_heap_test.cc:109
upb_map_clear
void upb_map_clear(upb_map *map)
Definition: php-upb.c:7308
upb_fielddef::packed_
bool packed_
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2957
_upb_sethas_field
UPB_INLINE void _upb_sethas_field(const upb_msg *msg, const upb_msglayout_field *f)
Definition: php-upb.h:1291
google_protobuf_FileOptions_submsgs
static const upb_msglayout *const google_protobuf_FileOptions_submsgs[1]
Definition: php-upb.c:4223
upb_msg_field_iter_setdone
void upb_msg_field_iter_setdone(upb_msg_field_iter *iter)
Definition: php-upb.c:5493
UPB_WELLKNOWN_UNSPECIFIED
@ UPB_WELLKNOWN_UNSPECIFIED
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2981
upb_fielddef_defaultuint32
uint32_t upb_fielddef_defaultuint32(const upb_fielddef *f)
Definition: php-upb.c:5257
google_protobuf_EnumValueDescriptorProto_submsgs
static const upb_msglayout *const google_protobuf_EnumValueDescriptorProto_submsgs[1]
Definition: php-upb.c:4171
binary_size.new_size
def new_size
Definition: binary_size.py:124
UINT64_MAX
#define UINT64_MAX
Definition: stdint-msvc2008.h:143
error_ref_leak.err
err
Definition: error_ref_leak.py:35
upb_msgdef_iswrapper
bool upb_msgdef_iswrapper(const upb_msgdef *m)
Definition: php-upb.c:5473
upb_msgdef_lookupname
bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len, const upb_fielddef **f, const upb_oneofdef **o)
Definition: php-upb.c:5393
create_oneofdef
static void create_oneofdef(symtab_addctx *ctx, upb_msgdef *m, const google_protobuf_OneofDescriptorProto *oneof_proto)
Definition: php-upb.c:6183
upb_msgdef_fieldcount
int upb_msgdef_fieldcount(const upb_msgdef *m)
Definition: php-upb.c:5433
_upb_msg_getraw
static upb_msgval _upb_msg_getraw(const upb_msg *msg, const upb_fielddef *f)
Definition: php-upb.c:7054
_UPB_MODE_SCALAR
@ _UPB_MODE_SCALAR
Definition: php-upb.h:1099
UPB_DESCRIPTOR_TYPE_FIXED32
@ UPB_DESCRIPTOR_TYPE_FIXED32
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:505
upb_array_append
bool upb_array_append(upb_array *arr, upb_msgval val, upb_arena *arena)
Definition: php-upb.c:7280
upb_tabent
struct _upb_tabent upb_tabent
google_protobuf_FieldOptions_submsgs
static const upb_msglayout *const google_protobuf_FieldOptions_submsgs[1]
Definition: php-upb.c:4275
set_default_default
static void set_default_default(symtab_addctx *ctx, upb_fielddef *f)
Definition: php-upb.c:6325
upb_arena::freelist_tail
mem_block * freelist_tail
Definition: php-upb.h:1763
symtab_addctx::symtab
upb_symtab * symtab
Definition: php-upb.c:5720
upb_msg_next
bool upb_msg_next(const upb_msg *msg, const upb_msgdef *m, const upb_symtab *ext_pool, const upb_fielddef **out_f, upb_msgval *out_val, size_t *iter)
Definition: php-upb.c:7164
google_protobuf_DescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_DescriptorProto_name(const google_protobuf_DescriptorProto *msg)
Definition: descriptor.upb.h:504
UINT32_MAX
#define UINT32_MAX
Definition: stdint-msvc2008.h:142
upb_inttable_compact
void upb_inttable_compact(upb_inttable *t, upb_arena *a)
Definition: php-upb.c:2537
file
Definition: bloaty/third_party/zlib/examples/gzappend.c:170
UPB_SETJMP
#define UPB_SETJMP(buf)
Definition: php-upb.c:163
google_protobuf_FileOptions_php_namespace
UPB_INLINE upb_StringView google_protobuf_FileOptions_php_namespace(const google_protobuf_FileOptions *msg)
Definition: descriptor.upb.h:1842
UPB_DESCRIPTOR_TYPE_SFIXED64
@ UPB_DESCRIPTOR_TYPE_SFIXED64
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:514
google_protobuf_SourceCodeInfo__fields
static const upb_msglayout_field google_protobuf_SourceCodeInfo__fields[1]
Definition: php-upb.c:4406
upb_msg_get
upb_msgval upb_msg_get(const upb_msg *msg, const upb_fielddef *f)
Definition: php-upb.c:7090
symtab_add
static void symtab_add(symtab_addctx *ctx, const char *name, upb_value v)
Definition: php-upb.c:6140
encode_mapentry
static void encode_mapentry(upb_encstate *e, uint32_t number, const upb_msglayout *layout, const upb_map_entry *ent)
Definition: php-upb.c:1350
google_protobuf_FileDescriptorProto_options
const UPB_INLINE google_protobuf_FileOptions * google_protobuf_FileDescriptorProto_options(const google_protobuf_FileDescriptorProto *msg)
Definition: descriptor.upb.h:317
jsondec_wsch
static void jsondec_wsch(jsondec *d, char ch)
Definition: php-upb.c:7459
absl::hash_internal::k2
static const uint64_t k2
Definition: abseil-cpp/absl/hash/internal/city.cc:55
upb_arena::block_alloc
upb_alloc * block_alloc
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2259
upb_find_field
static const upb_msglayout_field * upb_find_field(const upb_msglayout *l, uint32_t field_number, int *last_field_index)
Definition: php-upb.c:526
status
absl::Status status
Definition: rls.cc:251
varint_ops
static const int8_t varint_ops[19]
Definition: php-upb.c:328
_upb_map_get
UPB_INLINE bool _upb_map_get(const upb_map *map, const void *key, size_t key_size, void *val, size_t val_size)
Definition: php-upb.h:1567
jsondec_struct
static void jsondec_struct(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8492
UPB_TYPE_UINT32
@ UPB_TYPE_UINT32
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:478
upb_enumdef_name
const char * upb_enumdef_name(const upb_enumdef *e)
Definition: php-upb.c:5077
ctx
static struct test_ctx ctx
Definition: test-ipc-send-recv.c:65
lookup
static bool lookup(const upb_table *t, lookupkey_t key, upb_value *v, uint32_t hash, eqlfunc_t *eql)
Definition: php-upb.c:2003
upb_tabstr
UPB_INLINE char * upb_tabstr(upb_tabkey key, uint32_t *len)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:789
upb_strtable_resize
bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_arena *a)
Definition: php-upb.c:2294
upb_msg_has
bool upb_msg_has(const upb_msg *msg, const upb_fielddef *f)
Definition: php-upb.c:7062
setup.name
name
Definition: setup.py:542
upb_symtab::bytes_loaded
size_t bytes_loaded
Definition: php-upb.c:4953
jsonenc::status
upb_status * status
Definition: php-upb.c:8821
jsondec_isvalue
static bool jsondec_isvalue(const upb_fielddef *f)
Definition: php-upb.c:7401
encode_fixedarray
static void encode_fixedarray(upb_encstate *e, const upb_array *arr, size_t elem_size, uint32_t tag)
Definition: php-upb.c:1136
upb_msgdef_numrealoneofs
int upb_msgdef_numrealoneofs(const upb_msgdef *m)
Definition: php-upb.c:5429
upb_enum_iter_number
int32_t upb_enum_iter_number(upb_enum_iter *iter)
Definition: php-upb.c:5121
UPB_DESCRIPTOR_TYPE_GROUP
@ UPB_DESCRIPTOR_TYPE_GROUP
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:508
jsonenc_mapkey
static void jsonenc_mapkey(jsonenc *e, upb_msgval val, const upb_fielddef *f)
Definition: php-upb.c:9373
google_protobuf_MethodDescriptorProto_submsgs
static const upb_msglayout *const google_protobuf_MethodDescriptorProto_submsgs[1]
Definition: php-upb.c:4204
getorcreate_array
static upb_array * getorcreate_array(upb_array **arr_ptr, int elem_size_lg2, upb_arena *arena)
Definition: php-upb.c:1626
UPB_MIN
#define UPB_MIN(x, y)
Definition: php-upb.c:126
check_documentation.path
path
Definition: check_documentation.py:57
google_protobuf_FieldDescriptorProto_number
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_number(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:953
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
UPB_DESCRIPTOR_TYPE_BYTES
@ UPB_DESCRIPTOR_TYPE_BYTES
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:510
_upb_tag_arrptr
UPB_INLINE uintptr_t _upb_tag_arrptr(void *ptr, int elem_size_lg2)
Definition: php-upb.h:1354
UPB_ASSERT
#define UPB_ASSERT(expr)
Definition: php-upb.c:149
EXTREG_KEY_SIZE
#define EXTREG_KEY_SIZE
Definition: php-upb.c:1798
upb_fielddef::sub
union upb_fielddef::@207 sub
UPB_DTYPE_FIXED64
@ UPB_DTYPE_FIXED64
Definition: php-upb.h:559
_upb_msg_getorcreateext
upb_msg_ext * _upb_msg_getorcreateext(upb_msg *msg, const upb_msglayout_ext *e, upb_arena *arena)
Definition: php-upb.c:1589
decode_totable
UPB_INLINE intptr_t decode_totable(const upb_msglayout *tablep)
Definition: php-upb.h:1820
xds_manager.p
p
Definition: xds_manager.py:60
upb_inttable::t
upb_table t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:849
_upb_msg_getext
const upb_msg_ext * _upb_msg_getext(const upb_msg *msg, const upb_msglayout_ext *e)
Definition: php-upb.c:1572
upb_oneofdef_index
uint32_t upb_oneofdef_index(const upb_oneofdef *o)
Definition: php-upb.c:5559
arena_initslow
upb_arena * arena_initslow(void *mem, size_t n, upb_alloc *alloc)
Definition: php-upb.c:2818
_upb_mapsorter_pushmap
bool _upb_mapsorter_pushmap(_upb_mapsorter *s, upb_descriptortype_t key_type, const upb_map *map, _upb_sortedmap *sorted)
Definition: php-upb.c:1725
upb_msglayout_place
static uint32_t upb_msglayout_place(upb_msglayout *l, size_t size)
Definition: php-upb.c:5819
decode_varint64
static const UPB_FORCEINLINE char * decode_varint64(upb_decstate *d, const char *ptr, uint64_t *val)
Definition: php-upb.c:470
decode_totablep
const UPB_INLINE upb_msglayout * decode_totablep(intptr_t table)
Definition: php-upb.h:1824
jsondec_errf
static UPB_NORETURN void jsondec_errf(jsondec *d, const char *fmt,...)
Definition: php-upb.c:7415
jsonenc
Definition: php-upb.c:8814
upb_status_clear
void upb_status_clear(upb_status *status)
Definition: php-upb.c:2676
jsondec_strtoint64
static int64_t jsondec_strtoint64(jsondec *d, upb_strview str)
Definition: php-upb.c:8008
google_protobuf_MessageOptions__fields
static const upb_msglayout_field google_protobuf_MessageOptions__fields[5]
Definition: php-upb.c:4261
UPB_PTR_AT
#define UPB_PTR_AT(msg, ofs, type)
Definition: php-upb.c:71
jsondec_false
static void jsondec_false(jsondec *d)
Definition: php-upb.c:7467
google_protobuf_FieldDescriptorProto_extendee
UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_extendee(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:943
google_protobuf_DescriptorProto_oneof_decl
const UPB_INLINE google_protobuf_OneofDescriptorProto *const * google_protobuf_DescriptorProto_oneof_decl(const google_protobuf_DescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:567
z
Uncopyable z
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3612
JD_ARRAY
@ JD_ARRAY
Definition: php-upb.c:7382
upb_msgval::str_val
upb_strview str_val
Definition: php-upb.h:4623
upb_strview::data
const char * data
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:258
UPB_PB_VARINT_MAX_LEN
#define UPB_PB_VARINT_MAX_LEN
Definition: php-upb.c:1008
mutable_array
static upb_tabval * mutable_array(upb_inttable *t)
Definition: php-upb.c:2400
google_protobuf_OneofDescriptorProto
struct google_protobuf_OneofDescriptorProto google_protobuf_OneofDescriptorProto
Definition: descriptor.upb.h:57
decode_top
static bool decode_top(struct upb_decstate *d, const char *buf, void *msg, const upb_msglayout *l)
Definition: php-upb.c:941
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
UPB_PRINTF
#define UPB_PRINTF(str, first_vararg)
Definition: php-upb.c:122
jsonenc_nullz
static size_t jsonenc_nullz(jsonenc *e, size_t size)
Definition: php-upb.c:9490
OP_FIXPCK_LG2
#define OP_FIXPCK_LG2(n)
Definition: php-upb.c:325
setup.k
k
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
upb_status_seterrf
void upb_status_seterrf(upb_status *status, const char *fmt,...)
Definition: php-upb.c:2693
UPB_MAXARRSIZE
#define UPB_MAXARRSIZE
Definition: php-upb.c:1860
jsondec_double
static upb_msgval jsondec_double(jsondec *d, const upb_fielddef *f)
Definition: php-upb.c:8092
google_protobuf_EnumValueDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_EnumValueDescriptorProto_name(const google_protobuf_EnumValueDescriptorProto *msg)
Definition: descriptor.upb.h:1384
google_protobuf_DescriptorProto_ReservedRange__fields
static const upb_msglayout_field google_protobuf_DescriptorProto_ReservedRange__fields[2]
Definition: php-upb.c:4076
map
zval * map
Definition: php/ext/google/protobuf/encode_decode.c:480
jsondec_strtouint64
static uint64_t jsondec_strtouint64(jsondec *d, upb_strview str)
Definition: php-upb.c:7999
upb_enumdef::full_name
const char * full_name
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2986
upb_msgdef::file
const upb_filedef * file
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2963
_upb_getoneofcase_field
UPB_INLINE uint32_t _upb_getoneofcase_field(const upb_msg *msg, const upb_msglayout_field *f)
Definition: php-upb.h:1321
jsondec_number
static double jsondec_number(jsondec *d)
Definition: php-upb.c:7590
upb_arena::cleanup_metadata
uintptr_t cleanup_metadata
Definition: php-upb.h:1749
encode_scalarfield
static void encode_scalarfield(upb_encstate *e, const char *msg, const upb_msglayout *m, const upb_msglayout_field *f)
Definition: php-upb.c:1395
jsondec_base64
static size_t jsondec_base64(jsondec *d, upb_strview str)
Definition: php-upb.c:7918
upb_fielddef_jsonname
const char * upb_fielddef_jsonname(const upb_fielddef *f)
Definition: php-upb.c:5199
upb_msg_set
void upb_msg_set(upb_msg *msg, const upb_fielddef *f, upb_msgval val, upb_arena *a)
Definition: php-upb.c:7132
google_protobuf_UninterpretedOption__fields
static const upb_msglayout_field google_protobuf_UninterpretedOption__fields[7]
Definition: php-upb.c:4375
google_protobuf_ServiceDescriptorProto_msginit
const upb_msglayout google_protobuf_ServiceDescriptorProto_msginit
Definition: php-upb.c:4198
jsonenc_printf
static void jsonenc_printf(jsonenc *e, const char *fmt,...)
Definition: php-upb.c:8874
google_protobuf_SourceCodeInfo_Location_msginit
const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit
Definition: php-upb.c:4424
upb_msgdef_ntoo
const upb_oneofdef * upb_msgdef_ntoo(const upb_msgdef *m, const char *name, size_t len)
Definition: php-upb.c:5382
upb_getentry
static const upb_tabent * upb_getentry(const upb_table *t, uint32_t hash)
Definition: php-upb.c:1937
upb_msg_clear
void upb_msg_clear(upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:7160
upb_msg
void upb_msg
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:548
UPB_JSONENC_PROTONAMES
@ UPB_JSONENC_PROTONAMES
Definition: php-upb.h:4806
upb_fielddef_isseq
bool upb_fielddef_isseq(const upb_fielddef *f)
Definition: php-upb.c:5312
google_protobuf_GeneratedCodeInfo_submsgs
static const upb_msglayout *const google_protobuf_GeneratedCodeInfo_submsgs[1]
Definition: php-upb.c:4430
encode_float
static void encode_float(upb_encstate *e, float d)
Definition: php-upb.c:1124
google_protobuf_EnumValueDescriptorProto__fields
static const upb_msglayout_field google_protobuf_EnumValueDescriptorProto__fields[3]
Definition: php-upb.c:4175
_upb_msg_discardunknown
bool _upb_msg_discardunknown(upb_msg *msg, const upb_msgdef *m, int depth)
Definition: php-upb.c:7204
unpack_def
static const void * unpack_def(upb_value v, upb_deftype_t type)
Definition: php-upb.c:4969
makejsonname
static char * makejsonname(symtab_addctx *ctx, const char *name)
Definition: php-upb.c:6133
jsondec_peek
static int jsondec_peek(jsondec *d)
Definition: php-upb.c:7516
google_protobuf_FieldDescriptorProto
struct google_protobuf_FieldDescriptorProto google_protobuf_FieldDescriptorProto
Definition: descriptor.upb.h:56
google_protobuf_FileDescriptorProto_submsgs
static const upb_msglayout *const google_protobuf_FileDescriptorProto_submsgs[6]
Definition: php-upb.c:4001
google_protobuf_FieldOptions__fields
static const upb_msglayout_field google_protobuf_FieldOptions__fields[7]
Definition: php-upb.c:4279
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
decode_longvarint64
static UPB_NOINLINE decode_vret decode_longvarint64(const char *ptr, uint64_t val)
Definition: php-upb.c:453
_upb_msg_discardunknown_shallow
void _upb_msg_discardunknown_shallow(upb_msg *msg)
Definition: php-upb.c:1542
jsondec_listvalue
static void jsondec_listvalue(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8476
jsonenc_msgfield
static void jsonenc_msgfield(jsonenc *e, const upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:9294
jsondec::line
int line
Definition: php-upb.c:7375
UPB_WELLKNOWN_VALUE
@ UPB_WELLKNOWN_VALUE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2997
python_utils.port_server.stderr
stderr
Definition: port_server.py:51
upb_filedef_syntax
upb_syntax_t upb_filedef_syntax(const upb_filedef *f)
Definition: php-upb.c:5618
arena_dofree
static void arena_dofree(upb_arena *a)
Definition: php-upb.c:2870
upb_inttable_iter_isequal
bool upb_inttable_iter_isequal(const upb_inttable_iter *i1, const upb_inttable_iter *i2)
Definition: php-upb.c:2655
upb_msg_getunknown
const char * upb_msg_getunknown(const upb_msg *msg, size_t *len)
Definition: php-upb.c:1549
UPB_WELLKNOWN_UINT32VALUE
@ UPB_WELLKNOWN_UINT32VALUE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2992
block
Block * block
Definition: protobuf/src/google/protobuf/descriptor.cc:1041
UPB_WIRE_TYPE_32BIT
@ UPB_WIRE_TYPE_32BIT
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:466
upb_filedef_package
const char * upb_filedef_package(const upb_filedef *f)
Definition: php-upb.c:5606
decode_err
static UPB_NORETURN void decode_err(upb_decstate *d)
Definition: php-upb.c:402
UPB_WELLKNOWN_UINT64VALUE
@ UPB_WELLKNOWN_UINT64VALUE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2990
google_protobuf_ServiceOptions_msginit
const upb_msglayout google_protobuf_ServiceOptions_msginit
Definition: php-upb.c:4349
UPB_DTYPE_SFIXED64
@ UPB_DTYPE_SFIXED64
Definition: php-upb.h:569
upb_status_vseterrf
void upb_status_vseterrf(upb_status *status, const char *fmt, va_list args)
Definition: php-upb.c:2700
upb_msgdef_fullname
const char * upb_msgdef_fullname(const upb_msgdef *m)
Definition: php-upb.c:5349
jsondec_tryparsech
static bool jsondec_tryparsech(jsondec *d, char ch)
Definition: php-upb.c:7444
jsondec_wellknown
static void jsondec_wellknown(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8736
o
UnboundConversion o
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:97
jsondec_buftouint64
static const char * jsondec_buftouint64(jsondec *d, const char *ptr, const char *end, uint64_t *val)
Definition: php-upb.c:7962
hash
uint64_t hash
Definition: ring_hash.cc:284
upb_encstate
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:782
extreg_key
static void extreg_key(char *buf, const upb_msglayout *l, uint32_t fieldnum)
Definition: php-upb.c:1800
UPB_DTYPE_FIXED32
@ UPB_DTYPE_FIXED32
Definition: php-upb.h:560
UPB_WIRE_TYPE_VARINT
@ UPB_WIRE_TYPE_VARINT
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:461
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
upb_enum_next
void upb_enum_next(upb_enum_iter *iter)
Definition: php-upb.c:5099
upb_fielddef_haspresence
bool upb_fielddef_haspresence(const upb_fielddef *f)
Definition: php-upb.c:5329
upb_strtable_lookup
UPB_INLINE bool upb_strtable_lookup(const upb_strtable *t, const char *key, upb_value *v)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:965
UPB_WIRE_TYPE_DELIMITED
@ UPB_WIRE_TYPE_DELIMITED
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:463
upb_msgdef_name
const char * upb_msgdef_name(const upb_msgdef *m)
Definition: php-upb.c:5357
upb_encstate::sorter
_upb_mapsorter sorter
Definition: php-upb.c:1031
google_protobuf_EnumDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_EnumDescriptorProto_name(const google_protobuf_EnumDescriptorProto *msg)
Definition: descriptor.upb.h:1197
for
for(map_begin_internal(intern, &it);!map_done(&it);map_next(&it))
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/map.c:207
upb_table::count
size_t count
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:819
UPB_TYPE_BYTES
@ UPB_TYPE_BYTES
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:482
upb_symtab::arena
upb_arena * arena
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3019
UPB_ENCODE_SKIPUNKNOWN
@ UPB_ENCODE_SKIPUNKNOWN
Definition: php-upb.h:1945
cleanup_ent::ud
void * ud
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2283
upb_oneofdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2992
ULL
#define ULL(x)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:57
google_protobuf_FieldDescriptorProto_has_extendee
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_extendee(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:936
upb_array_set
void upb_array_set(upb_array *arr, size_t i, upb_msgval val)
Definition: php-upb.c:7273
upb_inttable_remove
bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val)
Definition: php-upb.c:2516
OP_SUBMSG
#define OP_SUBMSG
Definition: php-upb.c:323
upb_fielddef_layout
const upb_msglayout_field * upb_fielddef_layout(const upb_fielddef *f)
Definition: php-upb.c:5299
jsondec_fieldmask
static void jsondec_fieldmask(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8599
decode_tosubmsg
static const UPB_FORCEINLINE char * decode_tosubmsg(upb_decstate *d, const char *ptr, upb_msg *submsg, upb_msglayout const *const *submsgs, const upb_msglayout_field *field, int size)
Definition: php-upb.c:592
upb_filedef::dep_count
int dep_count
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3012
UPB_TYPE_ENUM
@ UPB_TYPE_ENUM
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:479
UPB_MSG_BEGIN
#define UPB_MSG_BEGIN
Definition: php-upb.h:4679
upb_fielddef_name
const char * upb_fielddef_name(const upb_fielddef *f)
Definition: php-upb.c:5195
_upb_array_ptr
UPB_INLINE void * _upb_array_ptr(upb_array *arr)
Definition: php-upb.h:1350
UPB_JSONDEC_IGNOREUNKNOWN
@ UPB_JSONDEC_IGNOREUNKNOWN
Definition: php-upb.h:4778
google_protobuf_FieldDescriptorProto_has_oneof_index
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_oneof_index(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:1005
upb_isbetween
static bool upb_isbetween(char c, char low, char high)
Definition: php-upb.c:4980
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
upb_arena_addblock
static void upb_arena_addblock(upb_arena *a, upb_arena *root, void *ptr, size_t size)
Definition: php-upb.c:2774
UPB_PTRADD
#define UPB_PTRADD(ptr, ofs)
Definition: php-upb.c:168
google_protobuf_OneofDescriptorProto__fields
static const upb_msglayout_field google_protobuf_OneofDescriptorProto__fields[2]
Definition: php-upb.c:4129
in
const char * in
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:391
start
static uint64_t start
Definition: benchmark-pound.c:74
jsondec_timestamp
static void jsondec_timestamp(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8386
upb_msg_internal
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1141
UINT8_MAX
#define UINT8_MAX
Definition: stdint-msvc2008.h:140
desctype_to_mapsize
static const uint8_t desctype_to_mapsize[]
Definition: php-upb.c:289
symtab_oomerr
UPB_NORETURN static UPB_NOINLINE void symtab_oomerr(symtab_addctx *ctx)
Definition: php-upb.c:5738
c
void c(T a)
Definition: miscompile_with_no_unique_address_test.cc:40
UPB_DESCRIPTOR_TYPE_MESSAGE
@ UPB_DESCRIPTOR_TYPE_MESSAGE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:509
google_protobuf_SourceCodeInfo_msginit
const upb_msglayout google_protobuf_SourceCodeInfo_msginit
Definition: php-upb.c:4410
encode_fixed32
static void encode_fixed32(upb_encstate *e, uint32_t val)
Definition: php-upb.c:1090
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
fixed64_ok
static const unsigned fixed64_ok
Definition: php-upb.c:315
inthash
static uint32_t inthash(upb_tabkey key)
Definition: php-upb.c:2394
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
upb_symtab::files
upb_strtable files
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3021
a2
T::first_type a2
Definition: abseil-cpp/absl/container/internal/hash_function_defaults_test.cc:307
benchmark.syntax
syntax
Definition: benchmark.py:90
google_protobuf_MethodOptions_msginit
const upb_msglayout google_protobuf_MethodOptions_msginit
Definition: php-upb.c:4365
upb_inttable_replace
bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val)
Definition: php-upb.c:2509
symtab_resolve
static const void * symtab_resolve(symtab_addctx *ctx, const upb_fielddef *f, const char *base, upb_strview sym, upb_deftype_t type)
Definition: php-upb.c:6151
upb_msgdef_wellknowntype
upb_wellknowntype_t upb_msgdef_wellknowntype(const upb_msgdef *m)
Definition: php-upb.c:5463
xds_interop_client.int
int
Definition: xds_interop_client.py:113
_upb_map_set
UPB_INLINE bool _upb_map_set(upb_map *map, const void *key, size_t key_size, void *val, size_t val_size, upb_arena *a)
Definition: php-upb.h:1588
invalid
@ invalid
Definition: base64_test.cc:39
jsondec_string
static upb_strview jsondec_string(jsondec *d)
Definition: php-upb.c:7755
upb_oneof_next
void upb_oneof_next(upb_oneof_iter *iter)
Definition: php-upb.c:5584
i1
int i1
Definition: abseil-cpp/absl/container/btree_test.cc:2772
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
google_protobuf_EnumDescriptorProto_msginit
const upb_msglayout google_protobuf_EnumDescriptorProto_msginit
Definition: php-upb.c:4154
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
google_protobuf_FileOptions_has_php_namespace
UPB_INLINE bool google_protobuf_FileOptions_has_php_namespace(const google_protobuf_FileOptions *msg)
Definition: descriptor.upb.h:1835
UPB_DTYPE_BYTES
@ UPB_DTYPE_BYTES
Definition: php-upb.h:565
WyhashMix
static uint64_t WyhashMix(uint64_t v0, uint64_t v1)
Definition: php-upb.c:2174
decode_vret::ptr
const char * ptr
Definition: php-upb.c:448
gen_stats_data.found
bool found
Definition: gen_stats_data.py:61
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition: php-upb.c:1863
upb_msg_sizeof
static size_t upb_msg_sizeof(const upb_msglayout *l)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1157
gen_synthetic_protos.label
label
Definition: gen_synthetic_protos.py:102
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
upb_enumdef_fullname
const char * upb_enumdef_fullname(const upb_enumdef *e)
Definition: php-upb.c:5073
upb_realloc
UPB_INLINE void * upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize, size_t size)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:308
upb_arena_init
upb_arena * upb_arena_init(void *mem, size_t n, upb_alloc *alloc)
Definition: php-upb.c:2844
jsonenc::indent_depth
int indent_depth
Definition: php-upb.c:8817
jsondec_skipval
static void jsondec_skipval(jsondec *d)
Definition: php-upb.c:7807
encode_growbuffer
static UPB_NOINLINE void encode_growbuffer(upb_encstate *e, size_t bytes)
Definition: php-upb.c:1047
_upb_msg_getexts
const upb_msg_ext * _upb_msg_getexts(const upb_msg *msg, size_t *count)
Definition: php-upb.c:1560
UPB_WELLKNOWN_DURATION
@ UPB_WELLKNOWN_DURATION
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2984
_upb_sortedmap::pos
int pos
Definition: php-upb.h:1696
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
upb_arena_free
void upb_arena_free(upb_arena *a)
Definition: php-upb.c:2893
max
int max
Definition: bloaty/third_party/zlib/examples/enough.c:170
upb_fielddef::uint
uint64_t uint
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2940
jsonenc_fieldmask
static void jsonenc_fieldmask(jsonenc *e, const upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:9194
google_protobuf_FieldDescriptorProto_label
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_label(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:963
SIZE_MAX
#define SIZE_MAX
Definition: stdint-msvc2008.h:206
UnalignedLoad32
static uint32_t UnalignedLoad32(const void *p)
Definition: php-upb.c:2137
root
RefCountedPtr< grpc_tls_certificate_provider > root
Definition: xds_server_config_fetcher.cc:223
google_protobuf_FieldOptions
struct google_protobuf_FieldOptions google_protobuf_FieldOptions
Definition: descriptor.upb.h:65
upb_oneofdef_issynthetic
bool upb_oneofdef_issynthetic(const upb_oneofdef *o)
Definition: php-upb.c:5563
eqlfunc_t
bool eqlfunc_t(upb_tabkey k1, lookupkey_t k2)
Definition: php-upb.c:1929
google_protobuf_EnumDescriptorProto_EnumReservedRange__fields
static const upb_msglayout_field google_protobuf_EnumDescriptorProto_EnumReservedRange__fields[2]
Definition: php-upb.c:4160
jsondec_streql
static bool jsondec_streql(upb_strview str, const char *lit)
Definition: php-upb.c:7391
upb_msg_field_next
void upb_msg_field_next(upb_msg_field_iter *iter)
Definition: php-upb.c:5483
_upb_tabent::val
upb_tabval val
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:809
wireval::size
uint32_t size
Definition: php-upb.c:396
upb_symtab::syms
upb_strtable syms
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3020
UPB_ASSUME
#define UPB_ASSUME(expr)
Definition: php-upb.c:141
jsonenc_scalar
static void jsonenc_scalar(jsonenc *e, upb_msgval val, const upb_fielddef *f)
Definition: php-upb.c:9335
UPB_WELLKNOWN_FLOATVALUE
@ UPB_WELLKNOWN_FLOATVALUE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2988
upb_oneofdef_field
const upb_fielddef * upb_oneofdef_field(const upb_oneofdef *o, int i)
Definition: php-upb.c:5550
_upb_decode
bool _upb_decode(const char *buf, size_t size, void *msg, const upb_msglayout *l, const upb_extreg *extreg, int options, upb_arena *arena)
Definition: php-upb.c:949
upb_table::size_lg2
uint8_t size_lg2
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:822
upb_msg_discardunknown
bool upb_msg_discardunknown(upb_msg *msg, const upb_msgdef *m, int maxdepth)
Definition: php-upb.c:7250
upb_array_get
upb_msgval upb_array_get(const upb_array *arr, size_t i)
Definition: php-upb.c:7264
upb_oneofdef::full_name
const char * full_name
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2994
upb_fielddef::lazy_
bool lazy_
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2956
upb_oneof_begin
void upb_oneof_begin(upb_oneof_iter *iter, const upb_oneofdef *o)
Definition: php-upb.c:5580
google_protobuf_FileDescriptorProto_syntax
UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_syntax(const google_protobuf_FileDescriptorProto *msg)
Definition: descriptor.upb.h:348
upb_msgdef_numoneofs
int upb_msgdef_numoneofs(const upb_msgdef *m)
Definition: php-upb.c:5425
_upb_array_realloc
bool _upb_array_realloc(upb_array *arr, size_t min_size, upb_arena *arena)
Definition: php-upb.c:1604
upb_DefPool::syms
upb_strtable syms
Definition: upb/upb/def.c:219
jsondec::options
int options
Definition: php-upb.c:7378
decode_verifyutf8_inl
UPB_INLINE bool decode_verifyutf8_inl(const char *buf, int len)
Definition: php-upb.h:1798
insert
static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey, upb_value val, uint32_t hash, hashfunc_t *hashfunc, eqlfunc_t *eql)
Definition: php-upb.c:2017
google_protobuf_FileDescriptorProto_has_name
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_name(const google_protobuf_FileDescriptorProto *msg)
Definition: descriptor.upb.h:249
jsonenc_errf
static UPB_NORETURN void jsonenc_errf(jsonenc *e, const char *fmt,...)
Definition: php-upb.c:8839
decode_group
static const UPB_FORCEINLINE char * decode_group(upb_decstate *d, const char *ptr, upb_msg *submsg, const upb_msglayout *subl, uint32_t number)
Definition: php-upb.c:609
upb_array::len
size_t len
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:580
setup.v
v
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
upb_inttable_iter
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:1113
decode_tag
static const UPB_FORCEINLINE char * decode_tag(upb_decstate *d, const char *ptr, uint32_t *val)
Definition: php-upb.c:485
google_protobuf_FileDescriptorProto_extension
const UPB_INLINE google_protobuf_FieldDescriptorProto *const * google_protobuf_FileDescriptorProto_extension(const google_protobuf_FileDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:308
UPB_DESCRIPTOR_TYPE_SINT32
@ UPB_DESCRIPTOR_TYPE_SINT32
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:515
upb_inthash
static uint32_t upb_inthash(uintptr_t key)
Definition: php-upb.c:1933
google_protobuf_DescriptorProto_submsgs
static const upb_msglayout *const google_protobuf_DescriptorProto_submsgs[7]
Definition: php-upb.c:4031
check_ident
static void check_ident(symtab_addctx *ctx, upb_strview name, bool full)
Definition: php-upb.c:5749
UPB_WELLKNOWN_TIMESTAMP
@ UPB_WELLKNOWN_TIMESTAMP
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2985
_upb_symtab_loaddefinit
bool _upb_symtab_loaddefinit(upb_symtab *s, const upb_def_init *init)
Definition: php-upb.c:6927
TAG
#define TAG(wire_type)
UPB_NOINLINE
#define UPB_NOINLINE
Definition: php-upb.c:120
jsonenc::arena
upb_arena * arena
Definition: php-upb.c:8822
upb_strtable_init
bool upb_strtable_init(upb_strtable *t, size_t expected_size, upb_arena *a)
Definition: php-upb.c:2280
upb_fielddef::defaultval
union upb_fielddef::@206 defaultval
upb_status_setoom
static void upb_status_setoom(upb_status *status)
Definition: php-upb.c:5023
jsonenc_msg
static void jsonenc_msg(jsonenc *e, const upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:9484
jsondec_tomsg
static void jsondec_tomsg(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8229
_upb_map_fromvalue
UPB_INLINE void _upb_map_fromvalue(upb_value val, void *out, size_t size)
Definition: php-upb.h:1552
upb_arena::freelist
mem_block * freelist
Definition: php-upb.h:1763
jsondec_partialbase64
static char * jsondec_partialbase64(jsondec *d, const char *ptr, const char *end, char *out)
Definition: php-upb.c:7890
upb_mapiter_key
upb_msgval upb_mapiter_key(const upb_map *map, size_t iter)
Definition: php-upb.c:7334
streql_view
static bool streql_view(upb_strview view, const char *b)
Definition: php-upb.c:6040
upb_fielddef::json_name
const char * json_name
Definition: php-upb.c:4864
upb_enumdef_file
const upb_filedef * upb_enumdef_file(const upb_enumdef *e)
Definition: php-upb.c:5081
_upb_mapsorter_cmpu64
static int _upb_mapsorter_cmpu64(const void *_a, const void *_b)
Definition: php-upb.c:1692
upb_fielddef_isprimitive
bool upb_fielddef_isprimitive(const upb_fielddef *f)
Definition: php-upb.c:5316
google_protobuf_OneofDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_OneofDescriptorProto_name(const google_protobuf_OneofDescriptorProto *msg)
Definition: descriptor.upb.h:1128
upb_filedef::msg_count
int msg_count
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3013
MessageLayout::fields
MessageField * fields
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:938
jsondec_value
static upb_msgval jsondec_value(jsondec *d, const upb_fielddef *f)
Definition: php-upb.c:8303
_upb_map_clear
UPB_INLINE void _upb_map_clear(upb_map *map)
Definition: php-upb.h:1604
jsondec_object
static void jsondec_object(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8295
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
upb_array::data
void * data
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:579
jsondec_isnullvalue
static bool jsondec_isnullvalue(const upb_fielddef *f)
Definition: php-upb.c:7395
emptyent
static upb_tabent * emptyent(upb_table *t, upb_tabent *e)
Definition: php-upb.c:1968
_upb_mapsorter_cmpi32
static int _upb_mapsorter_cmpi32(const void *_a, const void *_b)
Definition: php-upb.c:1698
upb_tabkey
uintptr_t upb_tabkey
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:787
cleanup_ent
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2280
UPB_ALIGN_OF
#define UPB_ALIGN_OF(type)
Definition: php-upb.c:96
upb_msgval::float_val
float float_val
Definition: php-upb.h:4614
table_hash
static uint32_t table_hash(const char *p, size_t n)
Definition: php-upb.c:2264
upb_inttable
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:848
_upb_map_size
UPB_INLINE size_t _upb_map_size(const upb_map *map)
Definition: php-upb.h:1563
google_protobuf_OneofDescriptorProto_submsgs
static const upb_msglayout *const google_protobuf_OneofDescriptorProto_submsgs[1]
Definition: php-upb.c:4125
upb_enumdef::ntoi
upb_strtable ntoi
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2987
begin
static size_t begin(const upb_table *t)
Definition: php-upb.c:2110
google_protobuf_SourceCodeInfo_submsgs
static const upb_msglayout *const google_protobuf_SourceCodeInfo_submsgs[1]
Definition: php-upb.c:4402
upb_fielddef::unresolved
const google_protobuf_FieldDescriptorProto * unresolved
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2950
def
int def(FILE *source, FILE *dest, int level)
Definition: bloaty/third_party/zlib/examples/zpipe.c:36
google_protobuf_ExtensionRangeOptions_msginit
const upb_msglayout google_protobuf_ExtensionRangeOptions_msginit
Definition: php-upb.c:4095
UPB_DEFTYPE_FIELD
@ UPB_DEFTYPE_FIELD
Definition: php-upb.c:4958
jsonenc::err
jmp_buf err
Definition: php-upb.c:8820
UPB_DESCRIPTOR_TYPE_UINT32
@ UPB_DESCRIPTOR_TYPE_UINT32
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:511
upb_msg_field_begin
void upb_msg_field_begin(upb_msg_field_iter *iter, const upb_msgdef *m)
Definition: php-upb.c:5479
upb_mutmsgval::array
upb_array * array
Definition: php-upb.h:4629
streql2
static bool streql2(const char *a, size_t n, const char *b)
Definition: php-upb.c:6036
google_protobuf_DescriptorProto_extension
const UPB_INLINE google_protobuf_FieldDescriptorProto *const * google_protobuf_DescriptorProto_extension(const google_protobuf_DescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:549
done
struct tab * done
Definition: bloaty/third_party/zlib/examples/enough.c:176
google_protobuf_MessageOptions_submsgs
static const upb_msglayout *const google_protobuf_MessageOptions_submsgs[1]
Definition: php-upb.c:4257
upb_fielddef::layout_index
uint16_t layout_index
Definition: php-upb.c:4881
upb_fielddef::type_
upb_descriptortype_t type_
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2958
upb_strtable_remove
bool upb_strtable_remove(upb_strtable *t, const char *key, size_t len, upb_value *val)
Definition: php-upb.c:2338
google_protobuf_EnumValueDescriptorProto_msginit
const upb_msglayout google_protobuf_EnumValueDescriptorProto_msginit
Definition: php-upb.c:4181
UPB_NORETURN
#define UPB_NORETURN
Definition: php-upb.c:121
google_protobuf_EnumDescriptorProto
struct google_protobuf_EnumDescriptorProto google_protobuf_EnumDescriptorProto
Definition: descriptor.upb.h:58
_upb_msg_new_inl
UPB_INLINE upb_msg * _upb_msg_new_inl(const upb_msglayout *l, upb_arena *a)
Definition: php-upb.h:1209
UPB_DESCRIPTOR_TYPE_FIXED64
@ UPB_DESCRIPTOR_TYPE_FIXED64
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:504
upb_deftype_t
upb_deftype_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3025
upb_symtab
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3018
upb_enumdef::defaultval
int32_t defaultval
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2989
UPB_DEFTYPE_ONEOF
@ UPB_DEFTYPE_ONEOF
Definition: php-upb.c:4965
upb_inttable_next
void upb_inttable_next(upb_inttable_iter *iter)
Definition: php-upb.c:2612
upb_msgval::double_val
double double_val
Definition: php-upb.h:4615
UPB_LABEL_OPTIONAL
@ UPB_LABEL_OPTIONAL
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:492
upb_tabval
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:798
upb_arena_new
UPB_INLINE upb_arena * upb_arena_new(void)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:392
absl::compare_internal::value_type
int8_t value_type
Definition: abseil-cpp/absl/types/compare.h:45
number
int32_t number
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:850
upb_fielddef_defaultfloat
float upb_fielddef_defaultfloat(const upb_fielddef *f)
Definition: php-upb.c:5267
upb_msglayout::submsgs
const struct upb_msglayout *const * submsgs
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:566
google_protobuf_FileOptions_php_class_prefix
UPB_INLINE upb_StringView google_protobuf_FileOptions_php_class_prefix(const google_protobuf_FileOptions *msg)
Definition: descriptor.upb.h:1832
upb_msgdef::fields
const upb_fielddef * fields
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2972
upb_cleanup_metadata
static uintptr_t upb_cleanup_metadata(uint32_t *cleanup, bool has_initial_block)
Definition: php-upb.c:2738
overhead
static const size_t overhead
Definition: php-upb.c:1485
upb_filedef_symtab
const upb_symtab * upb_filedef_symtab(const upb_filedef *f)
Definition: php-upb.c:5646
upb_arena
struct upb_arena upb_arena
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:365
fastdecode_loadtag
UPB_INLINE uint32_t fastdecode_loadtag(const char *ptr)
Definition: php-upb.h:1888
fastdecode_err
const char * fastdecode_err(upb_decstate *d)
Definition: php-upb.c:412
JD_STRING
@ JD_STRING
Definition: php-upb.c:7382
upb_fielddef_packed
bool upb_fielddef_packed(const upb_fielddef *f)
Definition: php-upb.c:5191
UPB_DESCRIPTOR_TYPE_FLOAT
@ UPB_DESCRIPTOR_TYPE_FLOAT
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:500
intptr_t
_W64 signed int intptr_t
Definition: stdint-msvc2008.h:118
jsonenc::options
int options
Definition: php-upb.c:8818
google_protobuf_MessageOptions_msginit
const upb_msglayout google_protobuf_MessageOptions_msginit
Definition: php-upb.c:4269
cleanup_ent
struct cleanup_ent cleanup_ent
upb_fielddef_containingoneof
const upb_oneofdef * upb_fielddef_containingoneof(const upb_fielddef *f)
Definition: php-upb.c:5211
upb_encstate::depth
int depth
Definition: php-upb.c:1030
jsondec_skipws
static void jsondec_skipws(jsondec *d)
Definition: php-upb.c:7425
strviewdup
static char * strviewdup(symtab_addctx *ctx, upb_strview view)
Definition: php-upb.c:6032
mon
static const char *const mon[12]
Definition: a_strex.c:515
UPB_DESCRIPTOR_TYPE_SINT64
@ UPB_DESCRIPTOR_TYPE_SINT64
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:516
upb_gfree
UPB_INLINE void upb_gfree(void *ptr)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:344
x
int x
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
upb_encode_ex
char * upb_encode_ex(const void *msg, const upb_msglayout *l, int options, upb_arena *arena, size_t *size)
Definition: php-upb.c:1447
_upb_mapsorter_cmpstr
static int _upb_mapsorter_cmpstr(const void *_a, const void *_b)
Definition: php-upb.c:1716
MAX_LOAD
static const double MAX_LOAD
Definition: php-upb.c:1866
UPB_LABEL_REQUIRED
@ UPB_LABEL_REQUIRED
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:493
google_protobuf_FileDescriptorProto_has_package
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_package(const google_protobuf_FileDescriptorProto *msg)
Definition: descriptor.upb.h:259
mem_block
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2272
jsonenc::ext_pool
const upb_symtab * ext_pool
Definition: php-upb.c:8819
gen_synthetic_protos.base
base
Definition: gen_synthetic_protos.py:31
jsondec_entrysep
static void jsondec_entrysep(jsondec *d)
Definition: php-upb.c:7470
upb_fielddef_isstring
bool upb_fielddef_isstring(const upb_fielddef *f)
Definition: php-upb.c:5307
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
field_rank
uint32_t field_rank(const upb_fielddef *f)
Definition: php-upb.c:5008
decode_tomap
static const char * decode_tomap(upb_decstate *d, const char *ptr, upb_msg *msg, upb_msglayout const *const *submsgs, const upb_msglayout_field *field, wireval *val)
Definition: php-upb.c:722
UPB_STRVIEW_FORMAT
#define UPB_STRVIEW_FORMAT
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:279
upb_array
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:578
make_layout
static void make_layout(symtab_addctx *ctx, const upb_msgdef *m)
Definition: php-upb.c:5877
jsonenc_stringbody
static void jsonenc_stringbody(jsonenc *e, upb_strview str)
Definition: php-upb.c:9024
upb_arena_addcleanup
bool upb_arena_addcleanup(upb_arena *a, void *ud, upb_cleanup_func *func)
Definition: php-upb.c:2898
upb_strtable_next
void upb_strtable_next(upb_strtable_iter *i)
Definition: php-upb.c:2352
UPB_STRVIEW_ARGS
#define UPB_STRVIEW_ARGS(view)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:280
upb_fielddef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2934
_upb_getmode
UPB_INLINE upb_fieldmode _upb_getmode(const upb_msglayout_field *field)
Definition: php-upb.h:1107
google_protobuf_SourceCodeInfo_Location__fields
static const upb_msglayout_field google_protobuf_SourceCodeInfo_Location__fields[5]
Definition: php-upb.c:4416
google_protobuf_EnumDescriptorProto__fields
static const upb_msglayout_field google_protobuf_EnumDescriptorProto__fields[5]
Definition: php-upb.c:4146
upb_filedef::syntax
upb_syntax_t syntax
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3005
upb_msgdef::real_oneof_count
int real_oneof_count
Definition: php-upb.c:4903
UPB_DECODE_ALIAS
@ UPB_DECODE_ALIAS
Definition: php-upb.h:696
upb_decstate
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:183
upb_isletter
static bool upb_isletter(char c)
Definition: php-upb.c:4984
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint-msvc2008.h:119
upb_filedef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3000
bm_speedup.scale
def scale(a, mul)
Definition: bm_speedup.py:24
_upb_mapsorter_cmpbool
static int _upb_mapsorter_cmpbool(const void *_a, const void *_b)
Definition: php-upb.c:1710
upb_deftype_t
upb_deftype_t
Definition: php-upb.c:4957
a1
T::first_type a1
Definition: abseil-cpp/absl/container/internal/hash_function_defaults_test.cc:305
_upb_arenahas
UPB_INLINE size_t _upb_arenahas(upb_arena *a)
Definition: php-upb.h:446
google_protobuf_MethodDescriptorProto_msginit
const upb_msglayout google_protobuf_MethodDescriptorProto_msginit
Definition: php-upb.c:4217
jsondec::ptr
const char * ptr
Definition: php-upb.c:7369
tests.google.protobuf.internal.message_test.cmp
cmp
Definition: bloaty/third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py:61
inttable_val_const
static const upb_tabval * inttable_val_const(const upb_inttable *t, uintptr_t key)
Definition: php-upb.c:2414
mem_block::next
struct mem_block * next
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2273
min
#define min(a, b)
Definition: qsort.h:83
encode_varint
static UPB_FORCEINLINE void encode_varint(upb_encstate *e, uint64_t val)
Definition: php-upb.c:1108
upb_malloc
UPB_INLINE void * upb_malloc(upb_alloc *alloc, size_t size)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:303
upb_umul128
static uint64_t upb_umul128(uint64_t v0, uint64_t v1, uint64_t *out_high)
Definition: php-upb.c:2149
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
google_protobuf_FieldDescriptorProto_type_name
UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_type_name(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:983
upb_msgdef::layout
const upb_msglayout * layout
Definition: php-upb.c:4891
UPB_DEFTYPE_FIELD_JSONNAME
@ UPB_DEFTYPE_FIELD_JSONNAME
Definition: php-upb.c:4966
jsondec::err
jmp_buf err
Definition: php-upb.c:7374
UPB_MAP_BEGIN
#define UPB_MAP_BEGIN
Definition: php-upb.h:574
_upb_sortedmap_next
UPB_INLINE bool _upb_sortedmap_next(_upb_mapsorter *s, const upb_map *map, _upb_sortedmap *sorted, upb_map_entry *ent)
Definition: php-upb.h:1717
upb_filedef_phpprefix
const char * upb_filedef_phpprefix(const upb_filedef *f)
Definition: php-upb.c:5610
g
struct @717 g
google_protobuf_FileDescriptorSet_msginit
const upb_msglayout google_protobuf_FileDescriptorSet_msginit
Definition: php-upb.c:3995
upb_fielddef_checkintfmt
bool upb_fielddef_checkintfmt(int32_t fmt)
Definition: php-upb.c:5341
google_protobuf_DescriptorProto_options
const UPB_INLINE google_protobuf_MessageOptions * google_protobuf_DescriptorProto_options(const google_protobuf_DescriptorProto *msg)
Definition: descriptor.upb.h:558
google_protobuf_FileDescriptorProto_has_syntax
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_syntax(const google_protobuf_FileDescriptorProto *msg)
Definition: descriptor.upb.h:341
UPB_DESCRIPTOR_TYPE_UINT64
@ UPB_DESCRIPTOR_TYPE_UINT64
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:502
google_protobuf_UninterpretedOption_msginit
const upb_msglayout google_protobuf_UninterpretedOption_msginit
Definition: php-upb.c:4385
layout
MessageLayout * layout
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:809
upb_fielddef::boolean
bool boolean
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2943
upb_enumdef::file
const upb_filedef * file
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2985
_upb_mapsorter_popmap
UPB_INLINE void _upb_mapsorter_popmap(_upb_mapsorter *s, _upb_sortedmap *sorted)
Definition: php-upb.h:1713
UPB_ALIGN_DOWN
#define UPB_ALIGN_DOWN(size, align)
Definition: php-upb.c:94
jsondec_tsdigits
static int jsondec_tsdigits(jsondec *d, const char **ptr, size_t digits, const char *after)
Definition: php-upb.c:8330
d
static const fe d
Definition: curve25519_tables.h:19
upb_oneofdef::parent
const upb_msgdef * parent
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2993
qsort
void qsort(void *a, size_t n, size_t es, int(*cmp)(const void *, const void *))
Definition: qsort.h:130
upb_strtable_iter_isequal
bool upb_strtable_iter_isequal(const upb_strtable_iter *i1, const upb_strtable_iter *i2)
Definition: php-upb.c:2381
_upb_array_resize
UPB_INLINE bool _upb_array_resize(upb_array *arr, size_t size, upb_arena *arena)
Definition: php-upb.h:1387
UPB_TYPE_INT32
@ UPB_TYPE_INT32
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:477
symtab_addctx::layouts
const upb_msglayout ** layouts
Definition: php-upb.c:5723
google_protobuf_FieldOptions_has_packed
UPB_INLINE bool google_protobuf_FieldOptions_has_packed(const google_protobuf_FieldOptions *msg)
Definition: descriptor.upb.h:2129
upb_oneof_iter_setdone
void upb_oneof_iter_setdone(upb_oneof_iter *iter)
Definition: php-upb.c:5596
jsonenc_struct
static void jsonenc_struct(jsonenc *e, const upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:9213
upb_fielddef::proto3_optional_
bool proto3_optional_
Definition: php-upb.c:4885
google_protobuf_DescriptorProto_ExtensionRange__fields
static const upb_msglayout_field google_protobuf_DescriptorProto_ExtensionRange__fields[3]
Definition: php-upb.c:4064
kWyhashSalt
const uint64_t kWyhashSalt[5]
Definition: php-upb.c:2259
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
google_protobuf_FileOptions_has_php_class_prefix
UPB_INLINE bool google_protobuf_FileOptions_has_php_class_prefix(const google_protobuf_FileOptions *msg)
Definition: descriptor.upb.h:1825
jsondec_skipdigits
static void jsondec_skipdigits(jsondec *d)
Definition: php-upb.c:7584
_upb_hasbit_field
UPB_INLINE bool _upb_hasbit_field(const upb_msg *msg, const upb_msglayout_field *f)
Definition: php-upb.h:1286
_upb_mapsorter_destroy
UPB_INLINE void _upb_mapsorter_destroy(_upb_mapsorter *s)
Definition: php-upb.h:1706
upb_enumdef_default
int32_t upb_enumdef_default(const upb_enumdef *e)
Definition: php-upb.c:5085
jsonenc_bytes
static void jsonenc_bytes(jsonenc *e, upb_strview str)
Definition: php-upb.c:8985
upb_oneofdef_numfields
int upb_oneofdef_numfields(const upb_oneofdef *o)
Definition: php-upb.c:5555
google_protobuf_FileDescriptorProto_enum_type
const UPB_INLINE google_protobuf_EnumDescriptorProto *const * google_protobuf_FileDescriptorProto_enum_type(const google_protobuf_FileDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:290
descriptor
static const char descriptor[7601]
Definition: php-upb.c:4526
stdint.h
jsondec_map
static void jsondec_map(jsondec *d, upb_msg *msg, const upb_fielddef *f)
Definition: php-upb.c:8212
upb_mutmsgval::map
upb_map * map
Definition: php-upb.h:4627
upb_wellknowntype_t
upb_wellknowntype_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2980
setup.idx
idx
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:197
UPB_WELLKNOWN_INT32VALUE
@ UPB_WELLKNOWN_INT32VALUE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2991
_UPB_MODE_ARRAY
@ _UPB_MODE_ARRAY
Definition: php-upb.h:1098
after
IntAfterTypedTestSuiteP after
Definition: googletest/googletest/test/gtest-typed-test_test.cc:375
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
upb_fielddef::index_
uint16_t index_
Definition: php-upb.c:4880
google_protobuf_EnumValueOptions_msginit
const upb_msglayout google_protobuf_EnumValueOptions_msginit
Definition: php-upb.c:4334
JD_NULL
@ JD_NULL
Definition: php-upb.c:7382
google_protobuf_FileDescriptorSet_submsgs
static const upb_msglayout *const google_protobuf_FileDescriptorSet_submsgs[1]
Definition: php-upb.c:3987
UPB_TABVALUE_EMPTY_INIT
#define UPB_TABVALUE_EMPTY_INIT
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:802
jsondec_wellknownvalue
static void jsondec_wellknownvalue(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8512
log2ceil
static int log2ceil(uint64_t v)
Definition: php-upb.c:1881
upb_msg_oneof_begin
void upb_msg_oneof_begin(upb_msg_oneof_iter *iter, const upb_msgdef *m)
Definition: php-upb.c:5502
upb_enum_begin
void upb_enum_begin(upb_enum_iter *i, const upb_enumdef *e)
Definition: php-upb.c:5094
google_benchmark.example.empty
def empty(state)
Definition: example.py:31
upb_msgdef_oneof
const upb_oneofdef * upb_msgdef_oneof(const upb_msgdef *m, int i)
Definition: php-upb.c:5454
upb_array_resize
bool upb_array_resize(upb_array *arr, size_t size, upb_arena *arena)
Definition: php-upb.c:7288
upb_msgdef::ntof
upb_strtable ntof
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2970
google_protobuf_FileOptions_msginit
const upb_msglayout google_protobuf_FileOptions_msginit
Definition: php-upb.c:4251
google_protobuf_FieldDescriptorProto_json_name
UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_json_name(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:1022
upb_msgval::bool_val
bool bool_val
Definition: php-upb.h:4613
UPB_DESCRIPTOR_TYPE_DOUBLE
@ UPB_DESCRIPTOR_TYPE_DOUBLE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:499
upb_json_encode
size_t upb_json_encode(const upb_msg *msg, const upb_msgdef *m, const upb_symtab *ext_pool, int options, char *buf, size_t size, upb_status *status)
Definition: php-upb.c:9501
upb_msg_internaldata
Definition: php-upb.h:1175
upb_fielddef_default
upb_msgval upb_fielddef_default(const upb_fielddef *f)
Definition: php-upb.c:5220
jsonenc_fieldval
static void jsonenc_fieldval(jsonenc *e, const upb_fielddef *f, upb_msgval val, bool *first)
Definition: php-upb.c:9438
jsondec_strfield
static upb_msgval jsondec_strfield(jsondec *d, const upb_fielddef *f)
Definition: php-upb.c:8128
jsonenc_err
static UPB_NORETURN void jsonenc_err(jsonenc *e, const char *msg)
Definition: php-upb.c:8833
makefullname
static const char * makefullname(symtab_addctx *ctx, const char *prefix, upb_strview name)
Definition: php-upb.c:6044
UPB_WELLKNOWN_FIELDMASK
@ UPB_WELLKNOWN_FIELDMASK
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2983
google_protobuf_FieldDescriptorProto_has_json_name
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_json_name(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:1015
upb_inttable_sizedinit
bool upb_inttable_sizedinit(upb_inttable *t, size_t asize, int hsize_lg2, upb_arena *a)
Definition: php-upb.c:2439
google_protobuf_DescriptorProto_ExtensionRange_msginit
const upb_msglayout google_protobuf_DescriptorProto_ExtensionRange_msginit
Definition: php-upb.c:4070
upb_map_delete
bool upb_map_delete(upb_map *map, upb_msgval key)
Definition: php-upb.c:7317
newstr
static str_t * newstr(symtab_addctx *ctx, const char *data, size_t len)
Definition: php-upb.c:6204
resolve_fielddef
static void resolve_fielddef(symtab_addctx *ctx, const char *prefix, upb_fielddef *f)
Definition: php-upb.c:6679
UPB_WELLKNOWN_BYTESVALUE
@ UPB_WELLKNOWN_BYTESVALUE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2995
mem
void * mem
Definition: libc.cpp:91
upb_roundup_pow2
static size_t upb_roundup_pow2(size_t bytes)
Definition: php-upb.c:1034
UPB_UNREACHABLE
#define UPB_UNREACHABLE()
Definition: php-upb.c:155
CHK_OOM
#define CHK_OOM(x)
Definition: php-upb.c:5717
upb_msg_getinternal
static upb_msg_internal * upb_msg_getinternal(upb_msg *msg)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1161
google_protobuf_FieldDescriptorProto__fields
static const upb_msglayout_field google_protobuf_FieldDescriptorProto__fields[11]
Definition: php-upb.c:4105
_upb_tabent::next
const struct _upb_tabent * next
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:815
value
const char * value
Definition: hpack_parser_table.cc:165
jsondec_parselit
static void jsondec_parselit(jsondec *d, const char *lit)
Definition: php-upb.c:7450
jsonenc_duration
static void jsonenc_duration(jsonenc *e, const upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8949
jsondec::any_pool
const upb_symtab * any_pool
Definition: php-upb.c:7371
google_protobuf_ExtensionRangeOptions__fields
static const upb_msglayout_field google_protobuf_ExtensionRangeOptions__fields[1]
Definition: php-upb.c:4091
upb_free
UPB_INLINE void upb_free(upb_alloc *alloc, void *ptr)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:314
upb_descriptortype_t
upb_descriptortype_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:498
shortname
static const char * shortname(const char *longname)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:8087
google_protobuf_MethodOptions__fields
static const upb_msglayout_field google_protobuf_MethodOptions__fields[3]
Definition: php-upb.c:4359
INT64_MIN
#define INT64_MIN
Definition: stdint-msvc2008.h:138
TAGBYTES
#define TAGBYTES(card)
Definition: php-upb.h:2076
jsondec::debug_field
const upb_fielddef * debug_field
Definition: php-upb.c:7379
upb_strtable_lookup2
bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len, upb_value *v)
Definition: php-upb.c:2332
upb_fielddef_file
const upb_filedef * upb_fielddef_file(const upb_fielddef *f)
Definition: php-upb.c:5203
google_protobuf_DescriptorProto_enum_type
const UPB_INLINE google_protobuf_EnumDescriptorProto *const * google_protobuf_DescriptorProto_enum_type(const google_protobuf_DescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:531
google_protobuf_DescriptorProto_ExtensionRange_submsgs
static const upb_msglayout *const google_protobuf_DescriptorProto_ExtensionRange_submsgs[1]
Definition: php-upb.c:4060
testing::internal::fmt
GTEST_API_ const char * fmt
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1808
ares::byte
unsigned char byte
Definition: ares-test.h:33
jsondec_anyfield
static void jsondec_anyfield(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8621
_upb_be_swap32
UPB_INLINE uint32_t _upb_be_swap32(uint32_t val)
Definition: php-upb.h:581
upb_DefPool::arena
upb_Arena * arena
Definition: upb/upb/def.c:218
decode_isdonefallback_inl
const UPB_INLINE char * decode_isdonefallback_inl(upb_decstate *d, const char *ptr, int overrun)
Definition: php-upb.h:1829
_upb_map_delete
UPB_INLINE bool _upb_map_delete(upb_map *map, const void *key, size_t key_size)
Definition: php-upb.h:1599
upb_msg_fielddefsize
static uint8_t upb_msg_fielddefsize(const upb_fielddef *f)
Definition: php-upb.c:5807
count_types_in_msg
static void count_types_in_msg(const google_protobuf_DescriptorProto *msg_proto, upb_filedef *file)
Definition: php-upb.c:6642
upb_cleanup_has_initial_block
static bool upb_cleanup_has_initial_block(uintptr_t cleanup_metadata)
Definition: php-upb.c:2734
INT32_MIN
#define INT32_MIN
Definition: stdint-msvc2008.h:136
upb_strtable_iter_setdone
void upb_strtable_iter_setdone(upb_strtable_iter *i)
Definition: php-upb.c:2376
_upb_symtab_addfile
static const upb_filedef * _upb_symtab_addfile(upb_symtab *s, const google_protobuf_FileDescriptorProto *file_proto, const upb_msglayout **layouts, upb_status *status)
Definition: php-upb.c:6876
jsondec::arena
upb_arena * arena
Definition: php-upb.c:7370
upb_msgdef::oneof_count
int oneof_count
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2975
upb_filedef::phpprefix
const char * phpprefix
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3003
google_protobuf_FieldDescriptorProto_has_type_name
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_type_name(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:976
upb_value::val
uint64_t val
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:682
upb_oneofdef::ntof
upb_strtable ntof
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2996
UPB_DESCRIPTOR_TYPE_SFIXED32
@ UPB_DESCRIPTOR_TYPE_SFIXED32
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:513
upb_msglayout
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:565
mem_block::size
uint32_t size
Definition: php-upb.c:2751
encode_fixed64
static void encode_fixed64(upb_encstate *e, uint64_t val)
Definition: php-upb.c:1085
upb_msgval
Definition: php-upb.h:4612
jsonenc_array
static void jsonenc_array(jsonenc *e, const upb_array *arr, const upb_fielddef *f)
Definition: php-upb.c:9402
upb_global_allocfunc
static void * upb_global_allocfunc(upb_alloc *alloc, void *ptr, size_t oldsize, size_t size)
Definition: php-upb.c:2718
UPB_MAPTYPE_STRING
#define UPB_MAPTYPE_STRING
Definition: php-upb.c:82
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
func
const EVP_CIPHER *(* func)(void)
Definition: cipher_extra.c:73
upb_gmalloc
UPB_INLINE void * upb_gmalloc(size_t size)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:336
symtab_addctx::arena
upb_arena * arena
Definition: php-upb.c:5722
upb_msg_field_done
bool upb_msg_field_done(const upb_msg_field_iter *iter)
Definition: php-upb.c:5485
upb_filedef_msgcount
int upb_filedef_msgcount(const upb_filedef *f)
Definition: php-upb.c:5622
upb_msg_new
upb_msg * upb_msg_new(const upb_msgdef *m, upb_arena *a)
Definition: php-upb.c:7046
upb_utf8_offsets
const uint8_t upb_utf8_offsets[]
Definition: php-upb.c:421
key
const char * key
Definition: hpack_parser_table.cc:164
upb_msgdef::oneofs
const upb_oneofdef * oneofs
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2973
upb_msgdef_itof
const upb_fielddef * upb_msgdef_itof(const upb_msgdef *m, uint32_t i)
Definition: php-upb.c:5365
upb_inttable::array_size
size_t array_size
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:851
__asan_unpoison_memory_region
static void __asan_unpoison_memory_region(const void *addr, size_t size)
Definition: mem.c:83
decode_msg
static const char * decode_msg(upb_decstate *d, const char *ptr, upb_msg *msg, const upb_msglayout *layout)
Definition: php-upb.c:827
upb_msg_ext
Definition: php-upb.h:1243
upb_fielddef_lazy
bool upb_fielddef_lazy(const upb_fielddef *f)
Definition: php-upb.c:5187
upb_enum_done
bool upb_enum_done(upb_enum_iter *iter)
Definition: php-upb.c:5100
upb_arena_doalloc
static void * upb_arena_doalloc(upb_alloc *alloc, void *ptr, size_t oldsize, size_t size)
Definition: php-upb.c:2810
N
#define N
Definition: sync_test.cc:37
UPB_TYPE_STRING
@ UPB_TYPE_STRING
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:481
upb_enumdef::iton
upb_inttable iton
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2988
upb_alloc_global
upb_alloc upb_alloc_global
Definition: php-upb.c:2743
ctx::symtab
const upb_DefPool * symtab
Definition: conformance_upb.c:85
I
#define I(b, c, d)
Definition: md5.c:120
bytes
uint8 bytes[10]
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:153
UPB_DESCRIPTOR_TYPE_ENUM
@ UPB_DESCRIPTOR_TYPE_ENUM
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:512
google_protobuf_FileDescriptorProto_message_type
const UPB_INLINE google_protobuf_DescriptorProto *const * google_protobuf_FileDescriptorProto_message_type(const google_protobuf_FileDescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:281
jsondec_array
static void jsondec_array(jsondec *d, upb_msg *msg, const upb_fielddef *f)
Definition: php-upb.c:8201
UPB_STATUS_MAX_MESSAGE
#define UPB_STATUS_MAX_MESSAGE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:195
google_protobuf_FieldOptions_packed
UPB_INLINE bool google_protobuf_FieldOptions_packed(const google_protobuf_FieldOptions *msg)
Definition: descriptor.upb.h:2136
upb_enumdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2984
jsonenc_getanymsg
static const upb_msgdef * jsonenc_getanymsg(jsonenc *e, upb_strview type_url)
Definition: php-upb.c:9100
_upb_mapsorter_init
UPB_INLINE void _upb_mapsorter_init(_upb_mapsorter *s)
Definition: php-upb.h:1700
jsonenc_value
static void jsonenc_value(jsonenc *e, const upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:9262
wireval::uint32_val
uint32_t uint32_val
Definition: php-upb.c:394
google_protobuf_ServiceDescriptorProto__fields
static const upb_msglayout_field google_protobuf_ServiceDescriptorProto__fields[3]
Definition: php-upb.c:4192
jsondec_mask
static upb_strview jsondec_mask(jsondec *d, const char *buf, const char *end)
Definition: php-upb.c:8567
upb_fielddef_index
uint32_t upb_fielddef_index(const upb_fielddef *f)
Definition: php-upb.c:5171
upb_fielddef::number_
uint32_t number_
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2952
jsonenc_arena
static upb_arena * jsonenc_arena(jsonenc *e)
Definition: php-upb.c:8847
count
int * count
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:96
UPB_DTYPE_FLOAT
@ UPB_DTYPE_FLOAT
Definition: php-upb.h:555
jsondec_unicode
static size_t jsondec_unicode(jsondec *d, char *out)
Definition: php-upb.c:7701
upb_fielddef_fullname
const char * upb_fielddef_fullname(const upb_fielddef *f)
Definition: php-upb.c:5128
upb_strtable::t
upb_table t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:845
google_protobuf_FieldDescriptorProto_has_name
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_name(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:926
nullz
static void nullz(upb_status *status)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2187
jsondec_codepoint
static uint32_t jsondec_codepoint(jsondec *d)
Definition: php-upb.c:7674
jsonenc_putsep
static void jsonenc_putsep(jsonenc *e, const char *str, bool *first)
Definition: php-upb.c:9165
CASE
#define CASE(ctype, type, wtype, encodeval)
upb_oneofdef_fieldcount
int upb_oneofdef_fieldcount(const upb_oneofdef *o)
Definition: php-upb.c:5546
UPB_LABEL_REPEATED
@ UPB_LABEL_REPEATED
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:494
findentry
static const upb_tabent * findentry(const upb_table *t, lookupkey_t key, uint32_t hash, eqlfunc_t *eql)
Definition: php-upb.c:1985
upb_filedef_dep
const upb_filedef * upb_filedef_dep(const upb_filedef *f, int i)
Definition: php-upb.c:5634
upb_oneof_done
bool upb_oneof_done(upb_oneof_iter *iter)
Definition: php-upb.c:5588
count_types_in_file
static void count_types_in_file(const google_protobuf_FileDescriptorProto *file_proto, upb_filedef *file)
Definition: php-upb.c:6661
_upb_value_setval
UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val, upb_ctype_t ctype)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:706
upb_msg_clearfield
void upb_msg_clearfield(upb_msg *msg, const upb_fielddef *f)
Definition: php-upb.c:7145
google_protobuf_EnumOptions_submsgs
static const upb_msglayout *const google_protobuf_EnumOptions_submsgs[1]
Definition: php-upb.c:4309
google_protobuf_FileOptions__fields
static const upb_msglayout_field google_protobuf_FileOptions__fields[21]
Definition: php-upb.c:4227
jsondec_wrapper
static void jsondec_wrapper(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8730
google_protobuf_OneofOptions_submsgs
static const upb_msglayout *const google_protobuf_OneofOptions_submsgs[1]
Definition: php-upb.c:4295
google_protobuf_GeneratedCodeInfo_msginit
const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit
Definition: php-upb.c:4438
google_protobuf_OneofOptions_msginit
const upb_msglayout google_protobuf_OneofOptions_msginit
Definition: php-upb.c:4303
google_protobuf_DescriptorProto_field
const UPB_INLINE google_protobuf_FieldDescriptorProto *const * google_protobuf_DescriptorProto_field(const google_protobuf_DescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:513
UPB_UNLIKELY
#define UPB_UNLIKELY(x)
Definition: php-upb.c:104
str_tabent
static const upb_tabent * str_tabent(const upb_strtable_iter *i)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1632
_upb_tabent
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:807
create_fielddef
static void create_fielddef(symtab_addctx *ctx, const char *prefix, upb_msgdef *m, const google_protobuf_FieldDescriptorProto *field_proto)
Definition: php-upb.c:6352
upb_table
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:818
google_protobuf_FieldDescriptorProto_submsgs
static const upb_msglayout *const google_protobuf_FieldDescriptorProto_submsgs[1]
Definition: php-upb.c:4101
jsondec_objstart
static void jsondec_objstart(jsondec *d)
Definition: php-upb.c:7551
upb_cleanup_pointer
static uint32_t * upb_cleanup_pointer(uintptr_t cleanup_metadata)
Definition: php-upb.c:2730
upb_array_size
size_t upb_array_size(const upb_array *arr)
Definition: php-upb.c:7260
OP_STRING
#define OP_STRING
Definition: php-upb.c:321
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
UPB_JSONENC_EMITDEFAULTS
@ UPB_JSONENC_EMITDEFAULTS
Definition: php-upb.h:4802
upb_arena::refcount
uint32_t refcount
Definition: php-upb.h:1759
google_protobuf_EnumOptions__fields
static const upb_msglayout_field google_protobuf_EnumOptions__fields[3]
Definition: php-upb.c:4313
JD_OBJECT
@ JD_OBJECT
Definition: php-upb.c:7382
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
google_protobuf_FieldDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_FieldDescriptorProto_name(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:933
UPB_DTYPE_STRING
@ UPB_DTYPE_STRING
Definition: php-upb.h:562
jsondec::is_first
bool is_first
Definition: php-upb.c:7377
upb_filedef_name
const char * upb_filedef_name(const upb_filedef *f)
Definition: php-upb.c:5602
decode_isdonefallback
const UPB_NOINLINE char * decode_isdonefallback(upb_decstate *d, const char *ptr, int overrun)
Definition: php-upb.c:568
get_field_size
static size_t get_field_size(const upb_msglayout_field *f)
Definition: php-upb.c:6988
upb_isalphanum
static bool upb_isalphanum(char c)
Definition: php-upb.c:4988
upb_map_size
size_t upb_map_size(const upb_map *map)
Definition: php-upb.c:7300
google_protobuf_DescriptorProto__fields
static const upb_msglayout_field google_protobuf_DescriptorProto__fields[10]
Definition: php-upb.c:4041
profile_analyzer.fields
list fields
Definition: profile_analyzer.py:266
L
lua_State * L
Definition: upb/upb/bindings/lua/main.c:35
fix_build_deps.r
r
Definition: fix_build_deps.py:491
upb_inttable_iter_setdone
void upb_inttable_iter_setdone(upb_inttable_iter *i)
Definition: php-upb.c:2649
upb_fielddef::is_extension_
bool is_extension_
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2955
first
StrT first
Definition: cxa_demangle.cpp:4884
upb_msgval::msg_val
const upb_msg * msg_val
Definition: php-upb.h:4621
google_protobuf_EnumValueDescriptorProto_number
UPB_INLINE int32_t google_protobuf_EnumValueDescriptorProto_number(const google_protobuf_EnumValueDescriptorProto *msg)
Definition: descriptor.upb.h:1394
google_protobuf_FileDescriptorProto_name
UPB_INLINE upb_StringView google_protobuf_FileDescriptorProto_name(const google_protobuf_FileDescriptorProto *msg)
Definition: descriptor.upb.h:256
int_arrent
static upb_tabval int_arrent(const upb_inttable_iter *i)
Definition: php-upb.c:2600
hashfunc_t
uint32_t hashfunc_t(upb_tabkey key)
Definition: php-upb.c:1928
upb_msg_iter_oneof
const upb_oneofdef * upb_msg_iter_oneof(const upb_msg_oneof_iter *iter)
Definition: php-upb.c:5523
google_protobuf_DescriptorProto_ReservedRange_msginit
const upb_msglayout google_protobuf_DescriptorProto_ReservedRange_msginit
Definition: php-upb.c:4081
upb_msgdef_layout
const upb_msglayout * upb_msgdef_layout(const upb_msgdef *m)
Definition: php-upb.c:5445
encode_message
static void encode_message(upb_encstate *e, const upb_msg *msg, const upb_msglayout *m, size_t *size)
Definition: php-upb.c:1412
values
std::array< int64_t, Size > values
Definition: abseil-cpp/absl/container/btree_benchmark.cc:608
UPB_DESCRIPTOR_TYPE_INT64
@ UPB_DESCRIPTOR_TYPE_INT64
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:501
between
static bool between(int32_t x, int32_t low, int32_t high)
Definition: php-upb.c:5335
upb_map_new
upb_map * upb_map_new(upb_arena *a, upb_fieldtype_t key_type, upb_fieldtype_t value_type)
Definition: php-upb.c:7294
upb_status_seterrmsg
void upb_status_seterrmsg(upb_status *status, const char *msg)
Definition: php-upb.c:2686
decode_verifyutf8
static void decode_verifyutf8(upb_decstate *d, const char *buf, int len)
Definition: php-upb.c:435
upb_inttable_done
bool upb_inttable_done(const upb_inttable_iter *i)
Definition: php-upb.c:2627
prefix
static const char prefix[]
Definition: head_of_line_blocking.cc:28
upb_tabstrview
UPB_INLINE upb_strview upb_tabstrview(upb_tabkey key)
Definition: php-upb.h:864
build_filedef
static void build_filedef(symtab_addctx *ctx, upb_filedef *file, const google_protobuf_FileDescriptorProto *file_proto)
Definition: php-upb.c:6729
encode_bytes
static void encode_bytes(upb_encstate *e, const void *data, size_t len)
Definition: php-upb.c:1079
xds_manager.num
num
Definition: xds_manager.py:56
UPB_MAPENTRY_VALUE
#define UPB_MAPENTRY_VALUE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:3310
UPB_DESCRIPTOR_TYPE_BOOL
@ UPB_DESCRIPTOR_TYPE_BOOL
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:506
decode_toarray
static const char * decode_toarray(upb_decstate *d, const char *ptr, upb_msg *msg, upb_msglayout const *const *submsgs, const upb_msglayout_field *field, wireval *val, int op)
Definition: php-upb.c:632
UPB_MAX_FIELDNUMBER
#define UPB_MAX_FIELDNUMBER
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:3006
int_tabent
static const upb_tabent * int_tabent(const upb_inttable_iter *i)
Definition: php-upb.c:2595
absl::hash_internal::k1
static const uint64_t k1
Definition: abseil-cpp/absl/hash/internal/city.cc:54
parse
static void parse(const char *s)
Definition: debug/trace.cc:121
decode_togroup
static const UPB_FORCEINLINE char * decode_togroup(upb_decstate *d, const char *ptr, upb_msg *submsg, upb_msglayout const *const *submsgs, const upb_msglayout_field *field)
Definition: php-upb.c:624
type_url
string * type_url
Definition: bloaty/third_party/protobuf/conformance/conformance_cpp.cc:72
upb_fielddef_ismap
bool upb_fielddef_ismap(const upb_fielddef *f)
Definition: php-upb.c:5320
strkey2
static lookupkey_t strkey2(const char *str, size_t len)
Definition: php-upb.c:1915
ok
bool ok
Definition: async_end2end_test.cc:197
google_protobuf_OneofOptions__fields
static const upb_msglayout_field google_protobuf_OneofOptions__fields[1]
Definition: php-upb.c:4299
decode_isdone
UPB_INLINE bool decode_isdone(upb_decstate *d, const char **ptr)
Definition: php-upb.h:1859
UPB_WIRE_TYPE_64BIT
@ UPB_WIRE_TYPE_64BIT
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:462
upb_strtable_clear
void upb_strtable_clear(upb_strtable *t)
Definition: php-upb.c:2288
state
Definition: bloaty/third_party/zlib/contrib/blast/blast.c:41
UPB_SYNTAX_PROTO3
@ UPB_SYNTAX_PROTO3
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2973
UPB_UNUSED
#define UPB_UNUSED(var)
Definition: php-upb.c:128
_upb_mapsorter_cmpu32
static int _upb_mapsorter_cmpu32(const void *_a, const void *_b)
Definition: php-upb.c:1704
deps
static upb_def_init * deps[1]
Definition: php-upb.c:4833
upb_extreg_new
upb_extreg * upb_extreg_new(upb_arena *arena)
Definition: php-upb.c:1805
_upb_msg_addunknown
bool _upb_msg_addunknown(upb_msg *msg, const char *data, size_t len, upb_arena *arena)
Definition: php-upb.c:1533
jsondec_arrnext
static bool jsondec_arrnext(jsondec *d)
Definition: php-upb.c:7547
absl::Status::ok
ABSL_MUST_USE_RESULT bool ok() const
Definition: third_party/abseil-cpp/absl/status/status.h:802
finalize_oneofs
static void finalize_oneofs(symtab_addctx *ctx, upb_msgdef *m)
Definition: php-upb.c:6060
UPB_TYPE_MESSAGE
@ UPB_TYPE_MESSAGE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:483
UPB_PARSE_PARAMS
#define UPB_PARSE_PARAMS
Definition: php-upb.h:2012
upb_inttable_begin
void upb_inttable_begin(upb_inttable_iter *i, const upb_inttable *t)
Definition: php-upb.c:2605
jsondec
Definition: php-upb.c:7368
upb_msgdef_mapentry
bool upb_msgdef_mapentry(const upb_msgdef *m)
Definition: php-upb.c:5459
jsondec_duration
static void jsondec_duration(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8448
upb_filedef_depcount
int upb_filedef_depcount(const upb_filedef *f)
Definition: php-upb.c:5626
upb_strtable_begin
void upb_strtable_begin(upb_strtable_iter *i, const upb_strtable *t)
Definition: php-upb.c:2347
upb_DefPool::files
upb_strtable files
Definition: upb/upb/def.c:220
_upb_mapsorter_cmpi64
static int _upb_mapsorter_cmpi64(const void *_a, const void *_b)
Definition: php-upb.c:1686
upb_strtable
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:844
jsondec_escape
static char jsondec_escape(jsondec *d)
Definition: php-upb.c:7651
jsonenc_double
static void jsonenc_double(jsonenc *e, const char *fmt, double val)
Definition: php-upb.c:9071
upb_msg_oneof_done
bool upb_msg_oneof_done(const upb_msg_oneof_iter *iter)
Definition: php-upb.c:5519
upb_fielddef::enumdef
const upb_enumdef * enumdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2949
upb_inttable_iter_value
upb_value upb_inttable_iter_value(const upb_inttable_iter *i)
Definition: php-upb.c:2643
upb_msgdef_numfields
int upb_msgdef_numfields(const upb_msgdef *m)
Definition: php-upb.c:5421
upb_msg_mutable
upb_mutmsgval upb_msg_mutable(upb_msg *msg, const upb_fielddef *f, upb_arena *a)
Definition: php-upb.c:7098
google_protobuf_FieldDescriptorProto_has_options
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_options(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:996
UPB_DTYPE_GROUP
@ UPB_DTYPE_GROUP
Definition: php-upb.h:563
_upb_array_constptr
const UPB_INLINE void * _upb_array_constptr(const upb_array *arr)
Definition: php-upb.h:1340
jsondec_tryskipdigits
static bool jsondec_tryskipdigits(jsondec *d)
Definition: php-upb.c:7571
upb_tabval::val
uint64_t val
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:799
getentry_mutable
static upb_tabent * getentry_mutable(upb_table *t, uint32_t hash)
Definition: php-upb.c:1981
jsondec_seqnext
static bool jsondec_seqnext(jsondec *d, char end_ch)
Definition: php-upb.c:7528
assign_layout_indices
static void assign_layout_indices(const upb_msgdef *m, upb_msglayout *l, upb_msglayout_field *fields)
Definition: php-upb.c:5834
google_protobuf_ServiceDescriptorProto_submsgs
static const upb_msglayout *const google_protobuf_ServiceDescriptorProto_submsgs[2]
Definition: php-upb.c:4187
next
static size_t next(const upb_table *t, size_t i)
Definition: php-upb.c:2101
upb_fielddef::label_
upb_label_t label_
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2959
google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit
const upb_msglayout google_protobuf_EnumDescriptorProto_EnumReservedRange_msginit
Definition: php-upb.c:4165
VARINT_CASE
#define VARINT_CASE(ctype, encode)
_upb_fieldtype_to_mapsize
static char _upb_fieldtype_to_mapsize[12]
Definition: php-upb.c:7014
google_protobuf_MessageOptions_map_entry
UPB_INLINE bool google_protobuf_MessageOptions_map_entry(const google_protobuf_MessageOptions *msg)
Definition: descriptor.upb.h:2046
encode_reserve
static UPB_FORCEINLINE void encode_reserve(upb_encstate *e, size_t bytes)
Definition: php-upb.c:1069
cleanup_ent::cleanup
upb_cleanup_func * cleanup
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2282
upb_fielddef_defaultint32
int32_t upb_fielddef_defaultint32(const upb_fielddef *f)
Definition: php-upb.c:5247
upb_msglayout_ext
Definition: php-upb.h:1148
upb_filedef::deps
const upb_filedef ** deps
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3007
google_protobuf_FileDescriptorSet__fields
static const upb_msglayout_field google_protobuf_FileDescriptorSet__fields[1]
Definition: php-upb.c:3991
jsonenc_putbytes
static void jsonenc_putbytes(jsonenc *e, const void *data, size_t len)
Definition: php-upb.c:8855
encode_zz32
static uint32_t encode_zz32(int32_t n)
Definition: php-upb.c:1022
upb_arena_fuse
bool upb_arena_fuse(upb_arena *a1, upb_arena *a2)
Definition: php-upb.c:2919
upb_oneofdef_containingtype
const upb_msgdef * upb_oneofdef_containingtype(const upb_oneofdef *o)
Definition: php-upb.c:5542
google_protobuf_ExtensionRangeOptions_submsgs
static const upb_msglayout *const google_protobuf_ExtensionRangeOptions_submsgs[1]
Definition: php-upb.c:4087
getjsonname
size_t getjsonname(const char *name, char *buf, size_t len)
Definition: php-upb.c:6095
UnalignedLoad64
static uint64_t UnalignedLoad64(const void *p)
Definition: php-upb.c:2131
jsondec_objnext
static bool jsondec_objnext(jsondec *d)
Definition: php-upb.c:7561
upb_filedef::phpnamespace
const char * phpnamespace
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3004
upb_msgdef_lookupjsonname
const upb_fielddef * upb_msgdef_lookupjsonname(const upb_msgdef *m, const char *name, size_t len)
Definition: php-upb.c:5406
_UPB_MODE_MAP
@ _UPB_MODE_MAP
Definition: php-upb.h:1097
upb_symtab_lookupmsg
const upb_msgdef * upb_symtab_lookupmsg(const upb_symtab *s, const char *sym)
Definition: php-upb.c:5674
_upb_symtab_bytesloaded
size_t _upb_symtab_bytesloaded(const upb_symtab *s)
Definition: php-upb.c:6973
UPB_WELLKNOWN_STRUCT
@ UPB_WELLKNOWN_STRUCT
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2999
google_protobuf_UninterpretedOption_NamePart_msginit
const upb_msglayout google_protobuf_UninterpretedOption_NamePart_msginit
Definition: php-upb.c:4396
google_protobuf_descriptor_proto_upbdefinit
upb_def_init google_protobuf_descriptor_proto_upbdefinit
Definition: php-upb.c:4837
jsondec_true
static void jsondec_true(jsondec *d)
Definition: php-upb.c:7466
UPB_LIKELY
#define UPB_LIKELY(x)
Definition: php-upb.c:103
UPB_WELLKNOWN_BOOLVALUE
@ UPB_WELLKNOWN_BOOLVALUE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2996
internal
Definition: benchmark/test/output_test_helper.cc:20
google_protobuf_GeneratedCodeInfo_Annotation_msginit
const upb_msglayout google_protobuf_GeneratedCodeInfo_Annotation_msginit
Definition: php-upb.c:4451
symtab_addctx::err
jmp_buf err
Definition: php-upb.c:5725
upb_msg_getinternal_const
static const upb_msg_internal * upb_msg_getinternal_const(const upb_msg *msg)
Definition: php-upb.c:1487
symtab_addctx
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3740
upb_fielddef_isextension
bool upb_fielddef_isextension(const upb_fielddef *f)
Definition: php-upb.c:5183
table
uint8_t table[256]
Definition: hpack_parser.cc:456
_upb_extreg_get
const upb_msglayout_field * _upb_extreg_get(const upb_extreg *r, const upb_msglayout *l, uint32_t num)
Definition: php-upb.c:1835
decode_reserve
static bool decode_reserve(upb_decstate *d, upb_array *arr, size_t elem)
Definition: php-upb.c:439
jsondec_null
static void jsondec_null(jsondec *d)
Definition: php-upb.c:7468
iter
Definition: test_winkernel.cpp:47
upb_msgval::int32_val
int32_t int32_val
Definition: php-upb.h:4616
google_protobuf_FieldDescriptorProto_type
UPB_INLINE int32_t google_protobuf_FieldDescriptorProto_type(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:973
google_protobuf_DescriptorProto_msginit
const upb_msglayout google_protobuf_DescriptorProto_msginit
Definition: php-upb.c:4054
google_protobuf_FieldDescriptorProto_has_default_value
UPB_INLINE bool google_protobuf_FieldDescriptorProto_has_default_value(const google_protobuf_FieldDescriptorProto *msg)
Definition: descriptor.upb.h:986
_upb_msg_new
upb_msg * _upb_msg_new(const upb_msglayout *l, upb_arena *a)
Definition: php-upb.c:1492
upb_strview
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:257
_upb_mapsorter_getkeys
static void _upb_mapsorter_getkeys(const void *_a, const void *_b, void *a_key, void *b_key, size_t size)
Definition: php-upb.c:1676
_upb_sortedmap
Definition: php-upb.h:1694
php-upb.h
jsondec_msg
static upb_msgval jsondec_msg(jsondec *d, const upb_fielddef *f)
Definition: php-upb.c:8237
jsondec_arrstart
static void jsondec_arrstart(jsondec *d)
Definition: php-upb.c:7537
xds_manager.f2
f2
Definition: xds_manager.py:85
OP_SCALAR_LG2
#define OP_SCALAR_LG2(n)
Definition: php-upb.c:320
upb_status_vappenderrf
void upb_status_vappenderrf(upb_status *status, const char *fmt, va_list args)
Definition: php-upb.c:2707
i2
int i2
Definition: abseil-cpp/absl/container/btree_test.cc:2773
in_oneof
static bool in_oneof(const upb_msglayout_field *field)
Definition: php-upb.c:7050
str_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2920
google_protobuf_OneofDescriptorProto_msginit
const upb_msglayout google_protobuf_OneofDescriptorProto_msginit
Definition: php-upb.c:4134
JD_TRUE
@ JD_TRUE
Definition: php-upb.c:7382
shortdefname
static const char * shortdefname(const char *fullname)
Definition: php-upb.c:4992
upb_array::size
size_t size
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:581
arena_findroot
static upb_arena * arena_findroot(upb_arena *a)
Definition: php-upb.c:2763
UPB_WIRE_TYPE_START_GROUP
@ UPB_WIRE_TYPE_START_GROUP
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:464
upb_filedef::enum_count
int enum_count
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3014
int8_t
signed char int8_t
Definition: stdint-msvc2008.h:75
jsonenc::overflow
size_t overflow
Definition: php-upb.c:8816
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
ch
char ch
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3621
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
autogen_x86imm.tmp
tmp
Definition: autogen_x86imm.py:12
cleanup
Definition: cleanup.py:1
_upb_repeated_or_map
UPB_INLINE bool _upb_repeated_or_map(const upb_msglayout_field *field)
Definition: php-upb.h:1111
intrin.h
upb_filedef::enums
const upb_enumdef * enums
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3009
google_protobuf_EnumValueOptions_submsgs
static const upb_msglayout *const google_protobuf_EnumValueOptions_submsgs[1]
Definition: php-upb.c:4325
rm
static bool rm(upb_table *t, lookupkey_t key, upb_value *val, upb_tabkey *removed, uint32_t hash, eqlfunc_t *eql)
Definition: php-upb.c:2062
is_pow2
static bool is_pow2(uint64_t v)
Definition: php-upb.c:1873
encode_zz64
static uint64_t encode_zz64(int64_t n)
Definition: php-upb.c:1023
jsonenc_putstr
static void jsonenc_putstr(jsonenc *e, const char *str)
Definition: php-upb.c:8869
decode_pushlimit
UPB_INLINE int decode_pushlimit(upb_decstate *d, const char *ptr, int size)
Definition: php-upb.h:1898
UPB_DESCRIPTOR_TYPE_INT32
@ UPB_DESCRIPTOR_TYPE_INT32
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:503
google_protobuf_ServiceOptions__fields
static const upb_msglayout_field google_protobuf_ServiceOptions__fields[2]
Definition: php-upb.c:4344
chkdefaulttype
static void chkdefaulttype(const upb_fielddef *f, int ctype)
Definition: php-upb.c:5237
google_protobuf_DescriptorProto
struct google_protobuf_DescriptorProto google_protobuf_DescriptorProto
Definition: descriptor.upb.h:52
upb_strtable_done
bool upb_strtable_done(const upb_strtable_iter *i)
Definition: php-upb.c:2356
upb_map_entry
Definition: php-upb.h:1499
upb_msgdef::full_name
const char * full_name
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2964
UPB_FORCEINLINE
#define UPB_FORCEINLINE
Definition: php-upb.c:119
file::name
char * name
Definition: bloaty/third_party/zlib/examples/gzappend.c:176
google_protobuf_FileDescriptorProto_msginit
const upb_msglayout google_protobuf_FileDescriptorProto_msginit
Definition: php-upb.c:4025
jsonenc_fieldpath
static void jsonenc_fieldpath(jsonenc *e, upb_strview path)
Definition: php-upb.c:9173
UPB_DEFTYPE_MSG
@ UPB_DEFTYPE_MSG
Definition: php-upb.c:4961
upb_fielddef::str
str_t * str
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2944
_upb_isle
UPB_INLINE bool _upb_isle(void)
Definition: php-upb.h:576
run_grpclb_interop_tests.l
dictionary l
Definition: run_grpclb_interop_tests.py:410
upb_fielddef_defaultint64
int64_t upb_fielddef_defaultint64(const upb_fielddef *f)
Definition: php-upb.c:5242
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
upb_filedef::package
const char * package
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3002
init
static bool init(upb_table *t, uint8_t size_lg2, upb_arena *a)
Definition: php-upb.c:1950
upb_strtable_iter
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:1086
upb_msg_oneof_iter_setdone
void upb_msg_oneof_iter_setdone(upb_msg_oneof_iter *iter)
Definition: php-upb.c:5527
_upb_tabent::key
upb_tabkey key
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:808
google_protobuf_DescriptorProto_nested_type
const UPB_INLINE google_protobuf_DescriptorProto *const * google_protobuf_DescriptorProto_nested_type(const google_protobuf_DescriptorProto *msg, size_t *len)
Definition: descriptor.upb.h:522
_upb_extreg_add
bool _upb_extreg_add(upb_extreg *r, const upb_msglayout_ext *e, size_t count)
Definition: php-upb.c:1813
length
std::size_t length
Definition: abseil-cpp/absl/time/internal/test_util.cc:57
key_type
upb_fieldtype_t key_type
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1071
upb_encstate::err
jmp_buf err
Definition: php-upb.c:1026
jsonenc_enum
static void jsonenc_enum(int32_t val, const upb_fielddef *f, jsonenc *e)
Definition: php-upb.c:8969
remove_filedef
static void remove_filedef(upb_symtab *s, upb_filedef *file)
Definition: php-upb.c:6860
upb_msgdef::itof
upb_inttable itof
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2969
INT32_MAX
#define INT32_MAX
Definition: stdint-msvc2008.h:137
upb_ok
bool upb_ok(const upb_status *status)
Definition: php-upb.c:2682
regress.m
m
Definition: regress/regress.py:25
mkowners.depth
depth
Definition: mkowners.py:114
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
upb_alloc
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:299
upb_map_entry::val
upb_value val
Definition: php-upb.h:1503
upb_strdup2
char * upb_strdup2(const char *s, size_t len, upb_arena *a)
Definition: php-upb.c:1889
upb_encode
char * upb_encode(const void *msg, const upb_msglayout *m, upb_arena *arena, size_t *size)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1105
inteql
static bool inteql(upb_tabkey k1, lookupkey_t k2)
Definition: php-upb.c:2396
encode_array
static void encode_array(upb_encstate *e, const upb_msg *msg, const upb_msglayout *m, const upb_msglayout_field *f)
Definition: php-upb.c:1245
_upb_map_fromkey
UPB_INLINE void _upb_map_fromkey(upb_strview key, void *out, size_t size)
Definition: php-upb.h:1531
upb_extreg::exts
upb_strtable exts
Definition: php-upb.c:1795
upb_fielddef_realcontainingoneof
const upb_oneofdef * upb_fielddef_realcontainingoneof(const upb_fielddef *f)
Definition: php-upb.c:5215
_UPB_MODE_IS_PACKED
@ _UPB_MODE_IS_PACKED
Definition: php-upb.h:1104
upb_map_set
bool upb_map_set(upb_map *map, upb_msgval key, upb_msgval val, upb_arena *arena)
Definition: php-upb.c:7312
__asan_poison_memory_region
static void __asan_poison_memory_region(const void *addr, size_t size)
Definition: mem.c:82
lookupkey_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1324
UPB_WELLKNOWN_INT64VALUE
@ UPB_WELLKNOWN_INT64VALUE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2989
jsondec::depth
int depth
Definition: php-upb.c:7372
jsondec_nanos
static int jsondec_nanos(jsondec *d, const char **ptr, const char *end)
Definition: php-upb.c:8350
upb_msglayout_field
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:556
upb_oneofdef_name
const char * upb_oneofdef_name(const upb_oneofdef *o)
Definition: php-upb.c:5538
upb_fielddef::sint
int64_t sint
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2939
upb_fielddef_defaultstr
const char * upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len)
Definition: php-upb.c:5277
upb_msgval_sizeof
static size_t upb_msgval_sizeof(upb_fieldtype_t type)
Definition: php-upb.c:5785
google_protobuf_FileDescriptorProto_parse_ex
UPB_INLINE google_protobuf_FileDescriptorProto * google_protobuf_FileDescriptorProto_parse_ex(const char *buf, size_t size, const upb_ExtensionRegistry *extreg, int options, upb_Arena *arena)
Definition: descriptor.upb.h:231
symtab_alloc
void * symtab_alloc(symtab_addctx *ctx, size_t bytes)
Definition: php-upb.c:5743
upb_msgdef_field
const upb_fielddef * upb_msgdef_field(const upb_msgdef *m, int i)
Definition: php-upb.c:5449
UPB_ENCODE_DETERMINISTIC
@ UPB_ENCODE_DETERMINISTIC
Definition: php-upb.h:1942
fastdecode_generic
const char * fastdecode_generic(struct upb_decstate *d, const char *ptr, upb_msg *msg, intptr_t table, uint64_t hasbits, uint64_t data)
Definition: php-upb.c:933
demo_pb2._b
int _b
Definition: demo_pb2.py:6
strhash
static uint32_t strhash(upb_tabkey key)
Definition: php-upb.c:2268
upb_fielddef_checklabel
bool upb_fielddef_checklabel(int32_t label)
Definition: php-upb.c:5339
jsonenc_timestamp
static void jsonenc_timestamp(jsonenc *e, const upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8907
jsondec_any
static void jsondec_any(jsondec *d, upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:8667
upb_fielddef::file
const upb_filedef * file
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2935
google_protobuf_FileDescriptorProto
struct google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto
Definition: descriptor.upb.h:51
jsonenc_string
static void jsonenc_string(jsonenc *e, upb_strview str)
Definition: php-upb.c:9065
op
static grpc_op * op
Definition: test/core/fling/client.cc:47
upb_fielddef_hassubdef
bool upb_fielddef_hassubdef(const upb_fielddef *f)
Definition: php-upb.c:5325
upb_filedef::name
const char * name
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3001
jsondec_err
static UPB_NORETURN void jsondec_err(jsondec *d, const char *msg)
Definition: php-upb.c:7408
upb_fielddef_label
upb_label_t upb_fielddef_label(const upb_fielddef *f)
Definition: php-upb.c:5175
create_enumdef
static void create_enumdef(symtab_addctx *ctx, const char *prefix, const google_protobuf_EnumDescriptorProto *enum_proto)
Definition: php-upb.c:6516
_upb_array_new
UPB_INLINE upb_array * _upb_array_new(upb_arena *a, size_t init_size, int elem_size_lg2)
Definition: php-upb.h:1360
jsonenc_map
static void jsonenc_map(jsonenc *e, const upb_map *map, const upb_fielddef *f)
Definition: php-upb.c:9418
UPB_MAPENTRY_KEY
#define UPB_MAPENTRY_KEY
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:3309
upb_filedef_enum
const upb_enumdef * upb_filedef_enum(const upb_filedef *f, int i)
Definition: php-upb.c:5642
UPB_TYPE_DOUBLE
@ UPB_TYPE_DOUBLE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:485
google_protobuf_FieldOptions_msginit
const upb_msglayout google_protobuf_FieldOptions_msginit
Definition: php-upb.c:4289
google_protobuf_FileOptions
struct google_protobuf_FileOptions google_protobuf_FileOptions
Definition: descriptor.upb.h:63
google_protobuf_MessageOptions
struct google_protobuf_MessageOptions google_protobuf_MessageOptions
Definition: descriptor.upb.h:64
intkey
static lookupkey_t intkey(uintptr_t key)
Definition: php-upb.c:1922
upb_strview::size
size_t size
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:259
jsondec_bool
static upb_msgval jsondec_bool(jsondec *d, const upb_fielddef *f)
Definition: php-upb.c:8167
UPB_TYPE_BOOL
@ UPB_TYPE_BOOL
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:474
addr
struct sockaddr_in addr
Definition: libuv/docs/code/tcp-echo-server/main.c:10
jsonenc_wrapper
static void jsonenc_wrapper(jsonenc *e, const upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:9093
upb_table_size
UPB_INLINE size_t upb_table_size(const upb_table *t)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:863
upb_filedef_enumcount
int upb_filedef_enumcount(const upb_filedef *f)
Definition: php-upb.c:5630
upb_array_new
upb_array * upb_array_new(upb_arena *a, upb_fieldtype_t type)
Definition: php-upb.c:7256
jsonenc::ptr
char * ptr
Definition: php-upb.c:8815
upb_fielddef::dbl
double dbl
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2941
UPB_TYPE_INT64
@ UPB_TYPE_INT64
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:486
if
if(p->owned &&p->wrapped !=NULL)
Definition: call.c:42
_upb_array_append_fallback
bool _upb_array_append_fallback(upb_array **arr_ptr, const void *value, int elem_size_lg2, upb_arena *arena)
Definition: php-upb.c:1644
upb_encstate::options
int options
Definition: php-upb.c:1029
jsonenc_any
static void jsonenc_any(jsonenc *e, const upb_msg *msg, const upb_msgdef *m)
Definition: php-upb.c:9136
upb_mapiter_done
bool upb_mapiter_done(const upb_map *map, size_t iter)
Definition: php-upb.c:7325
jsonenc_nanos
static void jsonenc_nanos(jsonenc *e, int32_t nanos)
Definition: php-upb.c:8891
upb_oneofdef::field_count
int field_count
Definition: php-upb.c:4923
upb_mapiter_next
bool upb_mapiter_next(const upb_map *map, size_t *iter)
Definition: php-upb.c:7321
upb_status_errmsg
const char * upb_status_errmsg(const upb_status *status)
Definition: php-upb.c:2684
_upb_oneofcase_field
UPB_INLINE uint32_t * _upb_oneofcase_field(upb_msg *msg, const upb_msglayout_field *f)
Definition: php-upb.h:1316
binary_size.old_size
old_size
Definition: binary_size.py:125
alloc
std::allocator< int > alloc
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:87
UPB_UNPOISON_MEMORY_REGION
#define UPB_UNPOISON_MEMORY_REGION(addr, size)
Definition: php-upb.c:253
upb_inttable_iter_key
uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i)
Definition: php-upb.c:2638
UPB_LONGJMP
#define UPB_LONGJMP(buf, val)
Definition: php-upb.c:164
OP_BYTES
#define OP_BYTES
Definition: php-upb.c:322
errno.h
upb_mapiter_value
upb_msgval upb_mapiter_value(const upb_map *map, size_t iter)
Definition: php-upb.c:7343
upb_msgdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2962
upb_strtable_count
UPB_INLINE size_t upb_strtable_count(const upb_strtable *t)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:919
decode_munge
static void decode_munge(int type, wireval *val)
Definition: php-upb.c:501
wireval
Definition: php-upb.c:392
encode_tag
static void encode_tag(upb_encstate *e, uint32_t field_number, uint8_t wire_type)
Definition: php-upb.c:1131
upb_fielddef::flt
float flt
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2942
upb_map_get
bool upb_map_get(const upb_map *map, upb_msgval key, upb_msgval *val)
Definition: php-upb.c:7304
wireval::bool_val
bool bool_val
Definition: php-upb.c:393
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
google_protobuf_EnumValueOptions__fields
static const upb_msglayout_field google_protobuf_EnumValueOptions__fields[2]
Definition: php-upb.c:4329
UPB_WELLKNOWN_LISTVALUE
@ UPB_WELLKNOWN_LISTVALUE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2998
_upb_value_val
static upb_value _upb_value_val(uint64_t val)
Definition: php-upb.c:1875
state
static struct rpc_state state
Definition: bad_server_response_test.cc:87
upb_msgval::int64_val
int64_t int64_val
Definition: php-upb.h:4617
upb_oneofdef_ntof
const upb_fielddef * upb_oneofdef_ntof(const upb_oneofdef *o, const char *name, size_t length)
Definition: php-upb.c:5567
upb_inttable_insert
bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val, upb_arena *a)
Definition: php-upb.c:2462
_upb_map_new
upb_map * _upb_map_new(upb_arena *a, size_t key_size, size_t value_size)
Definition: php-upb.c:1662
upb_msgval::uint32_val
uint32_t uint32_val
Definition: php-upb.h:4618
UPB_WELLKNOWN_ANY
@ UPB_WELLKNOWN_ANY
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:2982
upb_arena::parent
struct upb_arena * parent
Definition: php-upb.h:1760
upb_strtable_iter_value
upb_value upb_strtable_iter_value(const upb_strtable_iter *i)
Definition: php-upb.c:2371
div_round_up
static size_t div_round_up(size_t n, size_t d)
Definition: php-upb.c:5781
strcopy
static upb_tabkey strcopy(lookupkey_t k2, upb_arena *a)
Definition: php-upb.c:2119
upb_arena_realloc
UPB_INLINE void * upb_arena_realloc(upb_arena *a, void *ptr, size_t oldsize, size_t size)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:387
upb_filedef_msg
const upb_msgdef * upb_filedef_msg(const upb_filedef *f, int i)
Definition: php-upb.c:5638
upb_filedef::symtab
const upb_symtab * symtab
Definition: php-upb.c:4940
pack_def
static upb_value pack_def(const void *ptr, upb_deftype_t type)
Definition: php-upb.c:4974
upb_fielddef_defaultbool
bool upb_fielddef_defaultbool(const upb_fielddef *f)
Definition: php-upb.c:5262
upb_msgdef_syntax
upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m)
Definition: php-upb.c:5361
UPB_POISON_MEMORY_REGION
#define UPB_POISON_MEMORY_REGION(addr, size)
Definition: php-upb.c:251
encode_varint64
static UPB_NOINLINE size_t encode_varint64(uint64_t val, char *buf)
Definition: php-upb.c:1011
UPB_MUSTTAIL
#define UPB_MUSTTAIL
Definition: php-upb.c:181
decode_vret::val
uint64_t val
Definition: php-upb.c:449
decode_newsubmsg
static upb_msg * decode_newsubmsg(upb_decstate *d, upb_msglayout const *const *submsgs, const upb_msglayout_field *field)
Definition: php-upb.c:560
upb_fielddef_msgsubdef
const upb_msgdef * upb_fielddef_msgsubdef(const upb_fielddef *f)
Definition: php-upb.c:5291
upb_fielddef::oneof
const upb_oneofdef * oneof
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2946
upb_map
Definition: php-upb.h:1487


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:51