Lua Utils
Biblioteca utilitária para facilitar a integração de Lua com C++
luaConfig.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2009 K2FS Sistemas e Projetos Ltd.
4 ** All rights reserved.
5 **
6 ************************************************************************/
7 
18 #ifndef _LUACONFIG_H_
19 #define _LUACONFIG_H_
20 
21 // Control exporting (when compiling the DLL) or importing symbols from
22 // the shared library
23 #include <QtCore/QtGlobal>
24 #include <lua.hpp>
25 
26 #ifdef LUAUTILS_LIB
27 #define LUAUTILS_API_EXPORT Q_DECL_EXPORT
28 #else
29 #define LUAUTILS_API_EXPORT Q_DECL_IMPORT
30 #endif
31 
32 
33 // Some compatibility definitions to allow compiling the library
34 // with Lua 5.1 or Lua 5.3
35 
36 #if LUA_VERSION_NUM == 503
37 
38 #define luacompat_len(L, pos) ((int)luaL_len((L), (pos)))
39 #define luacompat_register(L, tab) luaL_setfuncs(L, tab, 0)
40 #define luacompat_pushglobaltable(L) lua_pushglobaltable(L)
41 
42 #define luacompat_setfenv(L, pos) lua_setupvalue(L, pos, 1)
43 
44 #define luaL_checkint(L, pos) (int)luaL_checkinteger(L, pos)
45 #define luaL_optint(L, pos, d) (int)luaL_optinteger(L, pos, d)
46 
47 #define luaL_typerror(L, narg, msg) luaL_argerror(L, narg, lua_pushfstring(L, "%s expected, got %s", msg, luaL_typename(L, narg)))
48 
49 #elif LUA_VERSION_NUM == 502
50 
51 #define luacompat_len(L, pos) ((int)luaL_len((L), (pos)))
52 #define luacompat_register(L, tab) luaL_setfuncs(L, tab, 0)
53 #define luacompat_pushglobaltable(L) lua_pushglobaltable(L)
54 
55 #define luacompat_setfenv(L, pos) lua_setupvalue(L, pos, 1)
56 
57 #define luaL_typerror(L, narg, msg) luaL_argerror(L, narg, lua_pushfstring(L, "%s expected, got %s", msg, luaL_typename(L, narg)))
58 
59 #elif LUA_VERSION_NUM == 501
60 
61 #define luacompat_len(L, pos) ((int)lua_objlen(L, pos))
62 #define luacompat_register(L, tab) luaL_register(L, NULL, tab)
63 #define luacompat_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX)
64 #define luacompat_setfenv(L, pos) lua_setfenv(L, pos)
65 
66 #else
67 #error "Unknown Lua version"
68 #endif
69 
70 
71 #endif
72 
73