fix arity on acquire-context-lock

pull/8675/merge^2
Matt Paras 2025-05-23 06:42:14 -07:00
parent 04697d61f9
commit aefdab6307
1 changed files with 36 additions and 17 deletions

View File

@ -3277,30 +3277,26 @@ callback : (-> any?)
); );
} }
let mut template_function_arity_2 = |name: &str, doc: &str| { macro_rules! register_2_no_context {
($name:expr, $func:expr, $doc:expr) => {{
module.register_fn($name, $func);
if generate_sources { if generate_sources {
let doc = format_docstring(doc); let doc = format_docstring($doc);
builtin_misc_module.push_str(&format!( builtin_misc_module.push_str(&format!(
r#" r#"
(provide {}) (provide {})
;;@doc ;;@doc
{} {}
(define ({} arg1 arg2) (define ({} arg1 arg2)
(helix.{} *helix.cx* arg1 arg2)) (helix.{} arg1 arg2))
"#, "#,
name, doc, name, name $name, doc, $name, $name
)); ));
} }
};
macro_rules! register_2 {
($name:expr, $func:expr, $doc:expr) => {{
module.register_fn($name, $func);
template_function_arity_2($name, $doc);
}}; }};
} }
register_2!( register_2_no_context!(
"acquire-context-lock", "acquire-context-lock",
|callback_fn: SteelVal, place: Option<SteelVal>| { |callback_fn: SteelVal, place: Option<SteelVal>| {
match (&callback_fn, &place) { match (&callback_fn, &place) {
@ -3383,7 +3379,7 @@ The provided function will get enqueued to run on the main thread, and during th
execution, the provided mutex will be locked. execution, the provided mutex will be locked.
```scheme ```scheme
(acquire-context-lock? callback-fn mutex) (acquire-context-lock callback-fn mutex)
``` ```
callback-fn : (-> void?) callback-fn : (-> void?)
@ -3393,6 +3389,29 @@ mutex : mutex?
"# "#
); );
let mut template_function_arity_2 = |name: &str, doc: &str| {
if generate_sources {
let doc = format_docstring(doc);
builtin_misc_module.push_str(&format!(
r#"
(provide {})
;;@doc
{}
(define ({} arg1 arg2)
(helix.{} *helix.cx* arg1 arg2))
"#,
name, doc, name, name
));
}
};
macro_rules! register_2 {
($name:expr, $func:expr, $doc:expr) => {{
module.register_fn($name, $func);
template_function_arity_2($name, $doc);
}};
}
// Arity 2 // Arity 2
register_2!( register_2!(
"enqueue-thread-local-callback-with-delay", "enqueue-thread-local-callback-with-delay",