Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit 8fae2a0

Browse files
committed
1.0.0
* Use $crate instead of rglua in macros * Add variadic support to dyn_symbols (In turn re-adds luaL_error and pushfstring * Add lua_getinfo * Add lua_next * Add lua_replace * Add lua_lessthan * Add lua_gc * Add rest of the functions we were missing * Add lua_objlen Types are now T* instead of Type::*. Same with prior enums. Deprecated old ones * Added LuaDebug * Added LuaAlloc * Added LuaHook * Added LuaReader * Removed redundant Interface trait, vtables already adds a function to get a ptr. I'm not gonna work on this for a while this is getting tiring. Near the completion of the library (in terms of the lua part.)
1 parent 1300660 commit 8fae2a0

File tree

7 files changed

+363
-58
lines changed

7 files changed

+363
-58
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ Here's a comparison and why you could use this one.
2323
[gmod-rs]: https://crates.io/crates/gmod
2424
[gmrs]: https://github.com/diogo464/gmrs
2525

26-
| Library | [rglua] | [rust-glua-sys] | [gmod-rs] | [gmrs] |
27-
|-----------------------------------|---------|-----------------|------------|--------|
28-
| Lua C Api Bindings | ✔️ | ✔️ | ✔️ ||
29-
| Crates.io | ✔️ || ✔️ ||
26+
| Library | [rglua] | [rust-glua-sys] | [gmod-rs] | [gmrs] |
27+
|-----------------------------------|---------|-----------------|-------------|--------|
28+
| *Full* Lua C Api Bindings | ✔️ | * | ||
29+
| On Crates.io | ✔️ || ✔️ ||
3030
| Proc Macros | ✔️ || ✔️ | ✔️ |
3131
| Interfacing w/ Source SDK | ✔️ ||||
3232
| Returning Result<> from functions | ✔️ ||| ✔️ |
3333
| Can be used on stable | ✔️ | ✔️ || ✔️ |
3434
| Real world examples | ✔️ || ✔️ ||
3535
| Github Stars | 😢 | 👍 | 👑 | 🤷‍♂️ |
3636

37+
\* They technically do, but they depend on autogenerated bindings which is inaccurate for gmod, leading to missing functions. (See lua_resume_real)
38+
3739
__*You can help with that last one 😉*__

rglua/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rglua"
33
description = "Toolkit for garrysmod development with the source sdk and luajit api"
4-
version = "0.9.0"
4+
version = "1.0.0"
55
authors = ["Vurv <[email protected]>"]
66
keywords = ["glua", "garrysmod", "lua", "gmod"]
77
categories = ["api-bindings", "external-ffi-bindings", "development-tools::ffi", "game-development", "accessibility"]

rglua/src/interface/mod.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ pub(crate) mod prelude {
2222
$vis struct $iface {
2323
pub vtable: usize
2424
}
25-
impl crate::interface::Interface for $iface {
26-
unsafe fn get_raw(&self, offset: isize) -> *mut std::ffi::c_void {
27-
(self.vtable as *mut *mut std::ffi::c_void).offset(offset).read()
28-
}
29-
}
3025
iface!( $($rest)* );
3126
};
3227
() => ();
@@ -134,14 +129,3 @@ pub fn get_from_interface(
134129
Err(InterfaceError::FactoryNotFound)
135130
}
136131
}
137-
138-
pub trait Interface {
139-
/// Retrieves a pointer to a function in the interface from the given offset.
140-
/// # Arguments
141-
/// * `offset` - offset of the function in the interface. E.g. `41` for PaintTraverse
142-
/// # Examples
143-
/// Todo!
144-
/// # Safety
145-
/// This is unsafe as it reads raw memory from the vtable. Might want to make sure it's valid
146-
unsafe fn get_raw(&self, offset: isize) -> *mut c_void;
147-
}

rglua/src/lua/globals.rs

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(non_snake_case)]
2-
31
use crate::types::*;
42

53
/// Index of the lua registry. What you'd get from debug.getregistry()
@@ -16,6 +14,55 @@ pub const MULTRET: c_int = -1;
1614
pub const NUMTYPES: c_int = 9;
1715
pub const NUMTAGS: c_int = NUMTYPES;
1816

