Allow opening jitlib in luajit-sys
This commit is contained in:
@@ -505,9 +505,11 @@ impl State {
|
||||
}
|
||||
|
||||
unsafe extern "C" fn open_cb(L: *mut lua_State) -> c_int {
|
||||
// SAFETY: we wrap luaL_openlibs so we can potentially catch any library open errors
|
||||
unsafe { luaL_openlibs(L) }
|
||||
0
|
||||
unsafe {
|
||||
luaL_openlibs(L);
|
||||
luaJIT_openlibs(L); // luajit-sys extension to open jitlibs
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new empty thread (coroutine) associated with this state.
|
||||
@@ -930,6 +932,21 @@ impl Stack {
|
||||
n
|
||||
}
|
||||
|
||||
/// Pushes the result of a Lua `require(...)` call onto the stack.
|
||||
///
|
||||
/// Any return values from the library `name` are pushed. Lua libraries are allowed to return
|
||||
/// multiple values. If `nret` is not [`LUA_MULTRET`], then the number of return values pushed
|
||||
/// will be exactly `nret`, filling with nils if necessary. The number values pushed to the
|
||||
/// stack is returned.
|
||||
///
|
||||
/// Equivalent to `require(name)`.
|
||||
pub fn require(&mut self, name: impl AsRef<[u8]>, nret: c_int) -> Result<c_int> {
|
||||
self.push("require");
|
||||
self.get(LUA_GLOBALSINDEX);
|
||||
self.push(name.as_ref());
|
||||
self.call(1, nret)
|
||||
}
|
||||
|
||||
/// Pushes the given chunk as a function at the top of the stack.
|
||||
///
|
||||
/// Equivalent to [`lua_loadx`].
|
||||
@@ -1039,8 +1056,8 @@ impl Stack {
|
||||
/// the index `top - narg` (i.e. the function is pushed first and then `narg` values as
|
||||
/// arguments). All arguments and the function are popped from the stack and then any return
|
||||
/// values are pushed. If `nret` is not [`LUA_MULTRET`], then the number of return values pushed
|
||||
/// will be exactly `nret`, filling with nils if necessary. Finally, the number of returned
|
||||
/// values pushed to the stack is returned.
|
||||
/// will be exactly `nret`, filling with nils if necessary. Finally, the number of values pushed
|
||||
/// to the stack is returned.
|
||||
///
|
||||
/// The current thread status must not be suspended or dead.
|
||||
///
|
||||
@@ -1096,8 +1113,8 @@ impl Stack {
|
||||
/// the index `top - narg` (i.e. the function is pushed first and then `narg` values as
|
||||
/// arguments). All arguments and the function are popped from the stack and then any return
|
||||
/// values are pushed. If `nret` is not [`LUA_MULTRET`], then the number of return values pushed
|
||||
/// will be exactly `nret`, filling with nils if necessary. Finally, the number of returned
|
||||
/// values pushed to the stack is returned.
|
||||
/// will be exactly `nret`, filling with nils if necessary. Finally, the number values pushed to
|
||||
/// the stack is returned.
|
||||
///
|
||||
/// If the thread yields a Rust [`Future`] value, then it will be polled to completion before
|
||||
/// the thread is resumed with the output of the [`Future`] as the argument. If the thread
|
||||
|
||||
Reference in New Issue
Block a user