MCPcopy Create free account
hub / github.com/Tencent/UnLua / lpbE_encode

Function lpbE_encode

Plugins/UnLuaExtensions/LuaProtobuf/Source/src/pb.cpp:1644–1665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1642}
1643
1644static void lpbE_encode(lpb_Env *e, const pb_Type *t, int idx) {
1645 lua_State *L = e->L;
1646 luaL_checkstack(L, 3, "message too many levels");
1647 if (e->LS->encode_order) {
1648 const pb_Field *f = NULL;
1649 while (pb_nextfield(t, &f)) {
1650 if (lua53_getfield(L, idx, (const char*)f->name) != LUA_TNIL)
1651 lpb_encode_onefield(e, t, f, -1);
1652 lua_pop(L, 1);
1653 }
1654 } else {
1655 lua_pushnil(L);
1656 while (lua_next(L, lpb_relindex(idx, 1))) {
1657 if (lua_type(L, -2) == LUA_TSTRING) {
1658 const pb_Field *f =
1659 pb_fname(t, lpb_name(e->LS, lpb_toslice(L, -2)));
1660 if (f != NULL) lpb_encode_onefield(e, t, f, -1);
1661 }
1662 lua_pop(L, 1);
1663 }
1664 }
1665}
1666
1667static int Lpb_encode(lua_State *L) {
1668 lpb_State *LS = lpb_lstate(L);

Callers 2

lpbE_fieldFunction · 0.85
Lpb_encodeFunction · 0.85

Calls 10

luaL_checkstackFunction · 0.85
pb_nextfieldFunction · 0.85
lua53_getfieldFunction · 0.85
lpb_encode_onefieldFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
lpb_relindexFunction · 0.85
lua_typeFunction · 0.85
pb_fnameFunction · 0.85
lpb_tosliceFunction · 0.85

Tested by

no test coverage detected