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

Function getNumberInTable

src/vm/luavm/lmylib.cpp:272–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272static bool getNumberInTable(lua_State *L, const char* pKey, double &ret) {
273 // 在table里,取指定pKey对应的一个number值
274
275 //默认栈顶是table,将pKey入栈
276 lua_pushstring(L, pKey);
277 lua_gettable(L, -2); //查找键值为key的元素,置于栈顶
278 if (!lua_isnumber(L, -1)) {
279 LogPrint(BCLog::LUAVM, "num get error! %s\n", lua_tostring(L, -1));
280 lua_pop(L, 1); //删掉产生的查找结果
281 return false;
282 } else {
283 ret = lua_tonumber(L, -1);
284 // LogPrint(BCLog::LUAVM, "getNumberInTable:%d\n", ret);
285 lua_pop(L, 1); //删掉产生的查找结果
286 return true;
287 }
288}
289
290static bool getStringInTable(lua_State *L, const char * pKey, string &strValue) {
291 // 在table里,取指定pKey对应的string值

Callers 8

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

Calls 3

lua_pushstringFunction · 0.85
lua_gettableFunction · 0.85
lua_isnumberFunction · 0.85

Tested by

no test coverage detected