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

Function Lslice_leave

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

Source from the content-addressed store, hash-verified

1101}
1102
1103static int Lslice_leave(lua_State *L) {
1104 lpb_Slice *s = check_lslice(L, 1);
1105 lua_Integer count = posrelat(luaL_optinteger(L, 2, 1), s->used);
1106 if (count > (lua_Integer)s->used)
1107 argcheck(L, 0, 2, "level (%d) exceed max level %d",
1108 (int)count, (int)s->used);
1109 else if (count == (lua_Integer)s->used) {
1110 s->curr = s->buff[0];
1111 s->used = 1;
1112 } else {
1113 s->used -= (size_t)count;
1114 s->curr = s->buff[s->used];
1115 }
1116 lua_settop(L, 1);
1117 lua_pushinteger(L, s->used);
1118 return 2;
1119}
1120
1121LUALIB_API int lpb_newslice(lua_State *L, const char *s, size_t len) {
1122 pb_Slice *ls = (pb_Slice*)lua_newuserdata(L, sizeof(pb_Slice));

Callers

nothing calls this directly

Calls 6

check_lsliceFunction · 0.85
posrelatFunction · 0.85
luaL_optintegerFunction · 0.85
argcheckFunction · 0.85
lua_settopFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected