void JSInterIsolateCallManager::notify(const Request& request, void* userData, JSPersistentFunctionHandle* cb) { bool delegateToSelf = getIsolate()->isThreadSelf(); JSInterIsolateCall::Ptr pCall(new JSInterIsolateCall(request, 0, userData, cb)); enqueue(pCall); if (delegateToSelf) { doOneWork(); } else { getEventLoop()->wakeup(); } }
/// @return non-zero on errors, and a description is available through getError() int Interpreter::doString(const std::string& str, const std::string& identifier) { errstr = ""; status = luaL_loadbuffer(luastate, str.c_str(), str.length(), identifier.c_str()); if (status != 0 && getTop() > 0) { if (lua_tostring(luastate, -1)) errstr = lua_tostring(luastate, -1); else { std::stringstream ss; ss << "doString returned " << status << " and top of stack is not string, stack:\n" << getStack(); throw LuaException(ss.str()); } lua_pop(luastate,1); return status; } // Run it return pCall(0,1,0,1); }
/// @return non-zero on errors, and a description is available through getError() int Interpreter::doFile(const std::string& filename) { errstr = ""; // Load the data status = luaL_loadfile(luastate, filename.c_str()); if (status != 0 && getTop() > 0) { if (lua_tostring(luastate, -1)) errstr = lua_tostring(luastate, -1); else { std::stringstream ss; ss << "doFile returned " << status << " and top of stack is not string, stack:\n" << getStack(); throw LuaException(ss.str()); } lua_pop(luastate,1); return status; } // Run it return pCall(0,1,0,1); }
bool JSInterIsolateCallManager::execute(const Request& request, Result& result, uint32_t timeout, void* userData) { bool delegateToSelf = getIsolate()->isThreadSelf(); JSInterIsolateCall::Ptr pCall(new JSInterIsolateCall(request, timeout, userData)); enqueue(pCall); if (delegateToSelf) { doOneWork(); } else { getEventLoop()->wakeup(); } if (!pCall->waitForResult()) { return false; } result = pCall->getResult(); return true; }