dbd/common.h

changeset 1
408291a6eb3e
child 2
c4f02fc67e5a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbd/common.h	Sun Nov 23 01:29:09 2008 +0000
@@ -0,0 +1,78 @@
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <lua.h>
+#include <lauxlib.h>
+#include <lualib.h>
+
+#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM < 501)
+#include <compat-5.1.h>
+#endif
+
+
+
+#define LUA_PUSH_ATTRIB_INT(n, v) \
+    lua_pushstring(L, n); \
+    lua_pushinteger(L, v); \
+    lua_rawset(L, -3); 
+
+#define LUA_PUSH_ATTRIB_FLOAT(n, v) \
+    lua_pushstring(L, n); \
+    lua_pushnumber(L, v); \
+    lua_rawset(L, -3); 
+
+#define LUA_PUSH_ATTRIB_STRING(n, v) \
+    lua_pushstring(L, n); \
+    lua_pushstring(L, v); \
+    lua_rawset(L, -3); 
+
+#define LUA_PUSH_ATTRIB_BOOL(n, v) \
+    lua_pushstring(L, n); \
+    lua_pushboolean(L, v); \
+    lua_rawset(L, -3); 
+
+#define LUA_PUSH_ATTRIB_NIL(n) \
+    lua_pushstring(L, n); \
+    lua_pushnil(L); \
+    lua_rawset(L, -3); 
+
+
+
+#define LUA_PUSH_ARRAY_INT(n, v) \
+    lua_pushinteger(L, v); \
+    lua_rawseti(L, -2, n); \
+    n++; 
+
+#define LUA_PUSH_ARRAY_FLOAT(n, v) \
+    lua_pushnumber(L, v); \
+    lua_rawseti(L, -2, n); \
+    n++; 
+
+#define LUA_PUSH_ARRAY_STRING(n, v) \
+    lua_pushstring(L, v); \
+    lua_rawseti(L, -2, n); \
+    n++;
+
+#define LUA_PUSH_ARRAY_BOOL(n, v) \
+    lua_pushboolean(L, v); \
+    lua_rawseti(L, -2, n); \
+    n++;
+
+#define LUA_PUSH_ARRAY_NIL(n) \
+    lua_pushnil(L); \
+    lua_rawseti(L, -2, n); \
+    n++;
+
+
+
+typedef enum lua_push_type {
+    LUA_PUSH_NIL = 0,
+    LUA_PUSH_INTEGER,
+    LUA_PUSH_NUMBER,
+    LUA_PUSH_STRING,
+    LUA_PUSH_BOOLEAN,
+
+    LUA_PUSH_MAX
+} lua_push_type_t;
+

mercurial