upb/upb/bindings/lua/def.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/def.h"
29 
30 #include <float.h>
31 #include <math.h>
32 #include <stdlib.h>
33 #include <string.h>
34 
35 #include "lauxlib.h"
36 #include "upb/bindings/lua/upb.h"
37 #include "upb/reflection.h"
38 
39 #define LUPB_ENUMDEF "lupb.enumdef"
40 #define LUPB_ENUMVALDEF "lupb.enumvaldef"
41 #define LUPB_FIELDDEF "lupb.fielddef"
42 #define LUPB_FILEDEF "lupb.filedef"
43 #define LUPB_MSGDEF "lupb.msgdef"
44 #define LUPB_ONEOFDEF "lupb.oneof"
45 #define LUPB_SYMTAB "lupb.symtab"
46 #define LUPB_OBJCACHE "lupb.objcache"
47 
48 static void lupb_DefPool_pushwrapper(lua_State* L, int narg, const void* def,
49  const char* type);
50 
51 /* lupb_wrapper ***************************************************************/
52 
53 /* Wrappers around upb def objects. The userval contains a reference to the
54  * symtab. */
55 
56 #define LUPB_SYMTAB_INDEX 1
57 
58 typedef struct {
59  const void* def; /* upb_MessageDef, upb_EnumDef, upb_OneofDef, etc. */
60 } lupb_wrapper;
61 
62 static const void* lupb_wrapper_check(lua_State* L, int narg,
63  const char* type) {
64  lupb_wrapper* w = luaL_checkudata(L, narg, type);
65  return w->def;
66 }
67 
68 static void lupb_wrapper_pushsymtab(lua_State* L, int narg) {
70 }
71 
72 /* lupb_wrapper_pushwrapper()
73  *
74  * For a given def wrapper at index |narg|, pushes a wrapper for the given |def|
75  * and the given |type|. The new wrapper will be part of the same symtab. */
76 static void lupb_wrapper_pushwrapper(lua_State* L, int narg, const void* def,
77  const char* type) {
80  lua_replace(L, -2); /* Remove symtab from stack. */
81 }
82 
83 /* lupb_MessageDef_pushsubmsgdef()
84  *
85  * Pops the msgdef wrapper at the top of the stack and replaces it with a msgdef
86  * wrapper for field |f| of this msgdef (submsg may not be direct, for example
87  * it may be the submessage of the map value).
88  */
89 void lupb_MessageDef_pushsubmsgdef(lua_State* L, const upb_FieldDef* f) {
91  assert(m);
93  lua_replace(L, -2); /* Replace msgdef with submsgdef. */
94 }
95 
96 /* lupb_FieldDef **************************************************************/
97 
98 const upb_FieldDef* lupb_FieldDef_check(lua_State* L, int narg) {
99  return lupb_wrapper_check(L, narg, LUPB_FIELDDEF);
100 }
101 
102 static int lupb_FieldDef_ContainingOneof(lua_State* L) {
103  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
106  return 1;
107 }
108 
109 static int lupb_FieldDef_ContainingType(lua_State* L) {
110  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
113  return 1;
114 }
115 
116 static int lupb_FieldDef_Default(lua_State* L) {
117  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
119  if (type == kUpb_CType_Message) {
120  return luaL_error(L, "Message fields do not have explicit defaults.");
121  }
123  return 1;
124 }
125 
126 static int lupb_FieldDef_Type(lua_State* L) {
127  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
128  lua_pushnumber(L, upb_FieldDef_Type(f));
129  return 1;
130 }
131 
132 static int lupb_FieldDef_HasSubDef(lua_State* L) {
133  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
134  lua_pushboolean(L, upb_FieldDef_HasSubDef(f));
135  return 1;
136 }
137 
138 static int lupb_FieldDef_Index(lua_State* L) {
139  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
140  lua_pushinteger(L, upb_FieldDef_Index(f));
141  return 1;
142 }
143 
144 static int lupb_FieldDef_IsExtension(lua_State* L) {
145  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
146  lua_pushboolean(L, upb_FieldDef_IsExtension(f));
147  return 1;
148 }
149 
150 static int lupb_FieldDef_Label(lua_State* L) {
151  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
152  lua_pushinteger(L, upb_FieldDef_Label(f));
153  return 1;
154 }
155 
156 static int lupb_FieldDef_Name(lua_State* L) {
157  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
158  lua_pushstring(L, upb_FieldDef_Name(f));
159  return 1;
160 }
161 
162 static int lupb_FieldDef_Number(lua_State* L) {
163  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
165  if (num) {
166  lua_pushinteger(L, num);
167  } else {
168  lua_pushnil(L);
169  }
170  return 1;
171 }
172 
173 static int lupb_FieldDef_IsPacked(lua_State* L) {
174  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
175  lua_pushboolean(L, upb_FieldDef_IsPacked(f));
176  return 1;
177 }
178 
179 static int lupb_FieldDef_MessageSubDef(lua_State* L) {
180  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
183  return 1;
184 }
185 
186 static int lupb_FieldDef_EnumSubDef(lua_State* L) {
187  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
190  return 1;
191 }
192 
193 static int lupb_FieldDef_CType(lua_State* L) {
194  const upb_FieldDef* f = lupb_FieldDef_check(L, 1);
195  lua_pushinteger(L, upb_FieldDef_CType(f));
196  return 1;
197 }
198 
199 static const struct luaL_Reg lupb_FieldDef_m[] = {
200  {"containing_oneof", lupb_FieldDef_ContainingOneof},
201  {"containing_type", lupb_FieldDef_ContainingType},
202  {"default", lupb_FieldDef_Default},
203  {"descriptor_type", lupb_FieldDef_Type},
204  {"has_subdef", lupb_FieldDef_HasSubDef},
205  {"index", lupb_FieldDef_Index},
206  {"is_extension", lupb_FieldDef_IsExtension},
207  {"label", lupb_FieldDef_Label},
208  {"name", lupb_FieldDef_Name},
209  {"number", lupb_FieldDef_Number},
210  {"packed", lupb_FieldDef_IsPacked},
211  {"msgsubdef", lupb_FieldDef_MessageSubDef},
212  {"enumsubdef", lupb_FieldDef_EnumSubDef},
213  {"type", lupb_FieldDef_CType},
214  {NULL, NULL}};
215 
216 /* lupb_OneofDef **************************************************************/
217 
218 const upb_OneofDef* lupb_OneofDef_check(lua_State* L, int narg) {
219  return lupb_wrapper_check(L, narg, LUPB_ONEOFDEF);
220 }
221 
222 static int lupb_OneofDef_ContainingType(lua_State* L) {
223  const upb_OneofDef* o = lupb_OneofDef_check(L, 1);
226  return 1;
227 }
228 
229 static int lupb_OneofDef_Field(lua_State* L) {
230  const upb_OneofDef* o = lupb_OneofDef_check(L, 1);
233 
234  if (idx < 0 || idx >= count) {
235  const char* msg =
236  lua_pushfstring(L, "index %d exceeds field count %d", idx, count);
237  return luaL_argerror(L, 2, msg);
238  }
239 
241  return 1;
242 }
243 
244 static int lupb_oneofiter_next(lua_State* L) {
245  const upb_OneofDef* o = lupb_OneofDef_check(L, lua_upvalueindex(1));
246  int* index = lua_touserdata(L, lua_upvalueindex(2));
247  const upb_FieldDef* f;
248  if (*index == upb_OneofDef_FieldCount(o)) return 0;
249  f = upb_OneofDef_Field(o, (*index)++);
250  lupb_wrapper_pushwrapper(L, lua_upvalueindex(1), f, LUPB_FIELDDEF);
251  return 1;
252 }
253 
254 static int lupb_OneofDef_Fields(lua_State* L) {
255  int* index = lua_newuserdata(L, sizeof(int));
257  *index = 0;
258 
259  /* Closure upvalues are: oneofdef, index. */
260  lua_pushcclosure(L, &lupb_oneofiter_next, 2);
261  return 1;
262 }
263 
264 static int lupb_OneofDef_len(lua_State* L) {
265  const upb_OneofDef* o = lupb_OneofDef_check(L, 1);
266  lua_pushinteger(L, upb_OneofDef_FieldCount(o));
267  return 1;
268 }
269 
270 /* lupb_OneofDef_lookupfield()
271  *
272  * Handles:
273  * oneof.lookup_field(field_number)
274  * oneof.lookup_field(field_name)
275  */
276 static int lupb_OneofDef_lookupfield(lua_State* L) {
277  const upb_OneofDef* o = lupb_OneofDef_check(L, 1);
278  const upb_FieldDef* f;
279 
280  switch (lua_type(L, 2)) {
281  case LUA_TNUMBER:
282  f = upb_OneofDef_LookupNumber(o, lua_tointeger(L, 2));
283  break;
284  case LUA_TSTRING:
285  f = upb_OneofDef_LookupName(o, lua_tostring(L, 2));
286  break;
287  default: {
288  const char* msg = lua_pushfstring(L, "number or string expected, got %s",
289  luaL_typename(L, 2));
290  return luaL_argerror(L, 2, msg);
291  }
292  }
293 
295  return 1;
296 }
297 
298 static int lupb_OneofDef_Name(lua_State* L) {
299  const upb_OneofDef* o = lupb_OneofDef_check(L, 1);
300  lua_pushstring(L, upb_OneofDef_Name(o));
301  return 1;
302 }
303 
304 static const struct luaL_Reg lupb_OneofDef_m[] = {
305  {"containing_type", lupb_OneofDef_ContainingType},
306  {"field", lupb_OneofDef_Field},
307  {"fields", lupb_OneofDef_Fields},
308  {"lookup_field", lupb_OneofDef_lookupfield},
309  {"name", lupb_OneofDef_Name},
310  {NULL, NULL}};
311 
312 static const struct luaL_Reg lupb_OneofDef_mm[] = {{"__len", lupb_OneofDef_len},
313  {NULL, NULL}};
314 
315 /* lupb_MessageDef
316  * ****************************************************************/
317 
318 typedef struct {
321 
322 const upb_MessageDef* lupb_MessageDef_check(lua_State* L, int narg) {
323  return lupb_wrapper_check(L, narg, LUPB_MSGDEF);
324 }
325 
326 static int lupb_MessageDef_FieldCount(lua_State* L) {
328  lua_pushinteger(L, upb_MessageDef_FieldCount(m));
329  return 1;
330 }
331 
332 static int lupb_MessageDef_OneofCount(lua_State* L) {
334  lua_pushinteger(L, upb_MessageDef_OneofCount(m));
335  return 1;
336 }
337 
338 static bool lupb_MessageDef_pushnested(lua_State* L, int msgdef, int name) {
342  lua_pop(L, 1);
343 
344  /* Construct full package.Message.SubMessage name. */
345  lua_pushstring(L, upb_MessageDef_FullName(m));
346  lua_pushstring(L, ".");
347  lua_pushvalue(L, name);
348  lua_concat(L, 3);
349  const char* nested_name = lua_tostring(L, -1);
350 
351  /* Try lookup. */
352  const upb_MessageDef* nested =
354  if (!nested) return false;
356  return true;
357 }
358 
359 /* lupb_MessageDef_Field()
360  *
361  * Handles:
362  * msg.field(field_number) -> fielddef
363  * msg.field(field_name) -> fielddef
364  */
365 static int lupb_MessageDef_Field(lua_State* L) {
367  const upb_FieldDef* f;
368 
369  switch (lua_type(L, 2)) {
370  case LUA_TNUMBER:
371  f = upb_MessageDef_FindFieldByNumber(m, lua_tointeger(L, 2));
372  break;
373  case LUA_TSTRING:
374  f = upb_MessageDef_FindFieldByName(m, lua_tostring(L, 2));
375  break;
376  default: {
377  const char* msg = lua_pushfstring(L, "number or string expected, got %s",
378  luaL_typename(L, 2));
379  return luaL_argerror(L, 2, msg);
380  }
381  }
382 
384  return 1;
385 }
386 
387 /* lupb_MessageDef_FindByNameWithSize()
388  *
389  * Handles:
390  * msg.lookup_name(name) -> fielddef or oneofdef
391  */
392 static int lupb_MessageDef_FindByNameWithSize(lua_State* L) {
394  const upb_FieldDef* f;
395  const upb_OneofDef* o;
396 
397  if (!upb_MessageDef_FindByName(m, lua_tostring(L, 2), &f, &o)) {
398  lua_pushnil(L);
399  } else if (o) {
401  } else {
403  }
404 
405  return 1;
406 }
407 
408 /* lupb_MessageDef_Name()
409  *
410  * Handles:
411  * msg.name() -> string
412  */
413 static int lupb_MessageDef_Name(lua_State* L) {
415  lua_pushstring(L, upb_MessageDef_Name(m));
416  return 1;
417 }
418 
419 static int lupb_msgfielditer_next(lua_State* L) {
420  const upb_MessageDef* m = lupb_MessageDef_check(L, lua_upvalueindex(1));
421  int* index = lua_touserdata(L, lua_upvalueindex(2));
422  const upb_FieldDef* f;
423  if (*index == upb_MessageDef_FieldCount(m)) return 0;
424  f = upb_MessageDef_Field(m, (*index)++);
425  lupb_wrapper_pushwrapper(L, lua_upvalueindex(1), f, LUPB_FIELDDEF);
426  return 1;
427 }
428 
429 static int lupb_MessageDef_Fields(lua_State* L) {
430  int* index = lua_newuserdata(L, sizeof(int));
432  *index = 0;
433 
434  /* Closure upvalues are: msgdef, index. */
435  lua_pushcclosure(L, &lupb_msgfielditer_next, 2);
436  return 1;
437 }
438 
439 static int lupb_MessageDef_File(lua_State* L) {
443  return 1;
444 }
445 
446 static int lupb_MessageDef_FullName(lua_State* L) {
448  lua_pushstring(L, upb_MessageDef_FullName(m));
449  return 1;
450 }
451 
452 static int lupb_MessageDef_index(lua_State* L) {
453  if (!lupb_MessageDef_pushnested(L, 1, 2)) {
454  luaL_error(L, "No such nested message");
455  }
456  return 1;
457 }
458 
459 static int lupb_msgoneofiter_next(lua_State* L) {
460  const upb_MessageDef* m = lupb_MessageDef_check(L, lua_upvalueindex(1));
461  int* index = lua_touserdata(L, lua_upvalueindex(2));
462  const upb_OneofDef* o;
463  if (*index == upb_MessageDef_OneofCount(m)) return 0;
464  o = upb_MessageDef_Oneof(m, (*index)++);
465  lupb_wrapper_pushwrapper(L, lua_upvalueindex(1), o, LUPB_ONEOFDEF);
466  return 1;
467 }
468 
469 static int lupb_MessageDef_Oneofs(lua_State* L) {
470  int* index = lua_newuserdata(L, sizeof(int));
472  *index = 0;
473 
474  /* Closure upvalues are: msgdef, index. */
475  lua_pushcclosure(L, &lupb_msgoneofiter_next, 2);
476  return 1;
477 }
478 
479 static int lupb_MessageDef_IsMapEntry(lua_State* L) {
481  lua_pushboolean(L, upb_MessageDef_IsMapEntry(m));
482  return 1;
483 }
484 
485 static int lupb_MessageDef_Syntax(lua_State* L) {
487  lua_pushinteger(L, upb_MessageDef_Syntax(m));
488  return 1;
489 }
490 
491 static int lupb_MessageDef_tostring(lua_State* L) {
493  lua_pushfstring(L, "<upb.MessageDef name=%s, field_count=%d>",
496  return 1;
497 }
498 
499 static const struct luaL_Reg lupb_MessageDef_mm[] = {
500  {"__call", lupb_MessageDef_call},
501  {"__index", lupb_MessageDef_index},
502  {"__len", lupb_MessageDef_FieldCount},
503  {"__tostring", lupb_MessageDef_tostring},
504  {NULL, NULL}};
505 
506 static const struct luaL_Reg lupb_MessageDef_m[] = {
507  {"field", lupb_MessageDef_Field},
508  {"fields", lupb_MessageDef_Fields},
509  {"field_count", lupb_MessageDef_FieldCount},
510  {"file", lupb_MessageDef_File},
511  {"full_name", lupb_MessageDef_FullName},
512  {"lookup_name", lupb_MessageDef_FindByNameWithSize},
513  {"name", lupb_MessageDef_Name},
514  {"oneof_count", lupb_MessageDef_OneofCount},
515  {"oneofs", lupb_MessageDef_Oneofs},
516  {"syntax", lupb_MessageDef_Syntax},
517  {"_map_entry", lupb_MessageDef_IsMapEntry},
518  {NULL, NULL}};
519 
520 /* lupb_EnumDef ***************************************************************/
521 
522 const upb_EnumDef* lupb_EnumDef_check(lua_State* L, int narg) {
523  return lupb_wrapper_check(L, narg, LUPB_ENUMDEF);
524 }
525 
526 static int lupb_EnumDef_len(lua_State* L) {
527  const upb_EnumDef* e = lupb_EnumDef_check(L, 1);
528  lua_pushinteger(L, upb_EnumDef_ValueCount(e));
529  return 1;
530 }
531 
532 static int lupb_EnumDef_File(lua_State* L) {
533  const upb_EnumDef* e = lupb_EnumDef_check(L, 1);
534  const upb_FileDef* file = upb_EnumDef_File(e);
536  return 1;
537 }
538 
539 /* lupb_EnumDef_Value()
540  *
541  * Handles:
542  * enum.value(number) -> enumval
543  * enum.value(name) -> enumval
544  */
545 static int lupb_EnumDef_Value(lua_State* L) {
546  const upb_EnumDef* e = lupb_EnumDef_check(L, 1);
547  const upb_EnumValueDef* ev;
548 
549  switch (lua_type(L, 2)) {
550  case LUA_TNUMBER:
552  break;
553  case LUA_TSTRING:
554  ev = upb_EnumDef_FindValueByName(e, lua_tostring(L, 2));
555  break;
556  default: {
557  const char* msg = lua_pushfstring(L, "number or string expected, got %s",
558  luaL_typename(L, 2));
559  return luaL_argerror(L, 2, msg);
560  }
561  }
562 
564  return 1;
565 }
566 
567 static const struct luaL_Reg lupb_EnumDef_mm[] = {{"__len", lupb_EnumDef_len},
568  {NULL, NULL}};
569 
570 static const struct luaL_Reg lupb_EnumDef_m[] = {
571  {"file", lupb_EnumDef_File}, {"value", lupb_EnumDef_Value}, {NULL, NULL}};
572 
573 /* lupb_EnumValueDef
574  * ************************************************************/
575 
576 const upb_EnumValueDef* lupb_enumvaldef_check(lua_State* L, int narg) {
577  return lupb_wrapper_check(L, narg, LUPB_ENUMVALDEF);
578 }
579 
580 static int lupb_EnumValueDef_Enum(lua_State* L) {
581  const upb_EnumValueDef* ev = lupb_enumvaldef_check(L, 1);
582  const upb_EnumDef* e = upb_EnumValueDef_Enum(ev);
584  return 1;
585 }
586 
587 static int lupb_EnumValueDef_FullName(lua_State* L) {
588  const upb_EnumValueDef* ev = lupb_enumvaldef_check(L, 1);
589  lua_pushstring(L, upb_EnumValueDef_FullName(ev));
590  return 1;
591 }
592 
593 static int lupb_EnumValueDef_Name(lua_State* L) {
594  const upb_EnumValueDef* ev = lupb_enumvaldef_check(L, 1);
595  lua_pushstring(L, upb_EnumValueDef_Name(ev));
596  return 1;
597 }
598 
599 static int lupb_EnumValueDef_Number(lua_State* L) {
600  const upb_EnumValueDef* ev = lupb_enumvaldef_check(L, 1);
602  return 1;
603 }
604 
605 static const struct luaL_Reg lupb_enumvaldef_m[] = {
606  {"enum", lupb_EnumValueDef_Enum},
607  {"full_name", lupb_EnumValueDef_FullName},
608  {"name", lupb_EnumValueDef_Name},
609  {"number", lupb_EnumValueDef_Number},
610  {NULL, NULL}};
611 
612 /* lupb_FileDef ***************************************************************/
613 
614 const upb_FileDef* lupb_FileDef_check(lua_State* L, int narg) {
615  return lupb_wrapper_check(L, narg, LUPB_FILEDEF);
616 }
617 
618 static int lupb_FileDef_Dependency(lua_State* L) {
619  const upb_FileDef* f = lupb_FileDef_check(L, 1);
620  int index = luaL_checkint(L, 2);
623  return 1;
624 }
625 
626 static int lupb_FileDef_DependencyCount(lua_State* L) {
627  const upb_FileDef* f = lupb_FileDef_check(L, 1);
628  lua_pushnumber(L, upb_FileDef_DependencyCount(f));
629  return 1;
630 }
631 
632 static int lupb_FileDef_enum(lua_State* L) {
633  const upb_FileDef* f = lupb_FileDef_check(L, 1);
634  int index = luaL_checkint(L, 2);
637  return 1;
638 }
639 
640 static int lupb_FileDef_enumcount(lua_State* L) {
641  const upb_FileDef* f = lupb_FileDef_check(L, 1);
642  lua_pushnumber(L, upb_FileDef_TopLevelEnumCount(f));
643  return 1;
644 }
645 
646 static int lupb_FileDef_msg(lua_State* L) {
647  const upb_FileDef* f = lupb_FileDef_check(L, 1);
648  int index = luaL_checkint(L, 2);
651  return 1;
652 }
653 
654 static int lupb_FileDef_msgcount(lua_State* L) {
655  const upb_FileDef* f = lupb_FileDef_check(L, 1);
656  lua_pushnumber(L, upb_FileDef_TopLevelMessageCount(f));
657  return 1;
658 }
659 
660 static int lupb_FileDef_Name(lua_State* L) {
661  const upb_FileDef* f = lupb_FileDef_check(L, 1);
662  lua_pushstring(L, upb_FileDef_Name(f));
663  return 1;
664 }
665 
666 static int lupb_FileDef_Package(lua_State* L) {
667  const upb_FileDef* f = lupb_FileDef_check(L, 1);
668  lua_pushstring(L, upb_FileDef_Package(f));
669  return 1;
670 }
671 
672 static int lupb_FileDef_Pool(lua_State* L) {
673  const upb_FileDef* f = lupb_FileDef_check(L, 1);
676  return 1;
677 }
678 
679 static int lupb_FileDef_Syntax(lua_State* L) {
680  const upb_FileDef* f = lupb_FileDef_check(L, 1);
681  lua_pushnumber(L, upb_FileDef_Syntax(f));
682  return 1;
683 }
684 
685 static const struct luaL_Reg lupb_FileDef_m[] = {
686  {"dep", lupb_FileDef_Dependency},
687  {"depcount", lupb_FileDef_DependencyCount},
688  {"enum", lupb_FileDef_enum},
689  {"enumcount", lupb_FileDef_enumcount},
690  {"msg", lupb_FileDef_msg},
691  {"msgcount", lupb_FileDef_msgcount},
692  {"name", lupb_FileDef_Name},
693  {"package", lupb_FileDef_Package},
694  {"symtab", lupb_FileDef_Pool},
695  {"syntax", lupb_FileDef_Syntax},
696  {NULL, NULL}};
697 
698 /* lupb_DefPool
699  * ****************************************************************/
700 
701 /* The symtab owns all defs. Thus GC-rooting the symtab ensures that all
702  * underlying defs stay alive.
703  *
704  * The symtab's userval is a cache of def* -> object. */
705 
706 #define LUPB_CACHE_INDEX 1
707 
708 typedef struct {
710 } lupb_DefPool;
711 
712 upb_DefPool* lupb_DefPool_check(lua_State* L, int narg) {
713  lupb_DefPool* lsymtab = luaL_checkudata(L, narg, LUPB_SYMTAB);
714  if (!lsymtab->symtab) {
715  luaL_error(L, "called into dead object");
716  }
717  return lsymtab->symtab;
718 }
719 
720 void lupb_DefPool_pushwrapper(lua_State* L, int narg, const void* def,
721  const char* type) {
722  narg = lua_absindex(L, narg);
723  assert(luaL_testudata(L, narg, LUPB_SYMTAB));
724 
725  if (def == NULL) {
726  lua_pushnil(L);
727  return;
728  }
729 
730  lua_getiuservalue(L, narg, LUPB_CACHE_INDEX); /* Get cache. */
731 
732  /* Index by "def" pointer. */
733  lua_rawgetp(L, -1, def);
734 
735  /* Stack is now: cache, cached value. */
736  if (lua_isnil(L, -1)) {
737  /* Create new wrapper. */
738  lupb_wrapper* w = lupb_newuserdata(L, sizeof(*w), 1, type);
739  w->def = def;
740  lua_replace(L, -2); /* Replace nil */
741 
742  /* Set symtab as userval. */
743  lua_pushvalue(L, narg);
745 
746  /* Add wrapper to the the cache. */
747  lua_pushvalue(L, -1);
748  lua_rawsetp(L, -3, def);
749  }
750 
751  lua_replace(L, -2); /* Remove cache, leaving only the wrapper. */
752 }
753 
754 /* upb_DefPool_New()
755  *
756  * Handles:
757  * upb.SymbolTable() -> <new instance>
758  */
759 static int lupb_DefPool_New(lua_State* L) {
760  lupb_DefPool* lsymtab = lupb_newuserdata(L, sizeof(*lsymtab), 1, LUPB_SYMTAB);
761  lsymtab->symtab = upb_DefPool_New();
762 
763  /* Create our object cache. */
764  lua_newtable(L);
765 
766  /* Cache metatable: specifies that values are weak. */
767  lua_createtable(L, 0, 1);
768  lua_pushstring(L, "v");
769  lua_setfield(L, -2, "__mode");
770  lua_setmetatable(L, -2);
771 
772  /* Put the symtab itself in the cache metatable. */
773  lua_pushvalue(L, -2);
774  lua_rawsetp(L, -2, lsymtab->symtab);
775 
776  /* Set the cache as our userval. */
778 
779  return 1;
780 }
781 
782 static int lupb_DefPool_gc(lua_State* L) {
783  lupb_DefPool* lsymtab = luaL_checkudata(L, 1, LUPB_SYMTAB);
784  upb_DefPool_Free(lsymtab->symtab);
785  lsymtab->symtab = NULL;
786  return 0;
787 }
788 
789 static int lupb_DefPool_AddFile(lua_State* L) {
790  size_t len;
792  const char* str = luaL_checklstring(L, 2, &len);
795  const upb_FileDef* file_def;
797 
800 
801  if (!file) {
802  luaL_argerror(L, 2, "failed to parse descriptor");
803  }
804 
805  file_def = upb_DefPool_AddFile(s, file, &status);
807 
808  lupb_DefPool_pushwrapper(L, 1, file_def, LUPB_FILEDEF);
809 
810  return 1;
811 }
812 
813 static int lupb_DefPool_addset(lua_State* L) {
814  size_t i, n, len;
818  const char* str = luaL_checklstring(L, 2, &len);
821 
824 
825  if (!set) {
826  luaL_argerror(L, 2, "failed to parse descriptor");
827  }
828 
830  for (i = 0; i < n; i++) {
833  }
834 
835  return 0;
836 }
837 
838 static int lupb_DefPool_FindMessageByName(lua_State* L) {
839  const upb_DefPool* s = lupb_DefPool_check(L, 1);
840  const upb_MessageDef* m =
841  upb_DefPool_FindMessageByName(s, luaL_checkstring(L, 2));
843  return 1;
844 }
845 
846 static int lupb_DefPool_FindEnumByName(lua_State* L) {
847  const upb_DefPool* s = lupb_DefPool_check(L, 1);
848  const upb_EnumDef* e = upb_DefPool_FindEnumByName(s, luaL_checkstring(L, 2));
850  return 1;
851 }
852 
853 static int lupb_DefPool_FindEnumByNameval(lua_State* L) {
854  const upb_DefPool* s = lupb_DefPool_check(L, 1);
855  const upb_EnumValueDef* e =
856  upb_DefPool_FindEnumByNameval(s, luaL_checkstring(L, 2));
858  return 1;
859 }
860 
861 static int lupb_DefPool_tostring(lua_State* L) {
862  lua_pushfstring(L, "<upb.SymbolTable>");
863  return 1;
864 }
865 
866 static const struct luaL_Reg lupb_DefPool_m[] = {
867  {"add_file", lupb_DefPool_AddFile},
868  {"add_set", lupb_DefPool_addset},
869  {"lookup_msg", lupb_DefPool_FindMessageByName},
870  {"lookup_enum", lupb_DefPool_FindEnumByName},
871  {"lookup_enumval", lupb_DefPool_FindEnumByNameval},
872  {NULL, NULL}};
873 
874 static const struct luaL_Reg lupb_DefPool_mm[] = {
875  {"__gc", lupb_DefPool_gc},
876  {"__tostring", lupb_DefPool_tostring},
877  {NULL, NULL}};
878 
879 /* lupb toplevel **************************************************************/
880 
881 static void lupb_setfieldi(lua_State* L, const char* field, int i) {
882  lua_pushinteger(L, i);
883  lua_setfield(L, -2, field);
884 }
885 
886 static const struct luaL_Reg lupbdef_toplevel_m[] = {
887  {"SymbolTable", lupb_DefPool_New}, {NULL, NULL}};
888 
889 void lupb_def_registertypes(lua_State* L) {
890  lupb_setfuncs(L, lupbdef_toplevel_m);
891 
892  /* Register types. */
900 
901  /* Register constants. */
902  lupb_setfieldi(L, "LABEL_OPTIONAL", kUpb_Label_Optional);
903  lupb_setfieldi(L, "LABEL_REQUIRED", kUpb_Label_Required);
904  lupb_setfieldi(L, "LABEL_REPEATED", kUpb_Label_Repeated);
905 
906  lupb_setfieldi(L, "TYPE_DOUBLE", kUpb_CType_Double);
907  lupb_setfieldi(L, "TYPE_FLOAT", kUpb_CType_Float);
908  lupb_setfieldi(L, "TYPE_INT64", kUpb_CType_Int64);
909  lupb_setfieldi(L, "TYPE_UINT64", kUpb_CType_UInt64);
910  lupb_setfieldi(L, "TYPE_INT32", kUpb_CType_Int32);
911  lupb_setfieldi(L, "TYPE_BOOL", kUpb_CType_Bool);
912  lupb_setfieldi(L, "TYPE_STRING", kUpb_CType_String);
913  lupb_setfieldi(L, "TYPE_MESSAGE", kUpb_CType_Message);
914  lupb_setfieldi(L, "TYPE_BYTES", kUpb_CType_Bytes);
915  lupb_setfieldi(L, "TYPE_UINT32", kUpb_CType_UInt32);
916  lupb_setfieldi(L, "TYPE_ENUM", kUpb_CType_Enum);
917 
918  lupb_setfieldi(L, "DESCRIPTOR_TYPE_DOUBLE", kUpb_FieldType_Double);
919  lupb_setfieldi(L, "DESCRIPTOR_TYPE_FLOAT", kUpb_FieldType_Float);
920  lupb_setfieldi(L, "DESCRIPTOR_TYPE_INT64", kUpb_FieldType_Int64);
921  lupb_setfieldi(L, "DESCRIPTOR_TYPE_UINT64", kUpb_FieldType_UInt64);
922  lupb_setfieldi(L, "DESCRIPTOR_TYPE_INT32", kUpb_FieldType_Int32);
923  lupb_setfieldi(L, "DESCRIPTOR_TYPE_FIXED64", kUpb_FieldType_Fixed64);
924  lupb_setfieldi(L, "DESCRIPTOR_TYPE_FIXED32", kUpb_FieldType_Fixed32);
925  lupb_setfieldi(L, "DESCRIPTOR_TYPE_BOOL", kUpb_FieldType_Bool);
926  lupb_setfieldi(L, "DESCRIPTOR_TYPE_STRING", kUpb_FieldType_String);
927  lupb_setfieldi(L, "DESCRIPTOR_TYPE_GROUP", kUpb_FieldType_Group);
928  lupb_setfieldi(L, "DESCRIPTOR_TYPE_MESSAGE", kUpb_FieldType_Message);
929  lupb_setfieldi(L, "DESCRIPTOR_TYPE_BYTES", kUpb_FieldType_Bytes);
930  lupb_setfieldi(L, "DESCRIPTOR_TYPE_UINT32", kUpb_FieldType_UInt32);
931  lupb_setfieldi(L, "DESCRIPTOR_TYPE_ENUM", kUpb_FieldType_Enum);
932  lupb_setfieldi(L, "DESCRIPTOR_TYPE_SFIXED32", kUpb_FieldType_SFixed32);
933  lupb_setfieldi(L, "DESCRIPTOR_TYPE_SFIXED64", kUpb_FieldType_SFixed64);
934  lupb_setfieldi(L, "DESCRIPTOR_TYPE_SINT32", kUpb_FieldType_SInt32);
935  lupb_setfieldi(L, "DESCRIPTOR_TYPE_SINT64", kUpb_FieldType_SInt64);
936 
937  lupb_setfieldi(L, "SYNTAX_PROTO2", kUpb_Syntax_Proto2);
938  lupb_setfieldi(L, "SYNTAX_PROTO3", kUpb_Syntax_Proto3);
939 }
upb_OneofDef_Name
const char * upb_OneofDef_Name(const upb_OneofDef *o)
Definition: upb/upb/def.c:870
xds_interop_client.str
str
Definition: xds_interop_client.py:487
lupb_newuserdata
void * lupb_newuserdata(lua_State *L, size_t size, int n, const char *type)
Definition: upb/upb/bindings/lua/upb.c:80
upb_FieldDef_Type
upb_FieldType upb_FieldDef_Type(const upb_FieldDef *f)
Definition: upb/upb/def.c:535
upb_FieldDef_Number
uint32_t upb_FieldDef_Number(const upb_FieldDef *f)
Definition: upb/upb/def.c:541
lupb_def_registertypes
void lupb_def_registertypes(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:889
kUpb_CType_String
@ kUpb_CType_String
Definition: upb/upb/upb.h:296
upb_FieldDef_IsPacked
bool upb_FieldDef_IsPacked(const upb_FieldDef *f)
Definition: upb/upb/def.c:547
kUpb_FieldType_SInt64
@ kUpb_FieldType_SInt64
Definition: upb/upb/upb.h:326
kUpb_CType_UInt32
@ kUpb_CType_UInt32
Definition: upb/upb/upb.h:290
kUpb_FieldType_SFixed64
@ kUpb_FieldType_SFixed64
Definition: upb/upb/upb.h:324
upb_CType
upb_CType
Definition: upb/upb/upb.h:286
kUpb_CType_Int32
@ kUpb_CType_Int32
Definition: upb/upb/upb.h:289
upb_DefPool_FindEnumByName
const upb_EnumDef * upb_DefPool_FindEnumByName(const upb_DefPool *s, const char *sym)
Definition: upb/upb/def.c:1135
kUpb_FieldType_SInt32
@ kUpb_FieldType_SInt32
Definition: upb/upb/upb.h:325
LUPB_CACHE_INDEX
#define LUPB_CACHE_INDEX
Definition: upb/upb/bindings/lua/def.c:706
lupb_FileDef_Pool
static int lupb_FileDef_Pool(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:672
upb_FieldDef_HasSubDef
bool upb_FieldDef_HasSubDef(const upb_FieldDef *f)
Definition: upb/upb/def.c:666
lupb_MessageDef_Fields
static int lupb_MessageDef_Fields(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:429
lupb_FileDef_Syntax
static int lupb_FileDef_Syntax(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:679
upb_FileDef_Package
const char * upb_FileDef_Package(const upb_FileDef *f)
Definition: upb/upb/def.c:922
file
const grpc_generator::File * file
Definition: python_private_generator.h:38
lupb_FileDef_m
static const struct luaL_Reg lupb_FileDef_m[]
Definition: upb/upb/bindings/lua/def.c:685
lupb_MessageDef_check
const upb_MessageDef * lupb_MessageDef_check(lua_State *L, int narg)
Definition: upb/upb/bindings/lua/def.c:322
lupb_FieldDef_CType
static int lupb_FieldDef_CType(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:193
upb_MessageDef_Syntax
upb_Syntax upb_MessageDef_Syntax(const upb_MessageDef *m)
Definition: upb/upb/def.c:717
kUpb_FieldType_UInt64
@ kUpb_FieldType_UInt64
Definition: upb/upb/upb.h:312
lupb_FieldDef_EnumSubDef
static int lupb_FieldDef_EnumSubDef(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:186
lupb_FileDef_check
const upb_FileDef * lupb_FileDef_check(lua_State *L, int narg)
Definition: upb/upb/bindings/lua/def.c:614
lupb_EnumValueDef_Number
static int lupb_EnumValueDef_Number(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:599
upb_OneofDef_LookupNumber
const upb_FieldDef * upb_OneofDef_LookupNumber(const upb_OneofDef *o, uint32_t num)
Definition: upb/upb/def.c:903
lupb_wrapper_pushwrapper
static void lupb_wrapper_pushwrapper(lua_State *L, int narg, const void *def, const char *type)
Definition: upb/upb/bindings/lua/def.c:76
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
lupb_FileDef_enum
static int lupb_FileDef_enum(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:632
google_protobuf_FileDescriptorSet_parse
UPB_INLINE google_protobuf_FileDescriptorSet * google_protobuf_FileDescriptorSet_parse(const char *buf, size_t size, upb_Arena *arena)
Definition: descriptor.upb.h:169
lupb_checkint32
int32_t lupb_checkint32(lua_State *L, int narg)
lupb_MessageDef_OneofCount
static int lupb_MessageDef_OneofCount(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:332
string.h
upb_MessageDef_FindByName
UPB_INLINE bool upb_MessageDef_FindByName(const upb_MessageDef *m, const char *name, const upb_FieldDef **f, const upb_OneofDef **o)
Definition: upb/upb/def.h:231
lupb_msgfielditer_next
static int lupb_msgfielditer_next(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:419
lupb_DefPool_AddFile
static int lupb_DefPool_AddFile(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:789
upb_FileDef_Dependency
const upb_FileDef * upb_FileDef_Dependency(const upb_FileDef *f, int i)
Definition: upb/upb/def.c:958
upb_DefPool_FindEnumByNameval
const upb_EnumValueDef * upb_DefPool_FindEnumByNameval(const upb_DefPool *s, const char *sym)
Definition: upb/upb/def.c:1140
kUpb_CType_Bytes
@ kUpb_CType_Bytes
Definition: upb/upb/upb.h:297
lupb_enumvaldef_m
static const struct luaL_Reg lupb_enumvaldef_m[]
Definition: upb/upb/bindings/lua/def.c:605
lupb_OneofDef_Field
static int lupb_OneofDef_Field(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:229
lupb_OneofDef_mm
static const struct luaL_Reg lupb_OneofDef_mm[]
Definition: upb/upb/bindings/lua/def.c:312
lupb_FieldDef_Type
static int lupb_FieldDef_Type(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:126
lupb_wrapper_check
static const void * lupb_wrapper_check(lua_State *L, int narg, const char *type)
Definition: upb/upb/bindings/lua/def.c:62
file
Definition: bloaty/third_party/zlib/examples/gzappend.c:170
upb_OneofDef_ContainingType
const upb_MessageDef * upb_OneofDef_ContainingType(const upb_OneofDef *o)
Definition: upb/upb/def.c:874
lupb_OneofDef_Fields
static int lupb_OneofDef_Fields(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:254
status
absl::Status status
Definition: rls.cc:251
kUpb_FieldType_SFixed32
@ kUpb_FieldType_SFixed32
Definition: upb/upb/upb.h:323
setup.name
name
Definition: setup.py:542
upb_OneofDef
Definition: upb/upb/def.c:157
lupb_FieldDef_Index
static int lupb_FieldDef_Index(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:138
lupb_MessageDef_pushnested
static bool lupb_MessageDef_pushnested(lua_State *L, int msgdef, int name)
Definition: upb/upb/bindings/lua/def.c:338
upb_EnumDef_File
const upb_FileDef * upb_EnumDef_File(const upb_EnumDef *e)
Definition: upb/upb/def.c:396
lupb_DefPool_check
upb_DefPool * lupb_DefPool_check(lua_State *L, int narg)
Definition: upb/upb/bindings/lua/def.c:712
lupb_EnumDef_len
static int lupb_EnumDef_len(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:526
kUpb_CType_Int64
@ kUpb_CType_Int64
Definition: upb/upb/upb.h:294
upb_Status_Clear
void upb_Status_Clear(upb_Status *status)
Definition: upb/upb/upb.c:44
google_protobuf_FileDescriptorSet
struct google_protobuf_FileDescriptorSet google_protobuf_FileDescriptorSet
Definition: descriptor.upb.h:50
lupb_DefPool
Definition: upb/upb/bindings/lua/def.c:708
lupb_DefPool_FindEnumByNameval
static int lupb_DefPool_FindEnumByNameval(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:853
lupb_wrapper_pushsymtab
static void lupb_wrapper_pushsymtab(lua_State *L, int narg)
Definition: upb/upb/bindings/lua/def.c:68
upb_FileDef_Syntax
upb_Syntax upb_FileDef_Syntax(const upb_FileDef *f)
Definition: upb/upb/def.c:924
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
upb_FileDef_TopLevelEnum
const upb_EnumDef * upb_FileDef_TopLevelEnum(const upb_FileDef *f, int i)
Definition: upb/upb/def.c:978
lupb_MessageDef_Oneofs
static int lupb_MessageDef_Oneofs(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:469
lupb_OneofDef_ContainingType
static int lupb_OneofDef_ContainingType(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:222
kUpb_FieldType_Double
@ kUpb_FieldType_Double
Definition: upb/upb/upb.h:309
kUpb_FieldType_Bool
@ kUpb_FieldType_Bool
Definition: upb/upb/upb.h:316
lupb_MessageDef_Field
static int lupb_MessageDef_Field(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:365
upb_EnumDef_FindValueByNumber
const upb_EnumValueDef * upb_EnumDef_FindValueByNumber(const upb_EnumDef *def, int32_t num)
Definition: upb/upb/def.c:417
o
UnboundConversion o
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:97
lupb_DefPool_addset
static int lupb_DefPool_addset(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:813
upb_FieldDef_Index
uint32_t upb_FieldDef_Index(const upb_FieldDef *f)
Definition: upb/upb/def.c:537
lupb_pushmsgval
void lupb_pushmsgval(lua_State *L, int container, upb_CType type, upb_MessageValue val)
Definition: bindings/lua/msg.c:319
lupb_MessageDef_Syntax
static int lupb_MessageDef_Syntax(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:485
kUpb_FieldType_Float
@ kUpb_FieldType_Float
Definition: upb/upb/upb.h:310
upb_FieldDef_Label
upb_Label upb_FieldDef_Label(const upb_FieldDef *f)
Definition: upb/upb/def.c:539
lua_setiuservalue
int lua_setiuservalue(lua_State *L, int index, int n)
Definition: upb/upb/bindings/lua/upb.c:98
kUpb_FieldType_UInt32
@ kUpb_FieldType_UInt32
Definition: upb/upb/upb.h:321
upb_MessageDef_IsMapEntry
UPB_INLINE bool upb_MessageDef_IsMapEntry(const upb_MessageDef *m)
Definition: upb/upb/def.h:209
lupb_DefPool::symtab
upb_DefPool * symtab
Definition: upb/upb/bindings/lua/def.c:709
upb_MessageDef_Name
const char * upb_MessageDef_Name(const upb_MessageDef *m)
Definition: upb/upb/def.c:713
lupb_DefPool_tostring
static int lupb_DefPool_tostring(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:861
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
upb_OneofDef_LookupName
const UPB_INLINE upb_FieldDef * upb_OneofDef_LookupName(const upb_OneofDef *o, const char *name)
Definition: upb/upb/def.h:150
kUpb_FieldType_String
@ kUpb_FieldType_String
Definition: upb/upb/upb.h:317
kUpb_CType_Double
@ kUpb_CType_Double
Definition: upb/upb/upb.h:293
lupb_FileDef_msg
static int lupb_FileDef_msg(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:646
lupb_FileDef_enumcount
static int lupb_FileDef_enumcount(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:640
lupb_pushint32
void lupb_pushint32(lua_State *L, int32_t val)
lupb_OneofDef_Name
static int lupb_OneofDef_Name(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:298
lua_getiuservalue
int lua_getiuservalue(lua_State *L, int index, int n)
Definition: upb/upb/bindings/lua/upb.c:106
lupb_MessageDef_File
static int lupb_MessageDef_File(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:439
lupb_MessageDef_index
static int lupb_MessageDef_index(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:452
lupb_EnumValueDef_Name
static int lupb_EnumValueDef_Name(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:593
lupb_checkstatus
void lupb_checkstatus(lua_State *L, upb_Status *s)
Definition: upb/upb/bindings/lua/upb.c:72
kUpb_Syntax_Proto2
@ kUpb_Syntax_Proto2
Definition: upb/upb/def.h:65
lupb_FieldDef_HasSubDef
static int lupb_FieldDef_HasSubDef(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:132
lupb_OneofDef_check
const upb_OneofDef * lupb_OneofDef_check(lua_State *L, int narg)
Definition: upb/upb/bindings/lua/def.c:218
kUpb_FieldType_Enum
@ kUpb_FieldType_Enum
Definition: upb/upb/upb.h:322
lupb_register_type
void lupb_register_type(lua_State *L, const char *name, const luaL_Reg *m, const luaL_Reg *mm)
Definition: upb/upb/bindings/lua/upb.c:132
lupb_MessageDef_Name
static int lupb_MessageDef_Name(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:413
lupb_MessageDef_FieldCount
static int lupb_MessageDef_FieldCount(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:326
lupb_FieldDef_Label
static int lupb_FieldDef_Label(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:150
kUpb_FieldType_Fixed32
@ kUpb_FieldType_Fixed32
Definition: upb/upb/upb.h:315
upb_FileDef_TopLevelMessage
const upb_MessageDef * upb_FileDef_TopLevelMessage(const upb_FileDef *f, int i)
Definition: upb/upb/def.c:973
upb_FileDef_Pool
const upb_DefPool * upb_FileDef_Pool(const upb_FileDef *f)
Definition: upb/upb/def.c:993
upb_OneofDef_FieldCount
int upb_OneofDef_FieldCount(const upb_OneofDef *o)
Definition: upb/upb/def.c:878
upb_DefPool_New
upb_DefPool * upb_DefPool_New(void)
Definition: upb/upb/def.c:1086
upb_EnumValueDef
Definition: upb/upb/def.c:150
lupb_DefPool_FindMessageByName
static int lupb_DefPool_FindMessageByName(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:838
lupb_FieldDef_ContainingOneof
static int lupb_FieldDef_ContainingOneof(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:102
def
int def(FILE *source, FILE *dest, int level)
Definition: bloaty/third_party/zlib/examples/zpipe.c:36
lupb_OneofDef_m
static const struct luaL_Reg lupb_OneofDef_m[]
Definition: upb/upb/bindings/lua/def.c:304
upb_FieldDef_Default
upb_MessageValue upb_FieldDef_Default(const upb_FieldDef *f)
Definition: upb/upb/def.c:581
lupb_FieldDef_MessageSubDef
static int lupb_FieldDef_MessageSubDef(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:179
lupb_oneofiter_next
static int lupb_oneofiter_next(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:244
upb_FieldDef_IsExtension
bool upb_FieldDef_IsExtension(const upb_FieldDef *f)
Definition: upb/upb/def.c:543
reflection.h
upb_FileDef_Name
const char * upb_FileDef_Name(const upb_FileDef *f)
Definition: upb/upb/def.c:920
upb_MessageDef_FindFieldByName
const UPB_INLINE upb_FieldDef * upb_MessageDef_FindFieldByName(const upb_MessageDef *m, const char *name)
Definition: upb/upb/def.h:204
lupb_EnumDef_File
static int lupb_EnumDef_File(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:532
LUPB_FIELDDEF
#define LUPB_FIELDDEF
Definition: upb/upb/bindings/lua/def.c:41
upb_Status
Definition: upb/upb/upb.h:52
lupb_wrapper
Definition: upb/upb/bindings/lua/def.c:58
upb.h
google_protobuf_FileDescriptorSet_file
const UPB_INLINE google_protobuf_FileDescriptorProto *const * google_protobuf_FileDescriptorSet_file(const google_protobuf_FileDescriptorSet *msg, size_t *len)
Definition: descriptor.upb.h:201
lupb_setfieldi
static void lupb_setfieldi(lua_State *L, const char *field, int i)
Definition: upb/upb/bindings/lua/def.c:881
LUPB_ENUMDEF
#define LUPB_ENUMDEF
Definition: upb/upb/bindings/lua/def.c:39
upb_FieldDef_CType
upb_CType upb_FieldDef_CType(const upb_FieldDef *f)
Definition: upb/upb/def.c:500
LUPB_SYMTAB_INDEX
#define LUPB_SYMTAB_INDEX
Definition: upb/upb/bindings/lua/def.c:56
upb_EnumDef_ValueCount
int upb_EnumDef_ValueCount(const upb_EnumDef *e)
Definition: upb/upb/def.c:407
lupb_FieldDef_IsPacked
static int lupb_FieldDef_IsPacked(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:173
upb_FileDef_TopLevelEnumCount
int upb_FileDef_TopLevelEnumCount(const upb_FileDef *f)
Definition: upb/upb/def.c:948
kUpb_Label_Required
@ kUpb_Label_Required
Definition: upb/upb/upb.h:303
upb_MessageDef_Oneof
const upb_OneofDef * upb_MessageDef_Oneof(const upb_MessageDef *m, int i)
Definition: upb/upb/def.c:833
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_FieldDef_EnumSubDef
const upb_EnumDef * upb_FieldDef_EnumSubDef(const upb_FieldDef *f)
Definition: upb/upb/def.c:623
setup.idx
idx
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:197
lupb_DefPool_New
static int lupb_DefPool_New(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:759
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
lupb_FileDef_Name
static int lupb_FileDef_Name(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:660
upb_FieldDef
Definition: upb/upb/def.c:56
lupb_EnumDef_m
static const struct luaL_Reg lupb_EnumDef_m[]
Definition: upb/upb/bindings/lua/def.c:570
nested
static int nested
Definition: test-callback-stack.c:39
lupb_FieldDef_Number
static int lupb_FieldDef_Number(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:162
kUpb_CType_Float
@ kUpb_CType_Float
Definition: upb/upb/upb.h:288
upb_EnumValueDef_FullName
const char * upb_EnumValueDef_FullName(const upb_EnumValueDef *ev)
Definition: upb/upb/def.c:450
kUpb_FieldType_Fixed64
@ kUpb_FieldType_Fixed64
Definition: upb/upb/upb.h:314
symtab
upb_symtab * symtab
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:774
lupb_EnumDef_Value
static int lupb_EnumDef_Value(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:545
lupb_FieldDef_IsExtension
static int lupb_FieldDef_IsExtension(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:144
lupb_DefPool_mm
static const struct luaL_Reg lupb_DefPool_mm[]
Definition: upb/upb/bindings/lua/def.c:874
lupb_DefPool_FindEnumByName
static int lupb_DefPool_FindEnumByName(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:846
lupb_FileDef_Package
static int lupb_FileDef_Package(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:666
lupb_OneofDef_lookupfield
static int lupb_OneofDef_lookupfield(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:276
upb_FieldDef_ContainingType
const upb_MessageDef * upb_FieldDef_ContainingType(const upb_FieldDef *f)
Definition: upb/upb/def.c:563
lupb_MessageDef_FullName
static int lupb_MessageDef_FullName(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:446
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
LUPB_MSGDEF
#define LUPB_MSGDEF
Definition: upb/upb/bindings/lua/def.c:43
lupb_MessageDef_IsMapEntry
static int lupb_MessageDef_IsMapEntry(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:479
upb_DefPool_Free
void upb_DefPool_Free(upb_DefPool *s)
Definition: upb/upb/def.c:1081
kUpb_Label_Repeated
@ kUpb_Label_Repeated
Definition: upb/upb/upb.h:304
upb_FileDef
Definition: upb/upb/def.c:171
lupb_FieldDef_m
static const struct luaL_Reg lupb_FieldDef_m[]
Definition: upb/upb/bindings/lua/def.c:199
LUPB_SYMTAB
#define LUPB_SYMTAB
Definition: upb/upb/bindings/lua/def.c:45
lupb_FieldDef_check
const upb_FieldDef * lupb_FieldDef_check(lua_State *L, int narg)
Definition: upb/upb/bindings/lua/def.c:98
def.h
upb_OneofDef_Field
const upb_FieldDef * upb_OneofDef_Field(const upb_OneofDef *o, int i)
Definition: upb/upb/def.c:880
lupb_MessageDef_FindByNameWithSize
static int lupb_MessageDef_FindByNameWithSize(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:392
count
int * count
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:96
lupb_FieldDef_ContainingType
static int lupb_FieldDef_ContainingType(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:109
lupb_EnumValueDef_Enum
static int lupb_EnumValueDef_Enum(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:580
lupb_OneofDef_len
static int lupb_OneofDef_len(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:264
lupb_FileDef_Dependency
static int lupb_FileDef_Dependency(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:618
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
lupb_wrapper::def
const void * def
Definition: upb/upb/bindings/lua/def.c:59
lupb_MessageDef::md
const upb_MessageDef * md
Definition: upb/upb/bindings/lua/def.c:319
google_protobuf_FileDescriptorProto_parse
UPB_INLINE google_protobuf_FileDescriptorProto * google_protobuf_FileDescriptorProto_parse(const char *buf, size_t size, upb_Arena *arena)
Definition: descriptor.upb.h:223
kUpb_FieldType_Group
@ kUpb_FieldType_Group
Definition: upb/upb/upb.h:318
lupb_Arena_pushnew
upb_Arena * lupb_Arena_pushnew(lua_State *L)
Definition: bindings/lua/msg.c:202
lupb_EnumValueDef_FullName
static int lupb_EnumValueDef_FullName(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:587
upb_MessageDef_OneofCount
int upb_MessageDef_OneofCount(const upb_MessageDef *m)
Definition: upb/upb/def.c:798
L
lua_State * L
Definition: upb/upb/bindings/lua/main.c:35
lupb_MessageDef
Definition: upb/upb/bindings/lua/def.c:318
lupb_msgoneofiter_next
static int lupb_msgoneofiter_next(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:459
msgdef
const upb_msgdef * msgdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:808
LUPB_ONEOFDEF
#define LUPB_ONEOFDEF
Definition: upb/upb/bindings/lua/def.c:44
lupb_MessageDef_m
static const struct luaL_Reg lupb_MessageDef_m[]
Definition: upb/upb/bindings/lua/def.c:506
lupb_MessageDef_tostring
static int lupb_MessageDef_tostring(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:491
cpp.gmock_class.set
set
Definition: bloaty/third_party/googletest/googlemock/scripts/generator/cpp/gmock_class.py:44
xds_manager.num
num
Definition: xds_manager.py:56
lupb_FieldDef_Default
static int lupb_FieldDef_Default(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:116
upb_MessageDef_FullName
const char * upb_MessageDef_FullName(const upb_MessageDef *m)
Definition: upb/upb/def.c:701
kUpb_Syntax_Proto3
@ kUpb_Syntax_Proto3
Definition: upb/upb/def.h:65
lupbdef_toplevel_m
static const struct luaL_Reg lupbdef_toplevel_m[]
Definition: upb/upb/bindings/lua/def.c:886
upb_MessageDef_File
const upb_FileDef * upb_MessageDef_File(const upb_MessageDef *m)
Definition: upb/upb/def.c:705
upb_DefPool_AddFile
const upb_FileDef * upb_DefPool_AddFile(upb_DefPool *s, const google_protobuf_FileDescriptorProto *file_proto, upb_Status *status)
Definition: upb/upb/def.c:3140
lupb_MessageDef_mm
static const struct luaL_Reg lupb_MessageDef_mm[]
Definition: upb/upb/bindings/lua/def.c:499
lupb_EnumDef_mm
static const struct luaL_Reg lupb_EnumDef_mm[]
Definition: upb/upb/bindings/lua/def.c:567
kUpb_FieldType_Message
@ kUpb_FieldType_Message
Definition: upb/upb/upb.h:319
lupb_FileDef_DependencyCount
static int lupb_FileDef_DependencyCount(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:626
LUPB_FILEDEF
#define LUPB_FILEDEF
Definition: upb/upb/bindings/lua/def.c:42
lupb_MessageDef_pushsubmsgdef
void lupb_MessageDef_pushsubmsgdef(lua_State *L, const upb_FieldDef *f)
Definition: upb/upb/bindings/lua/def.c:89
kUpb_CType_Bool
@ kUpb_CType_Bool
Definition: upb/upb/upb.h:287
upb_FieldDef_ContainingOneof
const upb_OneofDef * upb_FieldDef_ContainingOneof(const upb_FieldDef *f)
Definition: upb/upb/def.c:571
kUpb_CType_Enum
@ kUpb_CType_Enum
Definition: upb/upb/upb.h:291
lupb_FieldDef_Name
static int lupb_FieldDef_Name(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:156
upb_EnumDef
Definition: upb/upb/def.c:134
lupb_DefPool_m
static const struct luaL_Reg lupb_DefPool_m[]
Definition: upb/upb/bindings/lua/def.c:866
lupb_DefPool_pushwrapper
static void lupb_DefPool_pushwrapper(lua_State *L, int narg, const void *def, const char *type)
Definition: upb/upb/bindings/lua/def.c:720
upb_FieldDef_Name
const char * upb_FieldDef_Name(const upb_FieldDef *f)
Definition: upb/upb/def.c:549
upb_EnumValueDef_Enum
const upb_EnumDef * upb_EnumValueDef_Enum(const upb_EnumValueDef *ev)
Definition: upb/upb/def.c:446
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
upb_MessageDef_FieldCount
int upb_MessageDef_FieldCount(const upb_MessageDef *m)
Definition: upb/upb/def.c:794
kUpb_CType_UInt64
@ kUpb_CType_UInt64
Definition: upb/upb/upb.h:295
kUpb_FieldType_Int32
@ kUpb_FieldType_Int32
Definition: upb/upb/upb.h:313
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
lupb_DefPool_gc
static int lupb_DefPool_gc(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:782
kUpb_FieldType_Int64
@ kUpb_FieldType_Int64
Definition: upb/upb/upb.h:311
lupb_MessageDef_call
int lupb_MessageDef_call(lua_State *L)
Definition: bindings/lua/msg.c:789
google_protobuf_FileDescriptorProto
struct google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto
Definition: descriptor.upb.h:51
upb_DefPool
Definition: upb/upb/def.c:217
amalgamate.files
list files
Definition: amalgamate.py:115
lupb_FileDef_msgcount
static int lupb_FileDef_msgcount(lua_State *L)
Definition: upb/upb/bindings/lua/def.c:654
upb_MessageDef_FindFieldByNumber
const upb_FieldDef * upb_MessageDef_FindFieldByNumber(const upb_MessageDef *m, uint32_t i)
Definition: upb/upb/def.c:721
kUpb_Label_Optional
@ kUpb_Label_Optional
Definition: upb/upb/upb.h:302
upb_EnumValueDef_Number
int32_t upb_EnumValueDef_Number(const upb_EnumValueDef *ev)
Definition: upb/upb/def.c:458
upb_Arena
Definition: upb_internal.h:36
LUPB_ENUMVALDEF
#define LUPB_ENUMVALDEF
Definition: upb/upb/bindings/lua/def.c:40
upb_DefPool_FindMessageByName
const upb_MessageDef * upb_DefPool_FindMessageByName(const upb_DefPool *s, const char *sym)
Definition: upb/upb/def.c:1125
fix_build_deps.dep
string dep
Definition: fix_build_deps.py:439
lupb_enumvaldef_check
const upb_EnumValueDef * lupb_enumvaldef_check(lua_State *L, int narg)
Definition: upb/upb/bindings/lua/def.c:576
kUpb_CType_Message
@ kUpb_CType_Message
Definition: upb/upb/upb.h:292
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
upb_EnumDef_FindValueByName
const UPB_INLINE upb_EnumValueDef * upb_EnumDef_FindValueByName(const upb_EnumDef *e, const char *name)
Definition: upb/upb/def.h:273
upb_FileDef_TopLevelMessageCount
int upb_FileDef_TopLevelMessageCount(const upb_FileDef *f)
Definition: upb/upb/def.c:926
kUpb_FieldType_Bytes
@ kUpb_FieldType_Bytes
Definition: upb/upb/upb.h:320
upb_FileDef_DependencyCount
int upb_FileDef_DependencyCount(const upb_FileDef *f)
Definition: upb/upb/def.c:930
lupb_EnumDef_check
const upb_EnumDef * lupb_EnumDef_check(lua_State *L, int narg)
Definition: upb/upb/bindings/lua/def.c:522


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:09