1 | // Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
|
---|
2 | // http://chaosforge.org/
|
---|
3 | //
|
---|
4 | // This file is part of NV Libraries.
|
---|
5 | // For conditions of distribution and use, see copyright notice in nv.hh
|
---|
6 |
|
---|
7 | #include "nv/lib/lua.hh"
|
---|
8 |
|
---|
9 | #if defined( NV_LUA_DYNAMIC )
|
---|
10 |
|
---|
11 | #include "nv/library.hh"
|
---|
12 |
|
---|
13 | #if NV_LUA_VERSION == NV_LUA_52
|
---|
14 | # undef luaL_loadfile
|
---|
15 | # undef luaL_loadbuffer
|
---|
16 | # undef luaL_prepbuffer
|
---|
17 | # undef lua_tonumber
|
---|
18 | # undef lua_tointeger
|
---|
19 | # undef lua_tounsigned
|
---|
20 | # undef lua_call
|
---|
21 | # undef lua_pcall
|
---|
22 | # undef lua_yield
|
---|
23 | #endif
|
---|
24 |
|
---|
25 | #define NV_LUA_FUN( rtype, fname, fparams ) rtype (*fname) fparams = nullptr;
|
---|
26 | #if NV_LUA_VERSION == NV_LUA_52
|
---|
27 | # define NV_LUA_FUN_51( rtype, fname, fparams )
|
---|
28 | # define NV_LUA_FUN_52 NV_LUA_FUN
|
---|
29 | #else
|
---|
30 | # define NV_LUA_FUN_51 NV_LUA_FUN
|
---|
31 | # define NV_LUA_FUN_52( rtype, fname, fparams )
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include <nv/lib/detail/lua_functions.inc>
|
---|
35 |
|
---|
36 | #undef NV_LUA_FUN
|
---|
37 | #undef NV_LUA_FUN_51
|
---|
38 | #undef NV_LUA_FUN_52
|
---|
39 |
|
---|
40 | bool nv::load_lua_library( const char* path )
|
---|
41 | {
|
---|
42 | static nv::library lua_library;
|
---|
43 | if ( lua_library.is_open() ) return true;
|
---|
44 | lua_library.open( path );
|
---|
45 |
|
---|
46 | # define NV_LUA_FUN( rtype, fname, fparams ) *(void **) (&fname) = lua_library.get(#fname);
|
---|
47 | # if NV_LUA_VERSION == NV_LUA_52
|
---|
48 | # define NV_LUA_FUN_51( rtype, fname, fparams )
|
---|
49 | # define NV_LUA_FUN_52 NV_LUA_FUN
|
---|
50 | # else
|
---|
51 | # define NV_LUA_FUN_51 NV_LUA_FUN
|
---|
52 | # define NV_LUA_FUN_52( rtype, fname, fparams )
|
---|
53 | # endif
|
---|
54 |
|
---|
55 | #include <nv/lib/detail/lua_functions.inc>
|
---|
56 |
|
---|
57 | #undef NV_LUA_FUN
|
---|
58 | #undef NV_LUA_FUN_51
|
---|
59 | #undef NV_LUA_FUN_52
|
---|
60 | return true;
|
---|
61 | }
|
---|
62 |
|
---|
63 | #endif
|
---|