Closed neverchanje closed 2 months ago
What do you mean with methods are camel case while functions are not? Currently the function attribute doesn't do any naming on the js side.
Adding #[rquickjs::function]
to a function foo_bar
just creates the type js_foo_bar
which is for convenient passing of functions to javascript. Allowing you to do stuff like ctx.globals().set("fooBar",js_foo_bar)
instead of the more error prone and less flexible ctx.globals().set("fooBar", Func::new(foo_bar))
.
It doesn't actually expose the function to javascript by itself so there is no name to be camel case or not.
The rename attribute exists because I might eventually want the attribute to set the Function.prototype.name
field of the function object. But currently that name is just left empty and the rename does indeed nothing. If you want the name attribute to be set then currently you will have to do that manually.
Closing for inactivity.
The above exported function is
foo_bar
instead offooBar
. And I noticed that it made no change if added with (rename('fooBar')). Results are still same.It'll look strange if all methods are in the camel case while functions not.
I just peeked at the code: https://github.com/DelSkayn/rquickjs/blob/master/macro/src/function.rs#L114 Seems the function will not use the new name as
_js_name
is never used.