mirror of
https://github.com/lxsang/luafcgi.git
synced 2024-09-07 13:56:40 +02:00
Support loading C module from lua state
This commit is contained in:
parent
bb1888cb77
commit
74dff76282
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[build]
|
||||||
|
rustflags = ["-C", "link-args=-rdynamic"]
|
@ -541,7 +541,8 @@ impl mlua::UserData for FCGIOStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fcgi_execute_request_handle(rq: &mut FGCIRequest) -> Result<(), Box<dyn std::error::Error>> {
|
fn fcgi_execute_request_handle(rq: &mut FGCIRequest) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let lua = mlua::Lua::new();
|
let lua = unsafe { mlua::Lua::unsafe_new() };
|
||||||
|
lua.load_from_std_lib(mlua::StdLib::ALL)?;
|
||||||
let global = lua.globals();
|
let global = lua.globals();
|
||||||
let request = lua.create_table()?;
|
let request = lua.create_table()?;
|
||||||
|
|
||||||
@ -836,6 +837,8 @@ impl mlua::UserData for LuabyteArray {
|
|||||||
fn add_methods<'lua, M: mlua::UserDataMethods<'lua, Self>>(methods: &mut M) {
|
fn add_methods<'lua, M: mlua::UserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||||
methods.add_method("size", |_, this: &LuabyteArray, ()| Ok(this.0.len()));
|
methods.add_method("size", |_, this: &LuabyteArray, ()| Ok(this.0.len()));
|
||||||
|
|
||||||
|
methods.add_method("ptr", |_, this:&LuabyteArray, ()| Ok(this.0.as_ptr() as usize));
|
||||||
|
|
||||||
methods.add_method("write", |_, this: &LuabyteArray, path: String| {
|
methods.add_method("write", |_, this: &LuabyteArray, path: String| {
|
||||||
match std::fs::File::create(&path) {
|
match std::fs::File::create(&path) {
|
||||||
Ok(mut file) => {
|
Ok(mut file) => {
|
||||||
@ -892,6 +895,6 @@ impl mlua::UserData for LuabyteArray {
|
|||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
methods.add_meta_method_mut(mlua::MetaMethod::Len, |_, this, ()| Ok(this.0.len()));
|
methods.add_meta_method(mlua::MetaMethod::Len, |_, this, ()| Ok(this.0.len()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user