summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2007-05-25 07:39:04 +0000
committerpixel <pixel>2007-05-25 07:39:04 +0000
commit06c5eb97eb7e8653dff3f9e1190613e01be2f6f8 (patch)
tree4885a4516c145564f014fd1df263cedf14a3ea4b
parentb769eedd469c2fd3df097ff47bf183945b69e962 (diff)
Slightly better stack handling, and adding support for LuaDomain's destructor.
-rw-r--r--lib/LuaHttp.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/LuaHttp.cc b/lib/LuaHttp.cc
index c746bff..e164eb4 100644
--- a/lib/LuaHttp.cc
+++ b/lib/LuaHttp.cc
@@ -3,6 +3,8 @@
#include "LuaHandle.h"
#include "LuaTask.h"
+#define DOMAIN_REGISTRY "DOMAINS_KEYS"
+
#define export_enum(L, n) \
L->push(#n); \
L->push((lua_Number) HttpResponse::n); \
@@ -68,7 +70,7 @@ void LuaHttpResponse::pushstatics(Lua * L) throw (GeneralException) {
export_enum(L, HTTP_500_INTERNAL_ERROR);
export_enum(L, HTTP_503_SERVICE_UNAVAILABLE);
- L->push("DOMAINS_KEYS");
+ L->push(DOMAIN_REGISTRY);
L->newtable();
L->settable(LUA_REGISTRYINDEX);
}
@@ -132,17 +134,25 @@ class LuaDomain : public Domain {
LuaDomain(Lua * _L, String r) : Domain(r), L(_L) {
id = max_id++;
- L->push("DOMAINS_KEYS");
+ L->push(DOMAIN_REGISTRY);
L->gettable(LUA_REGISTRYINDEX);
L->push((lua_Number) id);
L->copy(2);
L->settable();
+ L->pop();
+ }
+ virtual ~LuaDomain() {
+ L->push(DOMAIN_REGISTRY);
+ L->gettable(LUA_REGISTRYINDEX);
+ L->push((lua_Number id);
+ L->push();
+ L->settable();
+ L->pop();
}
- virtual ~LuaDomain() { }
virtual void Do(const HttpRequest & req, HttpResponse * res) throw (GeneralException) {
int i;
- L->push("DOMAINS_KEYS");
+ L->push(DOMAIN_REGISTRY);
L->gettable(LUA_REGISTRYINDEX);
L->push((lua_Number) id);
L->gettable();