[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
|
---|
[165] | 29 | #elif NV_LUA_VERSION == NV_LUA_51
|
---|
| 30 | # define NV_LUA_FUN_51 NV_LUA_FUN
|
---|
| 31 | # define NV_LUA_FUN_52( rtype, fname, fparams )
|
---|
[164] | 32 | #else
|
---|
[165] | 33 | # define NV_LUA_FUN_51( rtype, fname, fparams )
|
---|
| 34 | # define NV_LUA_FUN_52( rtype, fname, fparams )
|
---|
[164] | 35 | #endif
|
---|
[5] | 36 |
|
---|
[164] | 37 | #include <nv/lib/detail/lua_functions.inc>
|
---|
[5] | 38 |
|
---|
[164] | 39 | #undef NV_LUA_FUN
|
---|
| 40 | #undef NV_LUA_FUN_51
|
---|
| 41 | #undef NV_LUA_FUN_52
|
---|
[5] | 42 |
|
---|
| 43 | bool nv::load_lua_library( const char* path )
|
---|
| 44 | {
|
---|
[109] | 45 | static nv::library lua_library;
|
---|
| 46 | if ( lua_library.is_open() ) return true;
|
---|
| 47 | lua_library.open( path );
|
---|
[5] | 48 |
|
---|
[164] | 49 | # define NV_LUA_FUN( rtype, fname, fparams ) *(void **) (&fname) = lua_library.get(#fname);
|
---|
| 50 | # if NV_LUA_VERSION == NV_LUA_52
|
---|
| 51 | # define NV_LUA_FUN_51( rtype, fname, fparams )
|
---|
| 52 | # define NV_LUA_FUN_52 NV_LUA_FUN
|
---|
[165] | 53 | # elif NV_LUA_VERSION == NV_LUA_51
|
---|
[164] | 54 | # define NV_LUA_FUN_51 NV_LUA_FUN
|
---|
| 55 | # define NV_LUA_FUN_52( rtype, fname, fparams )
|
---|
[165] | 56 | # else
|
---|
| 57 | # define NV_LUA_FUN_51( rtype, fname, fparams )
|
---|
| 58 | # define NV_LUA_FUN_52( rtype, fname, fparams )
|
---|
[164] | 59 | # endif
|
---|
[109] | 60 |
|
---|
[165] | 61 | # include <nv/lib/detail/lua_functions.inc>
|
---|
[5] | 62 |
|
---|
[165] | 63 | # undef NV_LUA_FUN
|
---|
| 64 | # undef NV_LUA_FUN_51
|
---|
| 65 | # undef NV_LUA_FUN_52
|
---|
[5] | 66 | return true;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | #endif
|
---|