|
1 | | -#![allow(unsafe_op_in_unsafe_fn, clippy::missing_safety_doc)] |
| 1 | +#![allow(unsafe_op_in_unsafe_fn, non_snake_case, clippy::missing_safety_doc)] |
2 | 2 |
|
3 | 3 | use std::os::raw::{c_char, c_int, c_long, c_void}; |
4 | 4 |
|
5 | 5 | unsafe extern "C" { |
6 | 6 | pub fn luaL_newstate() -> *mut c_void; |
| 7 | + |
| 8 | + #[cfg(not(feature = "lua55"))] |
7 | 9 | pub fn luaL_openlibs(state: *mut c_void); |
| 10 | + #[cfg(feature = "lua55")] |
| 11 | + pub fn luaL_openselectedlibs(state: *mut c_void, load: c_int, preload: c_int); |
| 12 | + |
8 | 13 | pub fn lua_getfield(state: *mut c_void, index: c_int, k: *const c_char); |
9 | 14 | pub fn lua_tolstring(state: *mut c_void, index: c_int, len: *mut c_long) -> *const c_char; |
10 | 15 | pub fn luaL_loadstring(state: *mut c_void, s: *const c_char) -> c_int; |
@@ -43,6 +48,11 @@ unsafe extern "C" { |
43 | 48 | pub fn lua_getglobal(state: *mut c_void, k: *const c_char) -> c_int; |
44 | 49 | } |
45 | 50 |
|
| 51 | +#[cfg(feature = "lua55")] |
| 52 | +pub unsafe fn luaL_openlibs(state: *mut c_void) { |
| 53 | + luaL_openselectedlibs(state, !0, 0); |
| 54 | +} |
| 55 | + |
46 | 56 | #[cfg(feature = "lua51")] |
47 | 57 | pub unsafe fn lua_getglobal(state: *mut c_void, k: *const c_char) { |
48 | 58 | lua_getfield(state, -10002 /* LUA_GLOBALSINDEX */, k); |
|
0 commit comments