Skip to main content

mlua_sys/lua55/
lualib.rs

1//! Contains definitions from `lualib.h`.
2
3use std::os::raw::{c_char, c_int};
4
5use super::lua::lua_State;
6
7pub const LUA_GLIBK: c_int = 1;
8
9pub const LUA_LOADLIBNAME: *const c_char = cstr!("package");
10pub const LUA_LOADLIBK: c_int = LUA_GLIBK << 1;
11
12pub const LUA_COLIBNAME: *const c_char = cstr!("coroutine");
13pub const LUA_COLIBK: c_int = LUA_GLIBK << 2;
14
15pub const LUA_DBLIBNAME: *const c_char = cstr!("debug");
16pub const LUA_DBLIBK: c_int = LUA_GLIBK << 3;
17
18pub const LUA_IOLIBNAME: *const c_char = cstr!("io");
19pub const LUA_IOLIBK: c_int = LUA_GLIBK << 4;
20
21pub const LUA_MATHLIBNAME: *const c_char = cstr!("math");
22pub const LUA_MATHLIBK: c_int = LUA_GLIBK << 5;
23
24pub const LUA_OSLIBNAME: *const c_char = cstr!("os");
25pub const LUA_OSLIBK: c_int = LUA_GLIBK << 6;
26
27pub const LUA_STRLIBNAME: *const c_char = cstr!("string");
28pub const LUA_STRLIBK: c_int = LUA_GLIBK << 7;
29
30pub const LUA_TABLIBNAME: *const c_char = cstr!("table");
31pub const LUA_TABLIBK: c_int = LUA_GLIBK << 8;
32
33pub const LUA_UTF8LIBNAME: *const c_char = cstr!("utf8");
34pub const LUA_UTF8LIBK: c_int = LUA_GLIBK << 9;
35
36#[cfg_attr(all(windows, raw_dylib), link(name = "lua55", kind = "raw-dylib"))]
37unsafe extern "C-unwind" {
38    pub fn luaopen_base(L: *mut lua_State) -> c_int;
39    pub fn luaopen_package(L: *mut lua_State) -> c_int;
40    pub fn luaopen_coroutine(L: *mut lua_State) -> c_int;
41    pub fn luaopen_debug(L: *mut lua_State) -> c_int;
42    pub fn luaopen_io(L: *mut lua_State) -> c_int;
43    pub fn luaopen_math(L: *mut lua_State) -> c_int;
44    pub fn luaopen_os(L: *mut lua_State) -> c_int;
45    pub fn luaopen_string(L: *mut lua_State) -> c_int;
46    pub fn luaopen_table(L: *mut lua_State) -> c_int;
47    pub fn luaopen_utf8(L: *mut lua_State) -> c_int;
48
49    // open all builtin libraries
50    pub fn luaL_openselectedlibs(L: *mut lua_State, load: c_int, preload: c_int);
51}
52
53pub unsafe fn luaL_openlibs(L: *mut lua_State) {
54    luaL_openselectedlibs(L, !0, 0);
55}