httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r534587 - in /httpd/mod_wombat/trunk: README apr_lua.c apr_lua.h test/test.lua
Date Wed, 02 May 2007 18:43:36 GMT
Author: brianm
Date: Wed May  2 11:43:35 2007
New Revision: 534587

URL: http://svn.apache.org/viewvc?view=rev&rev=534587
Log:
Add new files from Brian Akins missed in previous checkin

Added:
    httpd/mod_wombat/trunk/apr_lua.c
    httpd/mod_wombat/trunk/apr_lua.h
Modified:
    httpd/mod_wombat/trunk/README
    httpd/mod_wombat/trunk/test/test.lua

Modified: httpd/mod_wombat/trunk/README
URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/README?view=diff&rev=534587&r1=534586&r2=534587
==============================================================================
--- httpd/mod_wombat/trunk/README (original)
+++ httpd/mod_wombat/trunk/README Wed May  2 11:43:35 2007
@@ -49,4 +49,4 @@
     Paul Querna
     Garrett Rooney
     Martin Traverso
-    
+    Brian Akins    

Added: httpd/mod_wombat/trunk/apr_lua.c
URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/apr_lua.c?view=auto&rev=534587
==============================================================================
--- httpd/mod_wombat/trunk/apr_lua.c (added)
+++ httpd/mod_wombat/trunk/apr_lua.c Wed May  2 11:43:35 2007
@@ -0,0 +1,55 @@
+#include "apr.h"
+#include "apr_tables.h"
+
+#include "lua.h"
+#include "lauxlib.h"
+#include "lualib.h"
+
+#define lua_unboxpointer(L,i)      (*(void **)(lua_touserdata(L, i)))
+
+static apr_table_t* check_apr_table(lua_State* L, int index) {
+    luaL_checkudata(L, index, "Apr.Table");
+    apr_table_t* t = (apr_table_t*)lua_unboxpointer(L, index);
+    return t;
+}
+
+static int lua_table_set(lua_State* L) {
+    apr_table_t *t = check_apr_table(L, 1);
+    const char* key = luaL_checkstring(L, 2);
+    const char* val = luaL_checkstring(L, 3);
+
+    apr_table_set(t, key, val);
+    return 0;
+}
+
+static int lua_table_get(lua_State* L) {
+    apr_table_t *t = check_apr_table(L, 1);
+    const char* key = luaL_checkstring(L, 2);
+    const char *val = apr_table_get(t, key);
+    lua_pushstring(L, val);
+    return 1;
+}
+
+static const luaL_reg lua_table_methods[] = {
+    {"set", lua_table_set},
+    {"get", lua_table_get},
+    {0, 0}
+};
+
+
+int apr_lua_init(lua_State *L, apr_pool_t *p) {
+    luaL_newmetatable(L, "Apr.Table");
+    luaL_openlib(L, "apr_table", lua_table_methods, 0);
+    lua_pushstring(L, "__index");
+    lua_pushstring(L, "get");
+    lua_gettable(L, 2);
+    lua_settable(L, 1);
+
+    lua_pushstring(L, "__newindex");
+    lua_pushstring(L, "set");
+    lua_gettable(L, 2);
+    lua_settable(L, 1);
+    
+    return 0;
+}
+

Added: httpd/mod_wombat/trunk/apr_lua.h
URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/apr_lua.h?view=auto&rev=534587
==============================================================================
--- httpd/mod_wombat/trunk/apr_lua.h (added)
+++ httpd/mod_wombat/trunk/apr_lua.h Wed May  2 11:43:35 2007
@@ -0,0 +1,6 @@
+#ifndef _APR_LUA_H_
+#define _APR_LUA_H_
+
+int apr_lua_init(lua_State *L, apr_pool_t *p);
+
+#endif

Modified: httpd/mod_wombat/trunk/test/test.lua
URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/test/test.lua?view=diff&rev=534587&r1=534586&r2=534587
==============================================================================
--- httpd/mod_wombat/trunk/test/test.lua (original)
+++ httpd/mod_wombat/trunk/test/test.lua Wed May  2 11:43:35 2007
@@ -135,9 +135,9 @@
 end
 
 function test:request_scope_says_hi()
-	local r, c = http.get "/request-says-hi"
-	assert(200 == c, "incorrect status code returned, expected 200 got " .. c)
-	assert(r:find("hello from request scope"), "Didn't find expected text in response")
+    local r, c = http.get "/request-says-hi"
+    assert(200 == c, "incorrect status code returned, expected 200 got " .. c)
+    assert(r:find("hello from request scope"), "Didn't find expected text in response")
 end
 
 test:run()



Mime
View raw message