Skip to content

Commit

Permalink
mockup how to get a function stuff into Lua
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jun 24, 2024
1 parent 448dbf4 commit e4e8c33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/sile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ SILE = {}
--- Fields
-- @section fields

--- Functions implemented in Rust, to be moved to approprate places in the API
-- @table SILE.rusile
SILE._rusile = require("rusile")

--- Machine friendly short-form version.
-- Semver, prefixed with "v", possible postfixed with ".r" followed by VCS version information.
-- @string version
Expand Down
7 changes: 7 additions & 0 deletions rusile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@ use mlua::prelude::*;
#[mlua::lua_module]
fn rusile(lua: &Lua) -> LuaResult<LuaTable> {
let exports = lua.create_table().unwrap();
let foo: LuaFunction = lua.create_function(foo).unwrap();
exports.set("foo", foo)?;
Ok(exports)
}

fn foo<'a>(_lua: &'a Lua, (): ()) -> LuaResult<()> {
eprintln!("e print from rusile not rustle");
Ok(())
}

0 comments on commit e4e8c33

Please sign in to comment.