fix: less common name for global console
This commit is contained in:
parent
9541172174
commit
9c98e8bd52
2 changed files with 13 additions and 9 deletions
|
@ -7,18 +7,19 @@ use tracing::warn;
|
|||
|
||||
use crate::helpers::pretty_lua;
|
||||
|
||||
use super::{console::Console, HELPTEXT};
|
||||
use super::{console::Console, HELPTEXT, GLOBAL_CONSOLE};
|
||||
|
||||
const SIGSEGV_HOOK : AtomicBool = AtomicBool::new(false);
|
||||
|
||||
pub fn lua_help(lua: &Lua, _args: ()) -> Result<(), Error> {
|
||||
let console : Console = lua.globals().get("console")?;
|
||||
console.send(HELPTEXT.into())
|
||||
let console : Console = lua.globals().get(GLOBAL_CONSOLE)?;
|
||||
console.send(HELPTEXT.into())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn lua_log(lua: &Lua, values: Variadic<Value>) -> Result<usize, Error> {
|
||||
let mut out = String::new();
|
||||
let console : Console = lua.globals().get("console")?;
|
||||
let console : Console = lua.globals().get(GLOBAL_CONSOLE)?;
|
||||
for value in values {
|
||||
out.push_str(&pretty_lua(value));
|
||||
out.push(' ');
|
||||
|
@ -33,8 +34,8 @@ pub fn lua_hexdump(lua: &Lua, (bytes, ret): (Vec<u8>, Option<bool>)) -> Result<V
|
|||
if ret.unwrap_or(false) {
|
||||
return Ok(pretty_hex::simple_hex(&bytes).to_lua(lua)?);
|
||||
}
|
||||
let console : Console = lua.globals().get("console")?;
|
||||
console.send(pretty_hex::pretty_hex(&bytes))?;
|
||||
let console : Console = lua.globals().get(GLOBAL_CONSOLE)?;
|
||||
console.send(pretty_hex::pretty_hex(&bytes) + "\n")?;
|
||||
Ok(Value::Nil)
|
||||
}
|
||||
|
||||
|
@ -178,7 +179,7 @@ pub fn lua_procmaps(lua: &Lua, ret: Option<bool>) -> Result<Value, Error> {
|
|||
).as_str()
|
||||
);
|
||||
}
|
||||
let console : Console = lua.globals().get("console")?;
|
||||
let console : Console = lua.globals().get(GLOBAL_CONSOLE)?;
|
||||
console.send(out)?;
|
||||
Ok(Value::Nil)
|
||||
}
|
||||
|
@ -219,7 +220,7 @@ pub fn lua_threads(lua: &Lua, ret: Option<bool>) -> Result<Value, Error> {
|
|||
}
|
||||
}
|
||||
|
||||
let console : Console = lua.globals().get("console")?;
|
||||
let console : Console = lua.globals().get(GLOBAL_CONSOLE)?;
|
||||
console.send(out)?;
|
||||
Ok(Value::Nil)
|
||||
}
|
||||
|
|
|
@ -10,13 +10,16 @@ use tokio::sync::broadcast;
|
|||
use crate::runtime::console::Console;
|
||||
use crate::runtime::builtins::*;
|
||||
|
||||
pub const GLOBAL_CONSOLE : &str = "GLOBAL_CONSOLE";
|
||||
|
||||
pub fn register_builtin_fn(lua: &Lua, console: broadcast::Sender<String>) -> Result<(), Error> {
|
||||
lua.globals().set("console", Console::from(console))?; // TODO passing it this way makes clones
|
||||
lua.globals().set(GLOBAL_CONSOLE, Console::from(console))?; // TODO passing it this way makes clones
|
||||
|
||||
lua.globals().set("PROT_NONE", ProtFlags::PROT_NONE.bits())?;
|
||||
lua.globals().set("PROT_READ", ProtFlags::PROT_READ.bits())?;
|
||||
lua.globals().set("PROT_WRITE", ProtFlags::PROT_WRITE.bits())?;
|
||||
lua.globals().set("PROT_EXEC", ProtFlags::PROT_EXEC.bits())?;
|
||||
lua.globals().set("PROT_ALL", (ProtFlags::PROT_EXEC | ProtFlags::PROT_WRITE | ProtFlags::PROT_READ).bits())?;
|
||||
|
||||
lua.globals().set("MAP_ANON", MapFlags::MAP_ANON.bits())?;
|
||||
lua.globals().set("MAP_PRIVATE",MapFlags::MAP_PRIVATE.bits())?;
|
||||
|
|
Loading…
Reference in a new issue