Skip to content

Commit

Permalink
Add a way to alias a function, e.g. change case
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl committed Jun 5, 2024
1 parent a7d3e2b commit 6f5ae1a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/interop/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ macro_rules! js_class {

$(
$(#[$method_attr: meta])*
fn $method_name: ident
fn $method_name: ident $( as $method_js_name: literal )?
( $( $fn_arg: ident: $fn_arg_type: ty ),* )
$(-> $result_type: ty)?
$method_body: block
Expand All @@ -120,8 +120,10 @@ macro_rules! js_class {
class.context(),
);

let function_name = $crate::__js_class_name!($method_name, $($method_js_name)?);

class.method(
$crate::boa_engine::JsString::from(stringify!($method_name)),
$crate::boa_engine::JsString::from(function_name),
$crate::__count!($( $fn_arg )*),
function,
);
Expand Down

0 comments on commit 6f5ae1a

Please sign in to comment.