| 217 | } |
| 218 | |
| 219 | static bool GetDataString(lua_State *L, vector<std::shared_ptr<std::vector<uint8_t>>> &ret) { |
| 220 | //从栈里取一串字符串 |
| 221 | if (!lua_isstring(L, -1 - 0)) { |
| 222 | LogPrint(BCLog::LUAVM, "%s\n", "data is not string"); |
| 223 | return false; |
| 224 | } |
| 225 | vector<uint8_t> vBuf; |
| 226 | vBuf.clear(); |
| 227 | const char *pStr = nullptr; |
| 228 | pStr = lua_tostring(L, -1 - 0); |
| 229 | if (pStr && (strlen(pStr) <= LUA_C_BUFFER_SIZE)) { |
| 230 | for (size_t i = 0; i < strlen(pStr); i++) { |
| 231 | vBuf.insert(vBuf.end(), pStr[i]); |
| 232 | } |
| 233 | ret.insert(ret.end(), std::make_shared<vector<uint8_t>>(vBuf.begin(), vBuf.end())); |
| 234 | // LogPrint(BCLog::LUAVM, "GetDataString:%s\n", pStr); |
| 235 | return true; |
| 236 | } else { |
| 237 | LogPrint(BCLog::LUAVM, "%s\n", "lua_tostring get fail"); |
| 238 | return false; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | // get bool field value of table |
| 243 | static bool GetBoolInTable(lua_State *L, const char *pKey, bool &value) { |
no test coverage detected