pub use std::os::raw::{c_char, c_int, c_void};
pub type LuaString = *const c_char; pub type SizeT = usize;
pub type LuaNumber = f64;
pub type LuaInteger = isize;
pub type LuaState = *mut c_void;
pub type LuaCFunction = extern "C" fn(LuaState) -> c_int;
pub type LuaHook = extern "C" fn(LuaState, *mut LuaDebug) -> c_int;
pub type LuaAlloc =
extern "C" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void;
pub type LuaReader = extern "C" fn(LuaState, ud: *mut c_void, sz: *mut SizeT) -> *const u8;
pub type LuaWriter = extern "C" fn(LuaState, p: *const c_void, sz: SizeT, ud: *mut c_void) -> c_int;
#[repr(C)]
pub struct LuaReg {
pub name: *const i8, pub func: Option<LuaCFunction>
}
pub type LuaJITProfileCallback =
extern "C" fn(data: *mut c_void, l: LuaState, samples: c_int, vmL: c_int) -> ();
#[repr(C)]
pub struct LuaBuffer {
pub b: *mut i8,
pub size: SizeT,
pub n: SizeT, pub state: LuaState,
pub initbuffer: [i8; crate::lua::BUFFERSIZE]
}
#[derive(Debug, Clone)]
#[repr(C)]
pub struct LuaDebug {
pub event: c_int,
pub name: LuaString, pub namewhat: LuaString,
pub what: LuaString,
pub source: LuaString,
pub currentline: c_int,
pub nups: c_int,
pub linedefined: c_int,
pub lastlinedefined: c_int,
pub short_src: [c_char; crate::lua::IDSIZE],
pub i_ci: c_int
}
impl Default for LuaDebug {
fn default() -> Self {
Self {
name: std::ptr::null(),
namewhat: std::ptr::null(),
what: std::ptr::null(),
source: std::ptr::null(),
event: Default::default(),
currentline: Default::default(),
nups: Default::default(),
linedefined: Default::default(),
lastlinedefined: Default::default(),
short_src: [0; 128],
i_ci: Default::default()
}
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub enum LuaType {
None = -1,
Nil = 0,
Bool,
LightUserdata,
Number,
String,
Table,
Function,
Userdata,
Thread,
Entity,
Vector,
Angle,
PhysObj,
Save,
Restore,
DamageInfo,
EffectData,
MoveData,
RecipientFilter,
UserCmd,
#[deprecated = "Leftover from gmod13 beta"]
ScriptedVehicle,
Material,
Panel,
Particle,
ParticleEmitter,
Texture,
UserMsg,
ConVar,
IMesh,
Matrix,
Sound,
PixelVisHandle,
DLight,
Video,
File,
Locomotion,
Path,
NavArea,
SoundHandle,
NavLadder,
ParticleSystem,
ProjectedTexture,
PhysCollide,
SurfaceInfo,
Count
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct Userdata {
pub data: *mut c_void,
pub typ: LuaType
}