From 0090125ad36fe82d7df317cd41c838f30f4e9cf5 Mon Sep 17 00:00:00 2001 From: pixel Date: Wed, 23 May 2007 13:05:56 +0000 Subject: LuaTask is now able to work on the current stack instead of taking a string command. --- lib/LuaTask.cc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'lib') 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; -- cgit v1.2.3