diff options
-rw-r--r-- | include/LuaTask.h | 2 | ||||
-rw-r--r-- | lib/LuaTask.cc | 21 |
2 files changed, 21 insertions, 2 deletions
diff --git a/include/LuaTask.h b/include/LuaTask.h index 48f65bf..85e228f 100644 --- a/include/LuaTask.h +++ b/include/LuaTask.h @@ -8,6 +8,7 @@ class LuaTask : public Task { public: LuaTask(Lua *, const String &); + LuaTask(Lua *, int); virtual ~LuaTask(); virtual String GetName(); protected: @@ -15,6 +16,7 @@ class LuaTask : public Task { private: Lua * L; String cmd; + int nargs, stacktop; Task * c; Buffer * b; diff --git a/lib/LuaTask.cc b/lib/LuaTask.cc index 4608fa1..ac3df8d 100644 --- a/lib/LuaTask.cc +++ b/lib/LuaTask.cc @@ -6,13 +6,24 @@ LuaTask * LuaTask::top = 0; -LuaTask::LuaTask(Lua * _L, const String & _cmd) : L(_L), cmd(_cmd), c(0), b(0) { +LuaTask::LuaTask(Lua * _L, const String & _cmd) : L(_L), cmd(_cmd), nargs(0), c(0), b(0) { if (top) { WaitFor(top); } else { SetBurst(); } top = this; + stacktop = L->gettop() + 1; +} + +LuaTask::LuaTask(Lua * _L, int _nargs) : L(_L), cmd(""), nargs(_nargs), c(0), b(0) { + if (top) { + WaitFor(top); + } else { + SetBurst(); + } + top = this; + stacktop = L->gettop() - nargs; } LuaTask::~LuaTask() { @@ -29,16 +40,22 @@ int LuaTask::Do() throw (GeneralException) { switch (current) { case 0: current = 1; - L->resume(cmd); + if (cmd != "") { + L->resume(cmd); + } else { + L->resume(nargs); + } case 1: if (c) { int nargs = 0; +#ifndef LUATASK_OMIT_HTTPCLIENT if (task == "HttpClient") { LuaBuffer o(b); o.pushdestruct(L); nargs = 1; } +#endif delete c; c = 0; |