diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-06-23 19:58:45 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-06-23 19:58:45 +0000 |
commit | 32ba97b96685241b1e30299f313c15d20d103998 (patch) | |
tree | 8ab81f56171f4a2f179f24db66d4794f9908770d /crawl-ref/source/clua.h | |
parent | d09478f5fd2fbbc23a3d0785d201ab7e7c8e2d8f (diff) | |
download | crawl-ref-32ba97b96685241b1e30299f313c15d20d103998.tar.gz crawl-ref-32ba97b96685241b1e30299f313c15d20d103998.zip |
Step 1 of .des file Lua-isation. The dungeon compiler converts .des files to
Lua (Lua code can be embedded with {{ <lua code here> }} constructs) that is
run to produce the final map.
Some maps may be broken, this is untested, lots more work needs to be done.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1629 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/clua.h')
-rw-r--r-- | crawl-ref/source/clua.h | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/crawl-ref/source/clua.h b/crawl-ref/source/clua.h index 0ec9723544..6759687494 100644 --- a/crawl-ref/source/clua.h +++ b/crawl-ref/source/clua.h @@ -41,7 +41,7 @@ private: class CLua { public: - CLua(bool managed); + CLua(bool managed = true); ~CLua(); lua_State *state(); @@ -63,6 +63,7 @@ public: void setregistry(const char *name); void getregistry(const char *name); + int loadstring(const char *str, const char *context); int execstring(const char *str, const char *context = "init.txt"); int execfile(const char *filename, bool trusted = false); @@ -161,4 +162,48 @@ extern CLua clua; void lua_set_exclusive_item(const item_def *item = NULL); +#define LUAWRAP(name, wrapexpr) \ + static int name(lua_State *ls) \ + { \ + wrapexpr; \ + return (0); \ + } + +#define PLUARET(type, val) \ + lua_push##type(ls, val); \ + return (1); + +#define LUARET1(name, type, val) \ + static int name(lua_State *ls) \ + { \ + lua_push##type(ls, val); \ + return (1); \ + } + +#define LUARET2(name, type, val1, val2) \ + static int name(lua_State *ls) \ + { \ + lua_push##type(ls, val1); \ + lua_push##type(ls, val2); \ + return (2); \ + } + +template <class T> +inline static T *util_get_userdata(lua_State *ls, int ndx) +{ + return (lua_islightuserdata(ls, ndx))? + static_cast<T *>( lua_touserdata(ls, ndx) ) + : NULL; +} + +template <class T> +inline static T *clua_get_userdata(lua_State *ls, const char *mt) +{ + return static_cast<T*>( luaL_checkudata( ls, 1, mt ) ); +} + +std::string quote_lua_string(const std::string &s); + +#define MAP_METATABLE "dgn.mtmap" + #endif |