summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2007-05-23 13:05:56 +0000
committerpixel <pixel>2007-05-23 13:05:56 +0000
commit0090125ad36fe82d7df317cd41c838f30f4e9cf5 (patch)
tree4956e95576996f2610c3a691b663084b182c005d
parent791463bd7d6358fa137b3c786857770a720e7dac (diff)
LuaTask is now able to work on the current stack instead of taking a
string command.
-rw-r--r--include/LuaTask.h2
-rw-r--r--lib/LuaTask.cc21
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;