[5] | 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 |
|
---|
[164] | 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
|
---|
[5] | 24 |
|
---|
[164] | 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
|
---|
[5] | 33 |
|
---|
[164] | 34 | #include <nv/lib/detail/lua_functions.inc>
|
---|
[5] | 35 |
|
---|
[164] | 36 | #undef NV_LUA_FUN
|
---|
| 37 | #undef NV_LUA_FUN_51
|
---|
| 38 | #undef NV_LUA_FUN_52
|
---|
[5] | 39 |
|
---|
| 40 | bool nv::load_lua_library( const char* path )
|
---|
| 41 | {
|
---|
[109] | 42 | static nv::library lua_library;
|
---|
| 43 | if ( lua_library.is_open() ) return true;
|
---|
| 44 | lua_library.open( path );
|
---|
[5] | 45 |
|
---|
[164] | 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
|
---|
[109] | 54 |
|
---|
[164] | 55 | #include <nv/lib/detail/lua_functions.inc>
|
---|
[5] | 56 |
|
---|
[164] | 57 | #undef NV_LUA_FUN
|
---|
| 58 | #undef NV_LUA_FUN_51
|
---|
| 59 | #undef NV_LUA_FUN_52
|
---|
[5] | 60 | return true;
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | #endif
|
---|