17+
pub const TNONE: c_int = -1;
18+
pub const TNIL: c_int = 0;
19+
pub const TBOOLEAN: c_int = 1;
20+
pub const TLIGHTUSERDATA: c_int = 2;
21+
pub const TNUMBER: c_int = 3;
22+
pub const TSTRING: c_int = 4;
23+
pub const TTABLE: c_int = 5;
24+
pub const TFUNCTION: c_int = 6;
25+
pub const TUSERDATA: c_int = 7;
26+
pub const TTHREAD: c_int = 8;
27+
28+
pub const MINSTACK: c_int = 20;
29+
30+
pub const OK: c_int = 0;
31+
pub const YIELD: c_int = 1;
32+
pub const ERRRUN: c_int = 2;
33+
pub const ERRSYNTAX: c_int = 3;
34+
pub const ERRMEM: c_int = 4;
35+
pub const ERRERR: c_int = 5;
36+
37+
pub const GCSTOP: c_int = 0;
38+
pub const GCRESTART: c_int = 1;
39+
pub const GCCOLLECT: c_int = 2;
40+
pub const GCCOUNT: c_int = 3;
41+
pub const GCCOUNTB: c_int = 4;
42+
pub const GCSTEP: c_int = 5;
43+
pub const GCSETPAUSE: c_int = 6;
44+
pub const GCSETSTEPMUL: c_int = 7;
45+
46+
pub const HOOKCALL: c_int = 0;
47+
pub const HOOKRET: c_int = 1;
48+
pub const HOOKLINE: c_int = 2;
49+
pub const HOOKCOUNT: c_int = 3;
50+
pub const HOOKTAILRET: c_int = 4;
51+
52+
pub const MASKCALL: c_int = 1 << HOOKCALL;
53+
pub const MASKRET: c_int = 1 << HOOKRET;
54+
pub const MASKLINE: c_int = 1 << HOOKLINE;
55+
pub const MASKCOUNT: c_int = 1 << HOOKCOUNT;
56+
57+
/// Size of LuaDebug.short_src
58+
pub const IDSIZE: usize = 128;
59+
60+
// This is libc's default so we'll roll with it
61+
pub const BUFFERSIZE: usize = 8192;
62+
63+
// Rust doesn't work well with C Enums. So I'm just going to ditch the idea.
64+
#[deprecated(since = "0.9.1", note = "Use rglua::lua::T* instead")]
65+
#[allow(non_snake_case)]
1966
pub mod Type {
2067
#![allow(non_upper_case_globals)]
2168

@@ -32,6 +79,7 @@ pub mod Type {
3279
}
3380

3481
#[repr(i32)]
82+
#[deprecated(since = "0.9.1", note = "Use rglua::lua::T* instead")]
3583
pub enum Status {
3684
Ok = 0,
3785
Yield,
@@ -42,6 +90,8 @@ pub enum Status {
4290
}
4391

4492
// Garbage collection
93+
#[repr(i32)]
94+
#[deprecated(since = "0.9.1", note = "Use rglua::lua::T* instead")]
4595
pub enum Gc {
4696
Stop = 0,
4797
Restart,
@@ -57,6 +107,7 @@ pub enum Gc {
57107
}
58108

59109
// To be used with debug.sethook
110+
#[deprecated(since = "0.9.1", note = "Use rglua::lua::T* instead")]
60111
pub enum Hook {
61112
Call = 0,
62113
Ret,
@@ -65,15 +116,41 @@ pub enum Hook {
65116
TailCall,
66117
}
67118

119+
#[deprecated(since = "0.9.1", note = "Use rglua::lua::T* instead")]
68120
pub enum Mask {
121+
#[allow(deprecated)]
69122
Call = (1 << Hook::Call as i32),
123+
#[allow(deprecated)]
70124
Ret = (1 << Hook::Ret as i32),
125+
#[allow(deprecated)]
71126
Line = (1 << Hook::Line as i32),
127+
#[allow(deprecated)]
72128
Count = (1 << Hook::Count as i32),
73129
}
74130

75-
pub mod Jit {
131+
pub mod jit {
132+
use super::c_int;
133+
134+
pub const VERSION: &str = "LuaJIT 2.0.4";
135+
pub const VERSION_NUM: c_int = 20004; /* Version 2.0.4 = 02.00.04. */
136+
137+
pub const MODE_MASK: c_int = 0x00ff;
138+
139+
pub const MODE_ENGINE: c_int = 1; /* Set mode for whole JIT engine. */
140+
pub const MODE_DEBUG: c_int = 2; /* Set debug mode (idx = level). */
141+
pub const MODE_FUNC: c_int = 3; /* Change mode for a function. */
142+
pub const MODE_ALLFUNC: c_int = 4; /* Recurse into subroutine protos. */
143+
pub const MODE_ALLSUBFUNC: c_int = 5; /* Change only the subroutines. */
144+
pub const MODE_TRACE: c_int = 6; /* Flush a compiled trace. */
145+
pub const MODE_WRAPCFUNC: c_int = 0x10; /* Set wrapper mode for C function calls. */
146+
pub const MODE_MAX: c_int = MODE_WRAPCFUNC + 1;
147+
148+
pub const MODE_OFF: c_int = 0x0000; /* Turn feature off. */
149+
pub const MODE_ON: c_int = 0x0100; /* Turn feature on. */
150+
pub const MODE_FLUSH: c_int = 0x0200; /* Flush JIT-compiled code. */
151+
76152
#[repr(i32)]
153+
#[deprecated(since = "0.9.1", note = "Use rglua::lua::T* instead")]
77154
pub enum Mode {
78155
ENGINE,
79156
DEBUG,
@@ -86,7 +163,8 @@ pub mod Jit {
86163
MASK = 0x0ff, // LUAJIT_MODE_MASK
87164
}
88165

89-
use super::c_int;
166+
#[deprecated(since = "0.9.1", note = "Use rglua::lua::T* instead")]
167+
#[allow(deprecated)]
90168
// Associated Constants, woah
91169
impl Mode {
92170
pub const OFF: c_int = 0x0000;

0 commit comments

Comments
 (0)