Debian Codegraph @

podofo/tools/podofocolor/lua_compat.h

raw
1 #ifndef LUA_COMPAT_H_COLOR
2 #define LUA_COMPAT_H_COLOR
3
4 extern "C" {
5 #include "lua.h"
6 // Note: If you're missing these, you're using lua 5.0 and haven't installed
7 // the extension libraries.
8 #include "lualib.h"
9 #include "lauxlib.h"
10 }
11
12 #if !defined(LUA_VERSION_NUM)
13 // Old lua without numeric version
14 #define LUA_VERSION_NUM 0
15 #endif
16
17 // Handle an API difference in the lua_open call between
18 // Lua 5.1 and Lua 5.2.
19 #if LUA_VERSION_NUM >= 502
20 inline lua_State* imp_lua_open(void) {
21 return luaL_newstate();
22 }
23 inline size_t imp_lua_objlen(lua_State *L, int index) {
24 return lua_rawlen(L, index);
25 }
26 #else
27 inline lua_State* imp_lua_open(void) {
28 return lua_open();
29 }
30 inline size_t imp_lua_objlen(lua_State *L, int index) {
31 return lua_objlen(L, index);
32 }
33 #endif
34
35 // Handle an API difference in the dofile and getn calls between
36 // Lua 5.0 and Lua 5.1.
37 #if LUA_VERSION_NUM >= 501
38 inline int imp_lua_dofile(lua_State* L, const char * path) {
39 return luaL_dofile(L, path);
40 }
41 inline int imp_lua_getn(lua_State *L, int t) {
42 return imp_lua_objlen(L, t);
43 }
44 #else
45 inline int imp_lua_dofile(lua_State* L, const char * path) {
46 return lua_dofile(L, path);
47 }
48 inline int imp_lua_getn(lua_State *L, int t) {
49 return luaL_getn(L, t);
50 }
51 #endif
52
53 #endif // LUA_COMPAT_H_COLOR