A set of modding tools for the newest generation of the Bitsquid game engine that powers the game Warhammer 40.000: Darktide.
Find a file
2023-03-28 20:49:15 +02:00
.cargo Add link args for x86_64-apple-darwin 2019-08-15 22:27:12 -04:00
ci The bash task in azure seems to find powershells find 2020-01-19 01:04:51 -05:00
etc Disable MACOSX_DEPLOYMENT_TARGET 2019-08-15 21:46:56 -04:00
examples Rename to luajit2-sys 2020-01-19 01:31:24 -05:00
luajit@505e2c03de chore: Update LuaJIT 2023-03-02 15:11:50 +01:00
src Move bindgen to build script 2023-03-21 11:55:46 +01:00
tests Rename to luajit2-sys 2020-01-19 01:31:24 -05:00
.azure-pipelines.yml Add weekly build to CI 2020-01-19 15:29:09 -05:00
.gitignore Initial commit 2019-08-13 18:03:48 -04:00
.gitmodules Adding luajit submodule 2019-08-13 18:11:24 -04:00
build.rs chore: Fix lcippy warning 2023-03-28 20:49:15 +02:00
Cargo.toml feat: Implement cross compilation for MSVC toolchain 2023-03-23 13:35:56 +01:00
LICENSE-APACHE Add license 2020-01-19 01:38:51 -05:00
LICENSE-MIT Add license 2020-01-19 01:38:51 -05:00
README.md Update README 2020-01-19 16:31:41 -05:00

Rust LuaJIT Bindings

crates.io docs.rs build

[dependencies]
luajit2-sys = "0.0.2"

Exported Cargo Environment Variables

DEP_LUAJIT_INCLUDE Path to the LuaJIT source and headers
DEP_LUAJIT_LIB_NAME Platform specfic lib name (lua51 on Windows and luajit everywhere else)

Example

use luajit2_sys as sys;
use std::ffi::CStr;

fn main() {
    unsafe {
        let lua = sys::luaL_newstate();
        sys::luaL_openlibs(lua);
        let script_data = b"return 1 + 2";
        let script_name = b"run_script\0";
        sys::luaL_loadbuffer(
            lua,
            script_data.as_ptr() as _,
            script_data.len() as _,
            script_name.as_ptr() as _,
        );
        sys::lua_pcall(lua, 0, 1, 0);
        let idx = sys::lua_gettop(lua);
        let s = sys::lua_tostring(lua, idx);
        let result = CStr::from_ptr(s).to_string_lossy().to_string();
        sys::lua_close(lua);

        println!("result: {}", result);
    }
}