summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/clua.cc25
-rw-r--r--crawl-ref/source/clua.h4
-rw-r--r--crawl-ref/source/cluautil.cc23
-rw-r--r--crawl-ref/source/cluautil.h12
4 files changed, 34 insertions, 30 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc
index 5c15de7389..334b481319 100644
--- a/crawl-ref/source/clua.cc
+++ b/crawl-ref/source/clua.cc
@@ -653,31 +653,6 @@ void CLua::remove_shutdown_listener(lua_shutdown_listener *listener)
shutdown_listeners.erase(i);
}
-/////////////////////////////////////////////////////////////////////
-
-void clua_register_metatable(lua_State *ls, const char *tn,
- const luaL_reg *lr,
- int (*gcfn)(lua_State *ls))
-{
- lua_stack_cleaner clean(ls);
- luaL_newmetatable(ls, tn);
- lua_pushstring(ls, "__index");
- lua_pushvalue(ls, -2);
- lua_settable(ls, -3);
-
- if (gcfn)
- {
- lua_pushstring(ls, "__gc");
- lua_pushcfunction(ls, gcfn);
- lua_settable(ls, -3);
- }
-
- if (lr)
- {
- luaL_openlib(ls, NULL, lr, 0);
- }
-}
-
////////////////////////////////////////////////////////////////////////
// lua_text_pattern
diff --git a/crawl-ref/source/clua.h b/crawl-ref/source/clua.h
index ed35813dd5..daca3922aa 100644
--- a/crawl-ref/source/clua.h
+++ b/crawl-ref/source/clua.h
@@ -298,10 +298,6 @@ template <class T> T *clua_new_userdata(
return static_cast<T*>( udata );
}
-void clua_register_metatable(lua_State *ls, const char *tn,
- const luaL_reg *lr,
- int (*gcfn)(lua_State *ls) = NULL);
-
void print_clua_stack();
#endif
diff --git a/crawl-ref/source/cluautil.cc b/crawl-ref/source/cluautil.cc
index 13f5ab7267..fe0ba1cd93 100644
--- a/crawl-ref/source/cluautil.cc
+++ b/crawl-ref/source/cluautil.cc
@@ -75,3 +75,26 @@ void luaopen_setmeta(lua_State *ls,
lua_pushvalue(ls, -2);
lua_settable(ls, -3);
}
+
+void clua_register_metatable(lua_State *ls, const char *tn,
+ const luaL_reg *lr,
+ int (*gcfn)(lua_State *ls))
+{
+ lua_stack_cleaner clean(ls);
+ luaL_newmetatable(ls, tn);
+ lua_pushstring(ls, "__index");
+ lua_pushvalue(ls, -2);
+ lua_settable(ls, -3);
+
+ if (gcfn)
+ {
+ lua_pushstring(ls, "__gc");
+ lua_pushcfunction(ls, gcfn);
+ lua_settable(ls, -3);
+ }
+
+ if (lr)
+ {
+ luaL_openlib(ls, NULL, lr, 0);
+ }
+}
diff --git a/crawl-ref/source/cluautil.h b/crawl-ref/source/cluautil.h
index 1af4d76485..02e5180d7c 100644
--- a/crawl-ref/source/cluautil.h
+++ b/crawl-ref/source/cluautil.h
@@ -6,21 +6,31 @@
#ifndef CLUAUTIL_H
#define CLUAUTIL_H
+extern "C" {
+#include <lua.h>
+#include <lauxlib.h>
+#include <lualib.h>
+}
+
/*
* Function definitions.
*/
#define LUAFN(name) static int name(lua_State *ls)
+// FIXME: remove one of these.
void luaopen_setmeta(lua_State *ls,
const char *global,
const luaL_reg *lua_lib,
const char *meta);
+void clua_register_metatable(lua_State *ls, const char *tn,
+ const luaL_reg *lr,
+ int (*gcfn)(lua_State *ls) = NULL);
+
/*
* Passing objects from and to Lua.
*/
-struct lua_State;
struct activity_interrupt_data;
int push_activity_interrupt(lua_State *ls, activity_interrupt_data *t);