mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 07:14:50 +01:00
chore(lua): renamed some top level methods
This commit is contained in:
parent
3047d21870
commit
d215b4ab0b
4 changed files with 9 additions and 7 deletions
8
dist/lua/annotations.lua
vendored
8
dist/lua/annotations.lua
vendored
|
@ -403,12 +403,14 @@ local RuntimeDriver = {}
|
||||||
---stops the runtime thread, returns false if driver was already stopped
|
---stops the runtime thread, returns false if driver was already stopped
|
||||||
function RuntimeDriver:stop() end
|
function RuntimeDriver:stop() end
|
||||||
|
|
||||||
---@return RuntimeDriver
|
---@param block? boolean block current thread if true, otherwise spawn a background thread
|
||||||
|
---@return RuntimeDriver | nil
|
||||||
---spawns a background thread and uses it to run the codemp runtime
|
---spawns a background thread and uses it to run the codemp runtime
|
||||||
function Codemp.spawn_runtime_driver() end
|
---returns the driver handle only if another thread has been spawned (block=true)
|
||||||
|
function Codemp.setup_driver(block) end
|
||||||
|
|
||||||
---@param printer? string | fun(string) | nil log sink used for printing, if string will go to file, otherwise use given function
|
---@param printer? string | fun(string) | nil log sink used for printing, if string will go to file, otherwise use given function
|
||||||
---@param debug? boolean show more verbose debug logs, default false
|
---@param debug? boolean show more verbose debug logs, default false
|
||||||
---@return boolean true if logger was setup correctly, false otherwise
|
---@return boolean true if logger was setup correctly, false otherwise
|
||||||
---setup a global logger for codemp, note that can only be done once
|
---setup a global logger for codemp, note that can only be done once
|
||||||
function Codemp.logger(printer, debug) end
|
function Codemp.setup_tracing(printer, debug) end
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl LuaUserData for Promise {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn spawn_runtime_driver(_: &Lua, (block,):(Option<bool>,)) -> LuaResult<Option<Driver>> {
|
pub(crate) fn setup_driver(_: &Lua, (block,):(Option<bool>,)) -> LuaResult<Option<Driver>> {
|
||||||
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
|
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
|
||||||
let future = async move {
|
let future = async move {
|
||||||
tracing::info!(" :: driving runtime...");
|
tracing::info!(" :: driving runtime...");
|
||||||
|
|
|
@ -16,7 +16,7 @@ impl Write for LuaLoggerProducer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO can we make this less verbose?
|
// TODO can we make this less verbose?
|
||||||
pub(crate) fn logger(_: &Lua, (printer, debug): (LuaValue, Option<bool>)) -> LuaResult<bool> {
|
pub(crate) fn setup_tracing(_: &Lua, (printer, debug): (LuaValue, Option<bool>)) -> LuaResult<bool> {
|
||||||
let level = if debug.unwrap_or_default() { tracing::Level::DEBUG } else {tracing::Level::INFO };
|
let level = if debug.unwrap_or_default() { tracing::Level::DEBUG } else {tracing::Level::INFO };
|
||||||
let format = tracing_subscriber::fmt::format()
|
let format = tracing_subscriber::fmt::format()
|
||||||
.with_level(true)
|
.with_level(true)
|
||||||
|
|
|
@ -28,7 +28,7 @@ fn entrypoint(lua: &Lua) -> LuaResult<LuaTable> {
|
||||||
)?)?;
|
)?)?;
|
||||||
|
|
||||||
// runtime
|
// runtime
|
||||||
exports.set("spawn_runtime_driver", lua.create_function(ext::a_sync::spawn_runtime_driver)?)?;
|
exports.set("setup_driver", lua.create_function(ext::a_sync::setup_driver)?)?;
|
||||||
exports.set("poll_callback", lua.create_function(|lua, ()| {
|
exports.set("poll_callback", lua.create_function(|lua, ()| {
|
||||||
let mut val = LuaMultiValue::new();
|
let mut val = LuaMultiValue::new();
|
||||||
match ext::callback().recv() {
|
match ext::callback().recv() {
|
||||||
|
@ -45,7 +45,7 @@ fn entrypoint(lua: &Lua) -> LuaResult<LuaTable> {
|
||||||
})?)?;
|
})?)?;
|
||||||
|
|
||||||
// logging
|
// logging
|
||||||
exports.set("logger", lua.create_function(ext::log::logger)?)?;
|
exports.set("setup_tracing", lua.create_function(ext::log::setup_tracing)?)?;
|
||||||
|
|
||||||
Ok(exports)
|
Ok(exports)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue