aboutsummaryrefslogtreecommitdiff
path: root/src/tools.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools.h')
-rw-r--r--src/tools.h27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/tools.h b/src/tools.h
index b8dc362..43582c5 100644
--- a/src/tools.h
+++ b/src/tools.h
@@ -4,16 +4,33 @@
4#ifndef TOOLS_H 4#ifndef TOOLS_H
5#define TOOLS_H 5#define TOOLS_H
6 6
7#include "lua.h" 7#include "lauxlib.h"
8#include "threading.h" 8#include "threading.h"
9 // MUTEX_T 9 // MUTEX_T
10 10
11#include <assert.h> 11#include <assert.h>
12 12
13// Note: The < LUA_REGISTRYINDEX test is to leave registry/global/upvalue indices untouched 13// M$ compiler doesn't support 'inline' keyword in C files...
14// 14#if defined( _MSC_VER)
15#define /*int*/ STACK_ABS(L,n) \ 15#define inline __inline
16 ( ((n) >= 0 || (n) <= LUA_REGISTRYINDEX) ? (n) : lua_gettop(L) +(n) +1 ) 16#endif
17
18// code is now using Lua 5.2 API
19// add Lua 5.2 API when building for Lua 5.1
20#if LUA_VERSION_NUM == 501
21#define lua_absindex( L, idx) (((idx) >= 0 || (idx) <= LUA_REGISTRYINDEX) ? (idx) : lua_gettop(L) + (idx) +1)
22#define lua_pushglobaltable(L) lua_pushvalue( L, LUA_GLOBALSINDEX)
23#define lua_setuservalue lua_setfenv
24#define lua_getuservalue lua_getfenv
25#define lua_rawlen lua_objlen
26#define luaG_registerlibfuncs( L, _funcs) luaL_register( L, NULL, _funcs)
27#endif // LUA_VERSION_NUM == 501
28
29// wrap Lua 5.2 calls under Lua 5.1 API when it is simpler that way
30#if LUA_VERSION_NUM == 502
31#define lua_equal( L, a, b) lua_compare( L, a, b, LUA_OPEQ)
32#define luaG_registerlibfuncs( L, _funcs) luaL_setfuncs( L, _funcs, 0)
33#endif // LUA_VERSION_NUM == 502
17 34
18#ifdef NDEBUG 35#ifdef NDEBUG
19 #define _ASSERT_L(lua,c) /*nothing*/ 36 #define _ASSERT_L(lua,c) /*nothing*/