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

Function lpbD_unpack

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

Source from the content-addressed store, hash-verified

1945}
1946
1947static int lpbD_unpack(lpb_Env* e, const pb_Type* t) {
1948 lua_State* L = e->L;
1949 int top = lua_gettop(L);
1950 uint32_t tag;
1951 int last_index = 0;
1952 unsigned int decode_count = 0;
1953 pb_Field **list = pb_sortfield((pb_Type*)t);
1954 lua_settop(L, top + t->field_count);
1955 luaL_checkstack(L, t->field_count * 2, "not enough stack space for fields");
1956 while (pb_readvarint32(e->s, &tag)) {
1957 const pb_Field* f = pb_field(t, pb_gettag(tag));
1958 if (last_index && (!f || f->sort_index != last_index)) {
1959 decode_count++;
1960 lua_replace(L, top + last_index);
1961 last_index = 0;
1962 }
1963 last_index = lpb_unpackfield(e, f, tag, last_index);
1964 }
1965 if (last_index) {
1966 decode_count++;
1967 lua_replace(L, top + last_index);
1968 }
1969 if (decode_count != t->field_count) lpb_pushunpackdef(L, e->LS, t, list, top);
1970 return t->field_count;
1971}
1972
1973static int Lpb_unpack(lua_State* L) {
1974 lpb_State* LS = lpb_lstate(L);

Callers 1

Lpb_unpackFunction · 0.85

Calls 8

lua_gettopFunction · 0.85
pb_sortfieldFunction · 0.85
lua_settopFunction · 0.85
luaL_checkstackFunction · 0.85
pb_readvarint32Function · 0.85
pb_fieldFunction · 0.85
lpb_unpackfieldFunction · 0.85
lpb_pushunpackdefFunction · 0.85

Tested by

no test coverage detected