MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / getArrayInTable

Function getArrayInTable

src/vm/luavm/lmylib.cpp:316–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314
315template <typename ArrayType>
316static bool getArrayInTable(lua_State *L, const char *pKey, uint16_t usLen, ArrayType &arrayOut) {
317 // 在table里,取指定pKey对应的数组
318 if ((usLen <= 0) || (usLen > LUA_C_BUFFER_SIZE)) {
319 LogPrint(BCLog::LUAVM, "usLen error\n");
320 return false;
321 }
322 uint8_t value = 0;
323 arrayOut.clear();
324 //默认栈顶是table,将key入栈
325 lua_pushstring(L, pKey);
326 lua_gettable(L, -2);
327 if (!lua_istable(L, -1)) {
328 lua_pop(L, 1);
329 LogPrint(BCLog::LUAVM, "getTableInTable is not table\n");
330 return false;
331 }
332 for (int32_t i = 0; i < usLen; ++i) {
333 lua_pushnumber(L, i + 1); //将索引入栈
334 lua_gettable(L, -2);
335 if (!lua_isnumber(L, -1)) {
336 LogPrint(BCLog::LUAVM, "getTableInTable is not number\n");
337 return false;
338 }
339 value = 0;
340 value = lua_tonumber(L, -1);
341 arrayOut.insert(arrayOut.end(), value);
342 lua_pop(L, 1);
343 }
344 lua_pop(L, 1); //删掉产生的查找结果
345 return true;
346}
347
348static bool getStringLogPrint(lua_State *L, char *pKey, uint16_t usLen, vector<uint8_t> &vOut) {
349 //从栈里取 table的值是一串字符串

Callers 11

GetDataTableLogPrintFunction · 0.85
GetDataTableDesFunction · 0.85
ParseUidInTableFunction · 0.85
GetDataTableWriteDataDBFunction · 0.85
GetDataTableWriteOutputFunction · 0.85
ExGetUserAppAccValueFuncFunction · 0.85
GetDataTableAssetOperateFunction · 0.85

Calls 7

lua_pushstringFunction · 0.85
lua_gettableFunction · 0.85
lua_pushnumberFunction · 0.85
lua_isnumberFunction · 0.85
clearMethod · 0.45
insertMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected