Go to the documentation of this file.
44 #include "upb/port_def.inc"
113 #define LUPB_ARENA "lupb.arena"
114 #define LUPB_ARRAY "lupb.array"
115 #define LUPB_MAP "lupb.map"
116 #define LUPB_MSG "lupb.msg"
118 #define LUPB_ARENA_INDEX 1
119 #define LUPB_MSGDEF_INDEX 2
128 luaL_argcheck(
L,
ok, narg,
"invalid field type");
143 lua_createtable(
L, 0, 1);
144 lua_pushstring(
L,
"v");
145 lua_setfield(
L, -2,
"__mode");
146 lua_setmetatable(
L, -2);
149 lua_rawsetp(
L, LUA_REGISTRYINDEX, &
cache_key);
163 lua_rawgetp(
L, LUA_REGISTRYINDEX, &
cache_key);
164 lua_rawgetp(
L, -1,
key);
165 if (lua_isnil(
L, -1)) {
180 lua_rawgetp(
L, LUA_REGISTRYINDEX, &
cache_key);
181 lua_pushvalue(
L, -2);
182 lua_rawsetp(
L, -2,
key);
312 luaL_argcheck(
L, lua_rawequal(
L, -1, -2), narg,
"message type mismatch");
378 luaL_argcheck(
L,
n != 0 &&
n <=
max, narg,
"invalid array index");
391 int arg_count = lua_gettop(
L);
395 if (lua_type(
L, 1) == LUA_TNUMBER) {
415 int msg = arg_count + 1;
417 while (lua_next(
L, 2) != 0) {
418 lua_pushvalue(
L, -2);
420 lua_settable(
L,
msg);
496 #define MAP_MSGDEF_INDEX 1
499 return luaL_checkudata(
L, narg,
LUPB_MAP);
515 if (lua_type(
L, 2) == LUA_TNUMBER) {
580 if (lua_isnil(
L, 3)) {
594 int map = lua_upvalueindex(2);
595 size_t*
iter = lua_touserdata(
L, lua_upvalueindex(1));
616 size_t*
iter = lua_newuserdata(
L,
sizeof(*
iter));
659 const char* fieldname = luaL_checklstring(
L,
field, &
len);
668 luaL_error(
L,
"no such field '%s'", lua_tostring(
L,
field));
776 luaL_argcheck(
L, lua_rawequal(
L, -1, -2), narg,
"message type mismatch");
790 int arg_count = lua_gettop(
L);
795 int msg = arg_count + 1;
797 while (lua_next(
L, 2) != 0) {
798 lua_pushvalue(
L, -2);
800 lua_settable(
L,
msg);
847 bool merge_arenas =
true;
867 luaL_argcheck(
L, larr->
type ==
type, 3,
"array type mismatch");
878 merge_arenas =
false;
934 if (lua_gettop(
L) >= narg) {
935 size_t len = lua_rawlen(
L, narg);
936 for (
size_t i = 1;
i <=
len;
i++) {
937 lua_rawgeti(
L, narg,
i);
954 const char* pb = lua_tolstring(
L, 2, &
len);
968 lua_pushstring(
L,
"Error decoding protobuf.");
994 lua_pushstring(
L,
"Error encoding protobuf.");
1013 const char* json = lua_tolstring(
L, 2, &
len);
1087 lua_pushinteger(
L,
i);
1088 lua_setfield(
L, -2,
field);
static int lupb_Map_New(lua_State *L)
static const struct luaL_Reg lupb_map_mm[]
void * lupb_newuserdata(lua_State *L, size_t size, int n, const char *type)
upb_Array * upb_Array_New(upb_Arena *a, upb_CType type)
upb_MessageValue upb_MapIterator_Key(const upb_Map *map, size_t iter)
size_t upb_Map_Size(const upb_Map *map)
static const upb_MessageDef * lupb_Message_Getmsgdef(lua_State *L, int msg)
static upb_Arena * lupb_Arena_check(lua_State *L, int narg)
@ kUpb_Encode_Deterministic
const upb_MessageDef * lupb_MessageDef_check(lua_State *L, int narg)
const upb_MiniTable * upb_MessageDef_MiniTable(const upb_MessageDef *m)
@ kUpb_Encode_SkipUnknown
static const struct luaL_Reg lupb_array_mm[]
static bool lupb_cacheget(lua_State *L, const void *key)
upb_DecodeStatus upb_Decode(const char *buf, size_t size, void *msg, const upb_MiniTable *l, const upb_ExtensionRegistry *extreg, int options, upb_Arena *arena)
static void lupb_Arena_Fuse(lua_State *L, int to, int from)
int32_t lupb_checkint32(lua_State *L, int narg)
static int copy(grpc_slice_buffer *input, grpc_slice_buffer *output)
uint64_t lupb_checkuint64(lua_State *L, int narg)
static int lupb_Arena_gc(lua_State *L)
size_t upb_JsonEncode(const upb_Message *msg, const upb_MessageDef *m, const upb_DefPool *ext_pool, int options, char *buf, size_t size, upb_Status *status)
static void lupb_Message_Newwrapper(lua_State *L, int narg, const upb_FieldDef *f, upb_MutableMessageValue val)
static upb_CType lupb_checkfieldtype(lua_State *L, int narg)
static upb_MessageValue lupb_tomsgval(lua_State *L, upb_CType type, int narg, int container, lupb_copy_t copy)
#define kUpb_MapEntry_ValueFieldNumber
static int lupb_textencode(lua_State *L)
upb_MessageValue upb_Array_Get(const upb_Array *arr, size_t i)
static upb_Arena * lupb_Arenaget(lua_State *L, int narg)
UPB_INLINE upb_Arena * upb_Arena_New(void)
void upb_Status_Clear(upb_Status *status)
grpc_core::ScopedArenaPtr arena
#define kUpb_MapEntry_KeyFieldNumber
const upb_Array * array_val
const char * lupb_checkstring(lua_State *L, int narg, size_t *len)
upb_Message * upb_Message_New(const upb_MessageDef *m, upb_Arena *a)
void lupb_pushuint32(lua_State *L, uint32_t val)
void lupb_pushmsgval(lua_State *L, int container, upb_CType type, upb_MessageValue val)
void lupb_pushuint64(lua_State *L, uint64_t val)
static const upb_FieldDef * lupb_msg_checkfield(lua_State *L, int msg, int field)
static int lupb_Array_New(lua_State *L)
int lua_setiuservalue(lua_State *L, int index, int n)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
double lupb_checkdouble(lua_State *L, int narg)
static int lupb_array_checkindex(lua_State *L, int narg, uint32_t max)
static int lupb_decode(lua_State *L)
bool upb_FieldDef_IsMap(const upb_FieldDef *f)
static lupb_array * lupb_array_check(lua_State *L, int narg)
void lupb_pushint32(lua_State *L, int32_t val)
bool upb_MapIterator_Next(const upb_Map *map, size_t *iter)
int lua_getiuservalue(lua_State *L, int index, int n)
static int lupb_map_index(lua_State *L)
static int lupb_jsonencode(lua_State *L)
void lupb_checkstatus(lua_State *L, upb_Status *s)
static int lupb_msg_tostring(lua_State *L)
void lupb_register_type(lua_State *L, const char *name, const luaL_Reg *m, const luaL_Reg *mm)
void lupb_pushint64(lua_State *L, int64_t val)
UPB_INLINE void * upb_Arena_Malloc(upb_Arena *a, size_t size)
#define LUPB_MSGDEF_INDEX
static void lupb_cacheset(lua_State *L, const void *key)
static void lupb_Message_Newmsgwrapper(lua_State *L, int narg, upb_MessageValue val)
int64_t lupb_checkint64(lua_State *L, int narg)
static int lupb_Array_Newindex(lua_State *L)
@ kUpb_DecodeOption_AliasString
static void lupb_msg_typechecksubmsg(lua_State *L, int narg, int msgarg, const upb_FieldDef *f)
float lupb_checkfloat(lua_State *L, int narg)
const upb_Message * msg_val
bool upb_Array_Append(upb_Array *arr, upb_MessageValue val, upb_Arena *arena)
upb_CType upb_FieldDef_CType(const upb_FieldDef *f)
bool lupb_checkbool(lua_State *L, int narg)
upb_Message * lupb_msg_pushnew(lua_State *L, int narg)
static int lupb_Map_Newindex(lua_State *L)
static int lupb_Message_Newindex(lua_State *L)
const upb_MessageDef * upb_FieldDef_MessageSubDef(const upb_FieldDef *f)
@ upb_JsonEncode_UseProtoNames
bool upb_Map_Set(upb_Map *map, upb_MessageValue key, upb_MessageValue val, upb_Arena *arena)
static const upb_FieldDef * lupb_msg_tofield(lua_State *L, int msg, int field)
static int lupb_Encode(lua_State *L)
size_t upb_Array_Size(const upb_Array *arr)
#define LUPB_UNREACHABLE()
void upb_Array_Set(upb_Array *arr, size_t i, upb_MessageValue val)
static void lupb_cacheinit(lua_State *L)
size_t upb_TextEncode(const upb_Message *msg, const upb_MessageDef *m, const upb_DefPool *ext_pool, int options, char *buf, size_t size)
char * upb_Encode(const void *msg, const upb_MiniTable *l, int options, upb_Arena *arena, size_t *size)
static int lupb_msg_index(lua_State *L)
static int lupb_map_len(lua_State *L)
const FieldDescriptor * field
@ upb_JsonDecode_IgnoreUnknown
static const struct luaL_Reg lupb_msg_toplevel_m[]
bool upb_Map_Delete(upb_Map *map, upb_MessageValue key)
upb_MutableMessageValue upb_Message_Mutable(upb_Message *msg, const upb_FieldDef *f, upb_Arena *a)
upb_MessageValue upb_Message_Get(const upb_Message *msg, const upb_FieldDef *f)
bool upb_FieldDef_IsRepeated(const upb_FieldDef *f)
UniquePtr< SSL_SESSION > ret
bool upb_JsonDecode(const char *buf, size_t size, upb_Message *msg, const upb_MessageDef *m, const upb_DefPool *symtab, int options, upb_Arena *arena, upb_Status *status)
upb_Arena * lupb_Arena_pushnew(lua_State *L)
@ upb_JsonEncode_EmitDefaults
static int lupb_map_pairs(lua_State *L)
UPB_INLINE upb_StringView upb_StringView_FromDataAndSize(const char *data, size_t size)
static void lupb_setfieldi(lua_State *L, const char *field, int i)
static upb_Message * lupb_msg_check(lua_State *L, int narg)
uint32_t lupb_checkuint32(lua_State *L, int narg)
static const struct luaL_Reg lupb_msg_mm[]
static int lupb_array_index(lua_State *L)
bool upb_Map_Get(const upb_Map *map, upb_MessageValue key, upb_MessageValue *val)
void lupb_MessageDef_pushsubmsgdef(lua_State *L, const upb_FieldDef *f)
bool upb_FieldDef_IsSubMessage(const upb_FieldDef *f)
static int lupb_jsondecode(lua_State *L)
upb_Map * upb_Map_New(upb_Arena *a, upb_CType key_type, upb_CType value_type)
static int lupb_array_len(lua_State *L)
bool upb_Message_Set(upb_Message *msg, const upb_FieldDef *f, upb_MessageValue val, upb_Arena *a)
void lupb_msg_registertypes(lua_State *L)
int lupb_MessageDef_call(lua_State *L)
upb_MessageValue upb_MapIterator_Value(const upb_Map *map, size_t iter)
static const struct luaL_Reg lupb_Arena_mm[]
const upb_FieldDef * upb_MessageDef_FindFieldByNumber(const upb_MessageDef *m, uint32_t i)
static void * lupb_Message_Newud(lua_State *L, int narg, size_t size, const char *type, const upb_FieldDef *f)
static void lupb_Arena_Fuseobjs(lua_State *L, int to, int from)
const upb_FieldDef * upb_MessageDef_FindFieldByNameWithSize(const upb_MessageDef *m, const char *name, size_t len)
bool upb_Arena_Fuse(upb_Arena *a1, upb_Arena *a2)
void upb_Arena_Free(upb_Arena *a)
static struct async_container * container
static lupb_map * lupb_map_check(lua_State *L, int narg)
static int lupb_MapIterator_Next(lua_State *L)
static int lupb_getoptions(lua_State *L, int narg)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:30