From 06c5eb97eb7e8653dff3f9e1190613e01be2f6f8 Mon Sep 17 00:00:00 2001 From: pixel Date: Fri, 25 May 2007 07:39:04 +0000 Subject: Slightly better stack handling, and adding support for LuaDomain's destructor. --- lib/LuaHttp.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib') 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(); -- cgit v1.2.3