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

Commit a63e2b0

Browse files
committed
Add even more functions
* lua_resume / lua_resume_real * lua_equal * lua_rawequal * lua_close * lua_rawget(i) * lua_rawset(i) Also added VERSION, RELEASE, COPYRIGHT, VERSION_NUM and AUTHORS to the lua namespace/module.
1 parent 9df8888 commit a63e2b0

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

src/globals.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ use crate::types::*;
33
pub mod Lua {
44
use super::CInt;
55

6+
pub static VERSION: &'static str = "Lua 5.1";
7+
pub static RELEASE: &'static str = "Lua 5.1.4";
8+
pub static VERSION_NUM: CInt = 501;
9+
pub static COPYRIGHT: &'static str = "Copyright (C) 1994-2008 Lua.org, PUC-Rio";
10+
pub static AUTHORS: &'static str = "R. Ierusalimschy, L. H. de Figueiredo & W. Celes";
11+
612
pub static REGISTRYINDEX: CInt = -10000;
713
pub static ENVIRONINDEX: CInt = -10000;
814
pub static GLOBALSINDEX: CInt = -10000;

src/lib.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ pub struct LuaSharedInterface {
3535
pub lua_setupvalue: extern fn(state: LuaState, fidx: CInt, idx: CInt) -> CharBuf,
3636
pub lua_setfenv: extern fn(state: LuaState, idx: CInt) -> CInt,
3737
pub lua_settable: extern fn(state: LuaState, idx: CInt),
38+
pub lua_rawset: extern fn(state: LuaState, idx: CInt), // lua_settable but no metamethods called
39+
pub lua_rawseti: extern fn(state: LuaState, idx: CInt, n: CInt), // t[n] = v
3840

3941
// Getters
4042
pub lua_gettable: extern fn(state: LuaState, idx: CInt),
43+
pub lua_rawget: extern fn(state: LuaState, idx: CInt), // lua_gettable but no metamethods called
44+
pub lua_rawgeti: extern fn(state: LuaState, idx: CInt, n: CInt), // lua_gettable but no metamethods called
45+
4146
pub lua_getfield: extern fn(state: LuaState, idx: CInt, key: CharBuf),
4247
pub lua_getupvalue: extern fn(state: LuaState, fidx: CInt, idx: CInt) -> CharBuf,
4348
pub lua_type: extern fn(state: LuaState, idx: CInt) -> CInt,
@@ -73,19 +78,26 @@ pub struct LuaSharedInterface {
7378
pub luaL_checkany: extern fn(state: LuaState, narg: CInt),
7479
pub luaL_checktype: extern fn(state: LuaState, narg: CInt, typeid: CInt),
7580
pub luaL_checkudata: extern fn(state: LuaState, narg: CInt, len: SizeT),
76-
pub luaL_argcheck: extern fn(state: LuaState, cond: CInt, narg: CInt, msg: CharBuf),
7781

7882
// Creation
7983
pub luaL_newstate: extern fn() -> LuaState,
8084
pub lua_createtable: extern fn(state: LuaState, narr: CInt, nrec: CInt),
8185

86+
// Destruction
87+
pub lua_close: extern fn(state: LuaState), // Destroys the lua state
88+
8289
// JIT
8390
// Returns 1 for success, 0 for failure
8491
pub luaJIT_setmode: extern fn(state: LuaState, idx: CInt, jit_mode: CInt) -> CInt,
8592

86-
// Coroutines / Yielding
93+
// Coroutines
8794
pub lua_yield: extern fn(state: LuaState, nresults: CInt) -> CInt,
8895
pub lua_status: extern fn(state: LuaState) -> CInt,
96+
pub lua_resume_real: extern fn(state: LuaState, narg: CInt) -> CInt,
97+
98+
// Comparison
99+
pub lua_equal: extern fn(state: LuaState, ind1: CInt, ind2: CInt) -> CInt, // Returns 1 or 0 bool
100+
pub lua_rawequal: extern fn(state: LuaState, ind1: CInt, ind2: CInt) -> CInt,
89101

90102
// Raising Errors
91103
pub luaL_typerror: extern fn(state: LuaState, narg: CInt, typename: CharBuf) -> CInt,
@@ -116,6 +128,9 @@ impl LuaSharedInterface {
116128
pub fn lua_tostring(&self, state: LuaState, idx: CInt) -> CharBuf {
117129
self.lua_tolstring(state, idx, 0)
118130
}
131+
pub fn lua_resume(&self, state: LuaState, narg: CInt) -> CInt {
132+
self.lua_resume_real(state, narg)
133+
}
119134
}
120135

121136
// Global Static Stuff

0 commit comments

Comments
 (0)