2023-03-09 11:17:25 +00:00
|
|
|
use mlua::prelude::*;
|
|
|
|
|
2023-03-10 10:07:03 +00:00
|
|
|
pub mod datatypes;
|
2023-03-09 11:17:25 +00:00
|
|
|
pub mod document;
|
2023-03-10 10:07:03 +00:00
|
|
|
pub mod instance;
|
|
|
|
|
|
|
|
use datatypes::types::*;
|
|
|
|
use datatypes::DatatypeTable;
|
|
|
|
|
|
|
|
fn make_dt<F>(lua: &Lua, f: F) -> LuaResult<LuaTable>
|
|
|
|
where
|
|
|
|
F: Fn(&Lua, &LuaTable) -> LuaResult<()>,
|
|
|
|
{
|
|
|
|
let tab = lua.create_table()?;
|
|
|
|
f(lua, &tab)?;
|
|
|
|
tab.set_readonly(true);
|
|
|
|
Ok(tab)
|
|
|
|
}
|
2023-03-09 11:17:25 +00:00
|
|
|
|
|
|
|
pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
|
2023-03-10 10:07:03 +00:00
|
|
|
let datatypes = vec![("Vector3", make_dt(lua, Vector3::make_dt_table)?)];
|
2023-03-09 11:17:25 +00:00
|
|
|
let exports = lua.create_table()?;
|
2023-03-10 10:07:03 +00:00
|
|
|
for (name, tab) in datatypes {
|
|
|
|
exports.set(name, tab)?;
|
|
|
|
}
|
2023-03-09 11:17:25 +00:00
|
|
|
Ok(exports)
|
|
|
|
}
|