1use crate::*;
2
3use core::mem;
4
5mod version {
7 include!(concat!(env!("OUT_DIR"), "/lua_version.rs"));
8}
9
10pub const LUA_VERSION_MAJOR: &str = version::VERSION_MAJOR;
11pub const LUA_VERSION_MINOR: &str = version::VERSION_MINOR;
12pub const LUA_VERSION_RELEASE: &str = version::VERSION_RELEASE;
13pub const LUA_VERSION_NUM: lua_Number = version::VERSION_NUM;
14pub const LUA_VERSION: &str = version::VERSION;
15pub const LUA_RELEASE: &str = version::RELEASE;
16pub const LUA_VERSUFFIX: &str = version::LUA_VERSUFFIX;
17
18cfg_if::cfg_if! {
20 if #[cfg(LUA_FLOAT_TYPE="LUA_FLOAT_FLOAT")] {
21 pub type lua_Number = libc::c_float;
22
23 pub const LUA_NUMBER_FRMLEN: &str = "";
24 pub const LUA_NUMBER_FMT: &str = "%.7g";
25 } else if #[cfg(LUA_FLOAT_TYPE="LUA_FLOAT_LONGDOUBLE")] {
26 compile_error!("LUA_FLOAT_LONGDOUBLE is not supported");
27 } else if #[cfg(LUA_FLOAT_TYPE="LUA_FLOAT_DOUBLE")] {
28 pub type lua_Number = libc::c_double;
29
30 pub const LUA_NUMBER_FRMLEN: &str = "";
31 pub const LUA_NUMBER_FMT: &str = "%.14g";
32 } else {
33 compile_error!("Lua numeric float type not defined");
34 }
35}
36
37cfg_if::cfg_if! {
39 if #[cfg(LUA_INT_TYPE="LUA_INT_INT")] {
40 pub type lua_Integer = libc::c_int;
41 pub type lua_Unsigned = libc::c_uint;
42 pub const LUA_INTEGER_FRMLEN: &str = "";
43
44 pub const LUA_INTEGER_FMT: &str = "%d";
45 } else if #[cfg(LUA_INT_TYPE="LUA_INT_LONG")] {
46 pub type lua_Integer = libc::c_long;
47 pub type lua_Unsigned = libc::c_ulong;
48 pub const LUA_INTEGER_FRMLEN: &str = "l";
49
50 pub const LUA_INTEGER_FMT: &str = "%ld";
51 } else if #[cfg(LUA_INT_TYPE="LUA_INT_LONGLONG")] {
52 pub type lua_Integer = libc::c_longlong;
53 pub type lua_Unsigned = libc::c_ulonglong;
54 pub const LUA_INTEGER_FRMLEN: &str = "ll";
55
56 pub const LUA_INTEGER_FMT: &str = "%ld";
57 } else {
58 compile_error!("Lua numeric integer type not defined");
59 }
60}
61
62cfg_if::cfg_if! {
64 if #[cfg(LUA_USE_C89)] {
65 pub type lua_KContext = libc::ptrdiff_t;
66 } else {
67 pub type lua_KContext = libc::intptr_t;
68 }
69}
70
71cfg_if::cfg_if! {
73 if #[cfg(LUA_FLOAT_TYPE="LUA_FLOAT_LONGDOUBLE")] {
74 pub const LUAL_BUFFERSIZE: usize = 8192;
75 } else {
76 pub const LUAL_BUFFERSIZE: usize =
77 0x80 * mem::size_of::<*const libc::c_void>() * mem::size_of::<lua_Integer>();
78 }
79}