Include lb_tasklib::spawn in globals
This commit is contained in:
parent
0cafac0948
commit
24c5e9edc2
6
crates/lb/src/task.lua
Normal file
6
crates/lb/src/task.lua
Normal file
@ -0,0 +1,6 @@
|
||||
local task = require("lb:task")
|
||||
|
||||
-- include `lb_tasklib::spawn` in the global scope
|
||||
function spawn(f, ...)
|
||||
return task:spawn(f, ...)
|
||||
end
|
@ -7,6 +7,7 @@ use tokio::task::JoinHandle;
|
||||
pub struct lb_tasklib;
|
||||
|
||||
#[metatype]
|
||||
#[include("task.lua")]
|
||||
impl lb_tasklib {
|
||||
#[new]
|
||||
extern "Lua-C" fn new() -> Self {
|
||||
|
@ -62,12 +62,12 @@ fn generate_impls(_args: &Args, imp: &mut ItemImpl) -> Result<TokenStream> {
|
||||
imp.attrs.retain(|attr| {
|
||||
if attr.path().is_ident("include") {
|
||||
if let Ok(path) = attr.parse_args::<LitStr>() {
|
||||
registry.build.push(quote_spanned!(attr.span() =>
|
||||
registry.build.push(quote_spanned!(path.span() =>
|
||||
b.include_lua(::std::include_str!(#path));
|
||||
));
|
||||
return false;
|
||||
} else if let Ok(chunk) = attr.parse_args::<Block>() {
|
||||
registry.build.push(quote_spanned!(attr.span() =>
|
||||
registry.build.push(quote_spanned!(chunk.span() =>
|
||||
b.include_lua(#ffi::__internal::luaify_chunk!(#chunk));
|
||||
));
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user