Skip to content

Commit

Permalink
feat: allow to open native libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmasoldi3r committed Dec 1, 2023
1 parent 94f8400 commit 17d7d82
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions runtime/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use std::{
io::{self, BufReader, Read, Seek},
};

use rlua::{InitFlags, StdLib};

const INDEX_SIZE: usize = 8;

fn open_file() -> io::Result<File> {
Expand All @@ -29,8 +31,14 @@ fn main() -> io::Result<()> {
bf.seek(io::SeekFrom::End(-(size + INDEX_SIZE as i64)))?;
bf.read_to_end(&mut buffer)?;
buffer.truncate(buffer.len() - INDEX_SIZE);
rlua::Lua::new()
// See https://github.com/amethyst/rlua/issues/264
unsafe {
rlua::Lua::unsafe_new_with_flags(
StdLib::ALL_NO_DEBUG,
InitFlags::DEFAULT - InitFlags::REMOVE_LOADLIB,
)
.context(|ctx| ctx.load(&buffer).exec())
.unwrap();
.unwrap()
};
Ok(())
}

0 comments on commit 17d7d82

Please sign in to comment.