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

Function GetArray

src/vm/luavm/lmylib.cpp:183–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183static bool GetArray(lua_State *L, vector<std::shared_ptr<std::vector<uint8_t>>> &ret) {
184 //从栈里取变长的数组
185 int32_t totallen = lua_gettop(L);
186 if ((totallen <= 0) || (totallen > LUA_C_BUFFER_SIZE)) {
187 LogPrint(BCLog::LUAVM, "totallen error\n");
188 return false;
189 }
190
191 vector<uint8_t> vBuf;
192 vBuf.clear();
193 for (int32_t i = 0; i < totallen; i++) {
194 if (!lua_isnumber(L, i + 1)) // if(!lua_isnumber(L,-1 - i))
195 {
196 LogPrint(BCLog::LUAVM, "%s\n", "data is not number");
197 return false;
198 }
199 vBuf.insert(vBuf.end(), lua_tonumber(L, i + 1));
200 }
201 ret.insert(ret.end(), std::make_shared<vector<uint8_t>>(vBuf.begin(), vBuf.end()));
202 // LogPrint(BCLog::LUAVM, "GetData:%s, len:%d\n", HexStr(vBuf).c_str(), vBuf.size());
203 return true;
204}
205
206static bool GetDataInt(lua_State *L, int32_t &intValue) {
207 //从栈里取int 高度

Callers 8

ExGetTxContractFuncFunction · 0.85
ExGetTxRegIDFuncFunction · 0.85
ExByteToIntegerFuncFunction · 0.85
ExGetTxConfirmHeightFuncFunction · 0.85
ExGetBase58AddrFuncFunction · 0.85
ExTransferContractAssetFunction · 0.85

Calls 6

lua_gettopFunction · 0.85
lua_isnumberFunction · 0.85
clearMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected