summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/LuaHttp.cc92
1 files changed, 86 insertions, 6 deletions
diff --git a/lib/LuaHttp.cc b/lib/LuaHttp.cc
index 6d22307..993b7a1 100644
--- a/lib/LuaHttp.cc
+++ b/lib/LuaHttp.cc
@@ -3,6 +3,61 @@
#include "LuaHandle.h"
#include "LuaTask.h"
+class LuaDomain;
+
+class LuaLuaDomain : public LuaObject {
+ public:
+ static void pushstatics(Lua *) throw (GeneralException);
+ LuaLuaDomain(LuaDomain *);
+ protected:
+ virtual void pushmembers(Lua *);
+ LuaDomain * d;
+};
+
+LuaLuaDomain::LuaLuaDomain(LuaDomain * _d) : d(_d) { }
+
+enum LuaDomain_methods_t {
+ LUADOMAIN_ONTOP = 0,
+};
+
+enum LuaDomain_functions_t {
+ LUADOMAIN_NEWDOMAIN = 0,
+};
+
+struct lua_functypes_t LuaDomain_methods[] = {
+ { LUADOMAIN_ONTOP, "OnTop", 0, 0, { } },
+ { -1, 0, 0, 0, 0 },
+};
+
+struct lua_functypes_t LuaDomain_functions[] = {
+ { LUADOMAIN_NEWDOMAIN, "Domain", 2, 2, { LUA_STRING, LUA_FUNCTION } },
+ { -1, 0, 0, 0, 0 },
+};
+
+class sLua_LuaDomain : public Base {
+ public:
+ DECLARE_METHOD(LuaDomain, LUADOMAIN_ONTOP);
+
+ DECLARE_FUNCTION(LuaDomain, LUADOMAIN_NEWDOMAIN);
+
+ private:
+ static int LuaDomain_proceed(Lua * L, int n, LuaDomain * obj, int caller);
+ static int LuaDomain_proceed_statics(Lua * L, int n, int caller);
+};
+
+void LuaLuaDomain::pushmembers(Lua * L) {
+ pushme(L, d);
+
+ PUSH_METHOD(LuaDomain, LUADOMAIN_ONTOP);
+}
+
+void LuaLuaDomain::pushstatics(Lua * L) throw (GeneralException) {
+ CHECK_METHODS(LuaDomain);
+ CHECK_FUNCTIONS(LuaDomain);
+
+ PUSH_FUNCTION(LuaDomain, LUADOMAIN_NEWDOMAIN);
+}
+
#define DOMAIN_REGISTRY "DOMAINS_KEYS"
#define export_enum(L, n) \
@@ -19,7 +74,6 @@ enum HttpResponse_method_t {
enum HttpResponse_functions_t {
HTTPRESPONSE_NEWHTTPRESPONSE = 0,
- HTTPRESPONSE_REGISTERDOMAIN,
};
struct lua_functypes_t HttpResponse_methods[] = {
@@ -30,7 +84,6 @@ struct lua_functypes_t HttpResponse_methods[] = {
struct lua_functypes_t HttpResponse_functions[] = {
{ HTTPRESPONSE_NEWHTTPRESPONSE, "HttpResponse", 0, 0, { } },
- { HTTPRESPONSE_REGISTERDOMAIN, "RegisterDomain", 2, 2, { LUA_STRING, LUA_FUNCTION } },
{ -1, 0, 0, 0, 0 }
};
@@ -40,7 +93,6 @@ class sLua_HttpResponse : public Base {
DECLARE_METHOD(HttpResponse, HTTPRESPONSE_NEWINDEX);
DECLARE_FUNCTION(HttpResponse, HTTPRESPONSE_NEWHTTPRESPONSE);
- DECLARE_FUNCTION(HttpResponse, HTTPRESPONSE_REGISTERDOMAIN);
private:
static int HttpResponse_proceed(Lua * L, int n, HttpResponse * obj, int caller);
static int HttpResponse_proceed_statics(Lua * L, int n, int caller);
@@ -58,7 +110,6 @@ void LuaHttpResponse::pushstatics(Lua * L) throw (GeneralException) {
CHECK_FUNCTIONS(HttpResponse);
PUSH_FUNCTION(HttpResponse, HTTPRESPONSE_NEWHTTPRESPONSE);
- PUSH_FUNCTION(HttpResponse, HTTPRESPONSE_REGISTERDOMAIN);
export_enum(L, HTTP_200_OK);
export_enum(L, HTTP_301_PERM_MOVED);
@@ -73,6 +124,8 @@ void LuaHttpResponse::pushstatics(Lua * L) throw (GeneralException) {
L->push(DOMAIN_REGISTRY);
L->newtable();
L->settable(LUA_REGISTRYINDEX);
+
+ LuaLuaDomain::pushstatics(L);
}
int sLua_HttpResponse::HttpResponse_proceed(Lua * L, int n, HttpResponse * res, int caller) {
@@ -222,9 +275,36 @@ int sLua_HttpResponse::HttpResponse_proceed_statics(Lua * L, int n, int caller)
}
r = 1;
break;
- case HTTPRESPONSE_REGISTERDOMAIN:
- new LuaDomain(L, L->tostring(1));
}
return r;
}
+
+int sLua_LuaDomain::LuaDomain_proceed(Lua * L, int n, LuaDomain * obj, int caller) {
+ int r = 0;
+
+ switch (caller) {
+ case LUADOMAIN_ONTOP:
+ obj->OnTop();
+ break;
+ }
+
+ return r;
+}
+
+int sLua_LuaDomain::LuaDomain_proceed_statics(Lua * L, int n, int caller) {
+ int r = 0;
+
+ switch (caller) {
+ case LUADOMAIN_NEWDOMAIN:
+ {
+ LuaLuaDomain lld(new LuaDomain(L, L->tostring(1)));
+ lld.pushdestruct(L);
+ r = 1;
+ }
+ break;
+ }
+
+ return r;
+}
+