Skip to content

Commit 6179efe

Browse files
committed
feat(lua_ffi): add raw table access function bindings
Adding: - lua_rawget - lua_rawgeti - lua_rawset - lua_rawseti
1 parent 386b5b6 commit 6179efe

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

hlua/ffi/src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,17 @@ extern "C" {
233233
/// "index" event
234234
pub fn lua_gettable(l: *mut lua_State, index: c_int);
235235

236+
/// Similar to [`lua_gettable`], but does a raw access (i.e., without
237+
/// metamethods).
238+
/// *[-1, +1, -]*
239+
pub fn lua_rawget(l: *mut lua_State, index: c_int);
240+
241+
/// Pushes onto the stack the value `t[n]`, where `t` is the value at the
242+
/// given valid `index`. The access is *raw*; that is, it does not invoke
243+
/// metamethods.
244+
/// *[-0, +1, -]*
245+
pub fn lua_rawgeti(l: *mut lua_State, index: c_int, n: c_int);
246+
236247
/// Does the equivalent to `t[k] = v`, where `t` is the value at the given
237248
/// valid `index`, `v` is the value at the top of the stack, and `k` is the
238249
/// value just below the top.
@@ -242,6 +253,19 @@ extern "C" {
242253
/// this function may trigger a metamethod for the "newindex" event.
243254
pub fn lua_settable(l: *mut lua_State, index: c_int);
244255

256+
/// Similar to [`lua_settable`], but does a raw assignment (i.e., without
257+
/// metamethods).
258+
/// *[-2, +0, m]*
259+
pub fn lua_rawset(l: *mut lua_State, index: c_int);
260+
261+
/// Does the equivalent of `t[n] = v`, where `t` is the value at the given
262+
/// valid `index` and `v` is the value at the top of the stack.
263+
/// *[-1, +0, m]*
264+
///
265+
/// This function pops the value from the stack. The assignment is raw; that
266+
/// is, it does not invoke metamethods.
267+
pub fn lua_rawseti(l: *mut lua_State, index: c_int, n: c_int);
268+
245269
/// Returns the type of the value in the given acceptable `index`, or
246270
/// [`LUA_TNONE`] for a non-valid index (that is, an index to an "empty"
247271
/// stack position). The types returned by lua_type are coded by the

0 commit comments

Comments
 (0)