| 181 | } |
| 182 | |
| 183 | static 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 | |
| 206 | static bool GetDataInt(lua_State *L, int32_t &intValue) { |
| 207 | //从栈里取int 高度 |
no test coverage detected