text_encode.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2021, Google LLC
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of Google LLC nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include "upb/text_encode.h"
29 
30 #include <ctype.h>
31 #include <float.h>
32 #include <inttypes.h>
33 #include <stdarg.h>
34 #include <stdio.h>
35 #include <string.h>
36 
37 #include "upb/reflection.h"
38 #include "upb/upb_internal.h"
39 
40 // Must be last.
41 #include "upb/port_def.inc"
42 
43 typedef struct {
44  char *buf, *ptr, *end;
45  size_t overflow;
47  int options;
50 } txtenc;
51 
52 static void txtenc_msg(txtenc* e, const upb_Message* msg,
53  const upb_MessageDef* m);
54 
55 static void txtenc_putbytes(txtenc* e, const void* data, size_t len) {
56  size_t have = e->end - e->ptr;
57  if (UPB_LIKELY(have >= len)) {
58  memcpy(e->ptr, data, len);
59  e->ptr += len;
60  } else {
61  if (have) {
62  memcpy(e->ptr, data, have);
63  e->ptr += have;
64  }
65  e->overflow += (len - have);
66  }
67 }
68 
69 static void txtenc_putstr(txtenc* e, const char* str) {
70  txtenc_putbytes(e, str, strlen(str));
71 }
72 
73 static void txtenc_printf(txtenc* e, const char* fmt, ...) {
74  size_t n;
75  size_t have = e->end - e->ptr;
76  va_list args;
77 
78  va_start(args, fmt);
79  n = vsnprintf(e->ptr, have, fmt, args);
80  va_end(args);
81 
82  if (UPB_LIKELY(have > n)) {
83  e->ptr += n;
84  } else {
85  e->ptr = UPB_PTRADD(e->ptr, have);
86  e->overflow += (n - have);
87  }
88 }
89 
90 static void txtenc_indent(txtenc* e) {
91  if ((e->options & UPB_TXTENC_SINGLELINE) == 0) {
92  int i = e->indent_depth;
93  while (i-- > 0) {
94  txtenc_putstr(e, " ");
95  }
96  }
97 }
98 
99 static void txtenc_endfield(txtenc* e) {
100  if (e->options & UPB_TXTENC_SINGLELINE) {
101  txtenc_putstr(e, " ");
102  } else {
103  txtenc_putstr(e, "\n");
104  }
105 }
106 
107 static void txtenc_enum(int32_t val, const upb_FieldDef* f, txtenc* e) {
108  const upb_EnumDef* e_def = upb_FieldDef_EnumSubDef(f);
109  const upb_EnumValueDef* ev = upb_EnumDef_FindValueByNumber(e_def, val);
110 
111  if (ev) {
112  txtenc_printf(e, "%s", upb_EnumValueDef_Name(ev));
113  } else {
114  txtenc_printf(e, "%" PRId32, val);
115  }
116 }
117 
118 static void txtenc_string(txtenc* e, upb_StringView str, bool bytes) {
119  const char* ptr = str.data;
120  const char* end = ptr + str.size;
121  txtenc_putstr(e, "\"");
122 
123  while (ptr < end) {
124  switch (*ptr) {
125  case '\n':
126  txtenc_putstr(e, "\\n");
127  break;
128  case '\r':
129  txtenc_putstr(e, "\\r");
130  break;
131  case '\t':
132  txtenc_putstr(e, "\\t");
133  break;
134  case '\"':
135  txtenc_putstr(e, "\\\"");
136  break;
137  case '\'':
138  txtenc_putstr(e, "\\'");
139  break;
140  case '\\':
141  txtenc_putstr(e, "\\\\");
142  break;
143  default:
144  if ((bytes || (uint8_t)*ptr < 0x80) && !isprint(*ptr)) {
145  txtenc_printf(e, "\\%03o", (int)(uint8_t)*ptr);
146  } else {
147  txtenc_putbytes(e, ptr, 1);
148  }
149  break;
150  }
151  ptr++;
152  }
153 
154  txtenc_putstr(e, "\"");
155 }
156 
158  const upb_FieldDef* f) {
159  txtenc_indent(e);
161  const char* name = upb_FieldDef_Name(f);
162 
163  if (type == kUpb_CType_Message) {
164  txtenc_printf(e, "%s {", name);
165  txtenc_endfield(e);
166  e->indent_depth++;
168  e->indent_depth--;
169  txtenc_indent(e);
170  txtenc_putstr(e, "}");
171  txtenc_endfield(e);
172  return;
173  }
174 
175  txtenc_printf(e, "%s: ", name);
176 
177  switch (type) {
178  case kUpb_CType_Bool:
179  txtenc_putstr(e, val.bool_val ? "true" : "false");
180  break;
181  case kUpb_CType_Float: {
182  char buf[32];
184  txtenc_putstr(e, buf);
185  break;
186  }
187  case kUpb_CType_Double: {
188  char buf[32];
190  txtenc_putstr(e, buf);
191  break;
192  }
193  case kUpb_CType_Int32:
194  txtenc_printf(e, "%" PRId32, val.int32_val);
195  break;
196  case kUpb_CType_UInt32:
197  txtenc_printf(e, "%" PRIu32, val.uint32_val);
198  break;
199  case kUpb_CType_Int64:
200  txtenc_printf(e, "%" PRId64, val.int64_val);
201  break;
202  case kUpb_CType_UInt64:
203  txtenc_printf(e, "%" PRIu64, val.uint64_val);
204  break;
205  case kUpb_CType_String:
206  txtenc_string(e, val.str_val, false);
207  break;
208  case kUpb_CType_Bytes:
209  txtenc_string(e, val.str_val, true);
210  break;
211  case kUpb_CType_Enum:
212  txtenc_enum(val.int32_val, f, e);
213  break;
214  default:
215  UPB_UNREACHABLE();
216  }
217 
218  txtenc_endfield(e);
219 }
220 
221 /*
222  * Arrays print as simple repeated elements, eg.
223  *
224  * foo_field: 1
225  * foo_field: 2
226  * foo_field: 3
227  */
228 static void txtenc_array(txtenc* e, const upb_Array* arr,
229  const upb_FieldDef* f) {
230  size_t i;
231  size_t size = upb_Array_Size(arr);
232 
233  for (i = 0; i < size; i++) {
234  txtenc_field(e, upb_Array_Get(arr, i), f);
235  }
236 }
237 
239  upb_MessageValue val, const upb_FieldDef* f) {
241  const upb_FieldDef* key_f = upb_MessageDef_Field(entry, 0);
242  const upb_FieldDef* val_f = upb_MessageDef_Field(entry, 1);
243  txtenc_indent(e);
244  txtenc_printf(e, "%s {", upb_FieldDef_Name(f));
245  txtenc_endfield(e);
246  e->indent_depth++;
247 
248  txtenc_field(e, key, key_f);
249  txtenc_field(e, val, val_f);
250 
251  e->indent_depth--;
252  txtenc_indent(e);
253  txtenc_putstr(e, "}");
254  txtenc_endfield(e);
255 }
256 
257 /*
258  * Maps print as messages of key/value, etc.
259  *
260  * foo_map: {
261  * key: "abc"
262  * value: 123
263  * }
264  * foo_map: {
265  * key: "def"
266  * value: 456
267  * }
268  */
269 static void txtenc_map(txtenc* e, const upb_Map* map, const upb_FieldDef* f) {
270  if (e->options & UPB_TXTENC_NOSORT) {
271  size_t iter = kUpb_Map_Begin;
272  while (upb_MapIterator_Next(map, &iter)) {
275  txtenc_mapentry(e, key, val, f);
276  }
277  } else {
279  const upb_FieldDef* key_f = upb_MessageDef_Field(entry, 0);
280  _upb_sortedmap sorted;
281  upb_MapEntry ent;
282 
283  _upb_mapsorter_pushmap(&e->sorter, upb_FieldDef_Type(key_f), map, &sorted);
284  while (_upb_sortedmap_next(&e->sorter, map, &sorted, &ent)) {
285  upb_MessageValue key, val;
286  memcpy(&key, &ent.k, sizeof(key));
287  memcpy(&val, &ent.v, sizeof(val));
288  txtenc_mapentry(e, key, val, f);
289  }
290  _upb_mapsorter_popmap(&e->sorter, &sorted);
291  }
292 }
293 
294 #define CHK(x) \
295  do { \
296  if (!(x)) { \
297  return false; \
298  } \
299  } while (0)
300 
301 static const char* txtenc_parsevarint(const char* ptr, const char* limit,
302  uint64_t* val) {
303  uint8_t byte;
304  int bitpos = 0;
305  *val = 0;
306 
307  do {
308  CHK(bitpos < 70 && ptr < limit);
309  byte = *ptr;
310  *val |= (uint64_t)(byte & 0x7F) << bitpos;
311  ptr++;
312  bitpos += 7;
313  } while (byte & 0x80);
314 
315  return ptr;
316 }
317 
318 /*
319  * Unknown fields are printed by number.
320  *
321  * 1001: 123
322  * 1002: "hello"
323  * 1006: 0xdeadbeef
324  * 1003: {
325  * 1: 111
326  * }
327  */
328 static const char* txtenc_unknown(txtenc* e, const char* ptr, const char* end,
329  int groupnum) {
330  while (ptr < end) {
331  uint64_t tag_64;
332  uint32_t tag;
333  CHK(ptr = txtenc_parsevarint(ptr, end, &tag_64));
334  CHK(tag_64 < UINT32_MAX);
335  tag = (uint32_t)tag_64;
336 
337  if ((tag & 7) == kUpb_WireType_EndGroup) {
338  CHK((tag >> 3) == (uint32_t)groupnum);
339  return ptr;
340  }
341 
342  txtenc_indent(e);
343  txtenc_printf(e, "%d: ", (int)(tag >> 3));
344 
345  switch (tag & 7) {
346  case kUpb_WireType_Varint: {
347  uint64_t val;
348  CHK(ptr = txtenc_parsevarint(ptr, end, &val));
349  txtenc_printf(e, "%" PRIu64, val);
350  break;
351  }
352  case kUpb_WireType_32Bit: {
353  uint32_t val;
354  CHK(end - ptr >= 4);
355  memcpy(&val, ptr, 4);
356  ptr += 4;
357  txtenc_printf(e, "0x%08" PRIu32, val);
358  break;
359  }
360  case kUpb_WireType_64Bit: {
361  uint64_t val;
362  CHK(end - ptr >= 8);
363  memcpy(&val, ptr, 8);
364  ptr += 8;
365  txtenc_printf(e, "0x%016" PRIu64, val);
366  break;
367  }
369  uint64_t len;
370  size_t avail = end - ptr;
371  char* start = e->ptr;
372  size_t start_overflow = e->overflow;
374  CHK(avail >= len);
375 
376  /* Speculatively try to parse as message. */
377  txtenc_putstr(e, "{");
378  txtenc_endfield(e);
379  e->indent_depth++;
380  if (txtenc_unknown(e, ptr, end, -1)) {
381  e->indent_depth--;
382  txtenc_indent(e);
383  txtenc_putstr(e, "}");
384  } else {
385  /* Didn't work out, print as raw bytes. */
387  e->indent_depth--;
388  e->ptr = start;
389  e->overflow = start_overflow;
390  str.data = ptr;
391  str.size = len;
392  txtenc_string(e, str, true);
393  }
394  ptr += len;
395  break;
396  }
398  txtenc_putstr(e, "{");
399  txtenc_endfield(e);
400  e->indent_depth++;
401  CHK(ptr = txtenc_unknown(e, ptr, end, tag >> 3));
402  e->indent_depth--;
403  txtenc_indent(e);
404  txtenc_putstr(e, "}");
405  break;
406  }
407  txtenc_endfield(e);
408  }
409 
410  return groupnum == -1 ? ptr : NULL;
411 }
412 
413 #undef CHK
414 
415 static void txtenc_msg(txtenc* e, const upb_Message* msg,
416  const upb_MessageDef* m) {
417  size_t iter = kUpb_Message_Begin;
418  const upb_FieldDef* f;
419  upb_MessageValue val;
420 
421  while (upb_Message_Next(msg, m, e->ext_pool, &f, &val, &iter)) {
422  if (upb_FieldDef_IsMap(f)) {
423  txtenc_map(e, val.map_val, f);
424  } else if (upb_FieldDef_IsRepeated(f)) {
425  txtenc_array(e, val.array_val, f);
426  } else {
427  txtenc_field(e, val, f);
428  }
429  }
430 
431  if ((e->options & UPB_TXTENC_SKIPUNKNOWN) == 0) {
432  size_t len;
433  const char* ptr = upb_Message_GetUnknown(msg, &len);
434  char* start = e->ptr;
435  if (ptr) {
436  if (!txtenc_unknown(e, ptr, ptr + len, -1)) {
437  /* Unknown failed to parse, back up and don't print it at all. */
438  e->ptr = start;
439  }
440  }
441  }
442 }
443 
444 size_t txtenc_nullz(txtenc* e, size_t size) {
445  size_t ret = e->ptr - e->buf + e->overflow;
446 
447  if (size > 0) {
448  if (e->ptr == e->end) e->ptr--;
449  *e->ptr = '\0';
450  }
451 
452  return ret;
453 }
454 
456  const upb_DefPool* ext_pool, int options, char* buf,
457  size_t size) {
458  txtenc e;
459 
460  e.buf = buf;
461  e.ptr = buf;
462  e.end = UPB_PTRADD(buf, size);
463  e.overflow = 0;
464  e.indent_depth = 0;
465  e.options = options;
466  e.ext_pool = ext_pool;
467  _upb_mapsorter_init(&e.sorter);
468 
469  txtenc_msg(&e, msg, m);
470  _upb_mapsorter_destroy(&e.sorter);
471  return txtenc_nullz(&e, size);
472 }
xds_interop_client.str
str
Definition: xds_interop_client.py:487
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
UPB_TXTENC_NOSORT
@ UPB_TXTENC_NOSORT
Definition: text_encode.h:45
upb_FieldDef_Type
upb_FieldType upb_FieldDef_Type(const upb_FieldDef *f)
Definition: upb/upb/def.c:535
upb_internal.h
upb_MessageValue::uint32_val
uint32_t uint32_val
Definition: upb/upb/reflection.h:46
kUpb_WireType_Delimited
@ kUpb_WireType_Delimited
Definition: upb/upb/upb.h:277
kUpb_CType_String
@ kUpb_CType_String
Definition: upb/upb/upb.h:296
upb_MapIterator_Key
upb_MessageValue upb_MapIterator_Key(const upb_Map *map, size_t iter)
Definition: reflection.c:461
upb_MessageValue::int64_val
int64_t int64_val
Definition: upb/upb/reflection.h:45
kUpb_CType_UInt32
@ kUpb_CType_UInt32
Definition: upb/upb/upb.h:290
txtenc_unknown
static const char * txtenc_unknown(txtenc *e, const char *ptr, const char *end, int groupnum)
Definition: text_encode.c:328
vsnprintf
int __cdecl vsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
Definition: libc.cpp:135
txtenc::ptr
char * ptr
Definition: text_encode.c:44
upb_CType
upb_CType
Definition: upb/upb/upb.h:286
kUpb_CType_Int32
@ kUpb_CType_Int32
Definition: upb/upb/upb.h:289
txtenc_endfield
static void txtenc_endfield(txtenc *e)
Definition: text_encode.c:99
kUpb_Map_Begin
#define kUpb_Map_Begin
Definition: upb/upb/upb.h:329
upb_EnumValueDef_Name
const char * upb_EnumValueDef_Name(const upb_EnumValueDef *ev)
Definition: upb/upb/def.c:454
upb_MessageDef
Definition: upb/upb/def.c:100
_upb_mapsorter
Definition: php-upb.h:1688
string.h
options
double_dict options[]
Definition: capstone_test.c:55
txtenc_msg
static void txtenc_msg(txtenc *e, const upb_Message *msg, const upb_MessageDef *m)
Definition: text_encode.c:415
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
kUpb_CType_Bytes
@ kUpb_CType_Bytes
Definition: upb/upb/upb.h:297
upb_Message_GetUnknown
const char * upb_Message_GetUnknown(const upb_Message *msg, size_t *len)
Definition: msg.c:101
UPB_UNREACHABLE
#define UPB_UNREACHABLE()
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:145
UINT32_MAX
#define UINT32_MAX
Definition: stdint-msvc2008.h:142
upb_MessageValue::str_val
upb_StringView str_val
Definition: upb/upb/reflection.h:51
setup.name
name
Definition: setup.py:542
txtenc_array
static void txtenc_array(txtenc *e, const upb_Array *arr, const upb_FieldDef *f)
Definition: text_encode.c:228
upb_MessageValue::int32_val
int32_t int32_val
Definition: upb/upb/reflection.h:44
upb_Array_Get
upb_MessageValue upb_Array_Get(const upb_Array *arr, size_t i)
Definition: reflection.c:364
_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
txtenc_field
static void txtenc_field(txtenc *e, upb_MessageValue val, const upb_FieldDef *f)
Definition: text_encode.c:157
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
map
zval * map
Definition: php/ext/google/protobuf/encode_decode.c:480
kUpb_CType_Int64
@ kUpb_CType_Int64
Definition: upb/upb/upb.h:294
txtenc::sorter
_upb_mapsorter sorter
Definition: text_encode.c:49
upb_MessageValue::double_val
double double_val
Definition: upb/upb/reflection.h:43
upb_MessageValue::array_val
const upb_Array * array_val
Definition: upb/upb/reflection.h:50
upb_MapEntry::k
union upb_MapEntry::@708 k
upb_MessageValue::bool_val
bool bool_val
Definition: upb/upb/reflection.h:41
upb_EnumDef_FindValueByNumber
const upb_EnumValueDef * upb_EnumDef_FindValueByNumber(const upb_EnumDef *def, int32_t num)
Definition: upb/upb/def.c:417
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
upb_MessageValue
Definition: upb/upb/reflection.h:40
CHK
#define CHK(x)
Definition: text_encode.c:294
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
UPB_PTRADD
#define UPB_PTRADD(ptr, ofs)
Definition: php-upb.c:168
start
static uint64_t start
Definition: benchmark-pound.c:74
kUpb_WireType_EndGroup
@ kUpb_WireType_EndGroup
Definition: upb/upb/upb.h:279
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
txtenc_printf
static void txtenc_printf(txtenc *e, const char *fmt,...)
Definition: text_encode.c:73
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
txtenc_nullz
size_t txtenc_nullz(txtenc *e, size_t size)
Definition: text_encode.c:444
kUpb_Message_Begin
#define kUpb_Message_Begin
Definition: upb/upb/reflection.h:113
upb_FieldDef_IsMap
bool upb_FieldDef_IsMap(const upb_FieldDef *f)
Definition: upb/upb/def.c:659
kUpb_CType_Double
@ kUpb_CType_Double
Definition: upb/upb/upb.h:293
upb_MapIterator_Next
bool upb_MapIterator_Next(const upb_Map *map, size_t *iter)
Definition: reflection.c:448
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
upb_Array
Definition: msg_internal.h:424
google::protobuf::isprint
bool isprint(char c)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:79
upb_MessageValue::uint64_val
uint64_t uint64_val
Definition: upb/upb/reflection.h:47
upb_EnumValueDef
Definition: upb/upb/def.c:150
kUpb_WireType_Varint
@ kUpb_WireType_Varint
Definition: upb/upb/upb.h:275
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
upb_MapEntry::v
union upb_MapEntry::@709 v
txtenc_putstr
static void txtenc_putstr(txtenc *e, const char *str)
Definition: text_encode.c:69
reflection.h
upb_Message_Next
bool upb_Message_Next(const upb_Message *msg, const upb_MessageDef *m, const upb_DefPool *ext_pool, const upb_FieldDef **out_f, upb_MessageValue *out_val, size_t *iter)
Definition: reflection.c:245
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
upb_MessageValue::msg_val
const upb_Message * msg_val
Definition: upb/upb/reflection.h:49
upb_FieldDef_CType
upb_CType upb_FieldDef_CType(const upb_FieldDef *f)
Definition: upb/upb/def.c:500
_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_mapsorter_popmap
UPB_INLINE void _upb_mapsorter_popmap(_upb_mapsorter *s, _upb_sortedmap *sorted)
Definition: php-upb.h:1713
upb_MapEntry
Definition: msg_internal.h:593
upb_Message
void upb_Message
Definition: msg.h:49
upb_FieldDef_MessageSubDef
const upb_MessageDef * upb_FieldDef_MessageSubDef(const upb_FieldDef *f)
Definition: upb/upb/def.c:619
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
_upb_mapsorter_destroy
UPB_INLINE void _upb_mapsorter_destroy(_upb_mapsorter *s)
Definition: php-upb.h:1706
upb_FieldDef_EnumSubDef
const upb_EnumDef * upb_FieldDef_EnumSubDef(const upb_FieldDef *f)
Definition: upb/upb/def.c:623
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
upb_FieldDef
Definition: upb/upb/def.c:56
upb_MessageValue::map_val
const upb_Map * map_val
Definition: upb/upb/reflection.h:48
upb_Array_Size
size_t upb_Array_Size(const upb_Array *arr)
Definition: reflection.c:362
kUpb_CType_Float
@ kUpb_CType_Float
Definition: upb/upb/upb.h:288
txtenc::options
int options
Definition: text_encode.c:47
txtenc_enum
static void txtenc_enum(int32_t val, const upb_FieldDef *f, txtenc *e)
Definition: text_encode.c:107
txtenc_putbytes
static void txtenc_putbytes(txtenc *e, const void *data, size_t len)
Definition: text_encode.c:55
upb_TextEncode
size_t upb_TextEncode(const upb_Message *msg, const upb_MessageDef *m, const upb_DefPool *ext_pool, int options, char *buf, size_t size)
Definition: text_encode.c:455
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
txtenc_mapentry
static void txtenc_mapentry(txtenc *e, upb_MessageValue key, upb_MessageValue val, const upb_FieldDef *f)
Definition: text_encode.c:238
kUpb_WireType_32Bit
@ kUpb_WireType_32Bit
Definition: upb/upb/upb.h:280
key
const char * key
Definition: hpack_parser_table.cc:164
upb_StringView
Definition: upb/upb/upb.h:72
bytes
uint8 bytes[10]
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:153
_upb_mapsorter_init
UPB_INLINE void _upb_mapsorter_init(_upb_mapsorter *s)
Definition: php-upb.h:1700
UPB_LIKELY
#define UPB_LIKELY(x)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:61
upb_FieldDef_IsRepeated
bool upb_FieldDef_IsRepeated(const upb_FieldDef *f)
Definition: upb/upb/def.c:651
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
txtenc
Definition: text_encode.c:43
upb_MessageValue::float_val
float float_val
Definition: upb/upb/reflection.h:42
UPB_TXTENC_SKIPUNKNOWN
@ UPB_TXTENC_SKIPUNKNOWN
Definition: text_encode.h:42
txtenc::indent_depth
int indent_depth
Definition: text_encode.c:46
_upb_EncodeRoundTripFloat
void _upb_EncodeRoundTripFloat(float val, char *buf, size_t size)
Definition: upb/upb/upb.c:354
kUpb_CType_Bool
@ kUpb_CType_Bool
Definition: upb/upb/upb.h:287
kUpb_CType_Enum
@ kUpb_CType_Enum
Definition: upb/upb/upb.h:291
upb_EnumDef
Definition: upb/upb/def.c:134
upb_Map
Definition: msg_internal.h:581
iter
Definition: test_winkernel.cpp:47
txtenc_parsevarint
static const char * txtenc_parsevarint(const char *ptr, const char *limit, uint64_t *val)
Definition: text_encode.c:301
_upb_sortedmap
Definition: php-upb.h:1694
upb_FieldDef_Name
const char * upb_FieldDef_Name(const upb_FieldDef *f)
Definition: upb/upb/def.c:549
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
txtenc_map
static void txtenc_map(txtenc *e, const upb_Map *map, const upb_FieldDef *f)
Definition: text_encode.c:269
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
kUpb_CType_UInt64
@ kUpb_CType_UInt64
Definition: upb/upb/upb.h:295
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
upb_MessageDef_Field
const upb_FieldDef * upb_MessageDef_Field(const upb_MessageDef *m, int i)
Definition: upb/upb/def.c:828
regress.m
m
Definition: regress/regress.py:25
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
upb_MapIterator_Value
upb_MessageValue upb_MapIterator_Value(const upb_Map *map, size_t iter)
Definition: reflection.c:470
txtenc_string
static void txtenc_string(txtenc *e, upb_StringView str, bool bytes)
Definition: text_encode.c:118
upb_DefPool
Definition: upb/upb/def.c:217
text_encode.h
_upb_EncodeRoundTripDouble
void _upb_EncodeRoundTripDouble(double val, char *buf, size_t size)
Definition: upb/upb/upb.c:344
kUpb_WireType_64Bit
@ kUpb_WireType_64Bit
Definition: upb/upb/upb.h:276
kUpb_CType_Message
@ kUpb_CType_Message
Definition: upb/upb/upb.h:292
kUpb_WireType_StartGroup
@ kUpb_WireType_StartGroup
Definition: upb/upb/upb.h:278
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
txtenc::ext_pool
const upb_DefPool * ext_pool
Definition: text_encode.c:48
UPB_TXTENC_SINGLELINE
@ UPB_TXTENC_SINGLELINE
Definition: text_encode.h:39
txtenc::overflow
size_t overflow
Definition: text_encode.c:45
txtenc_indent
static void txtenc_indent(txtenc *e)
Definition: text_encode.c:90


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:35