Skip to content

Attribute for static methods #296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 25, 2018

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented Jun 22, 2018

This hooks up the existing support for static methods that @ohanar added for WebIDL to a #[wasm_bindgen(static_method_of = Class)] attribute, and implements bindings to Object.keys to exercise the code path during tests.

leading_colon: None,
segments,
},
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic largely redundant with wasm_bindgen_webidl::util::ident_ty, it might be good to move some of the utility functions out of that crate and into the backend.

@ohanar
Copy link
Member

ohanar commented Jun 23, 2018

Looks good to me. I'll let you decide if you want to address the small amount of refactoring here or leave it for the future.

fitzgen added 5 commits June 25, 2018 10:45
This is similar to `js_namespace` but translates into a static method on `Class`
rather than a free function. This allows us to have bindings to things like
`Object.keys` as `Object::keys`.
@fitzgen fitzgen force-pushed the attribute-for-static-methods branch from d7d59fd to 8fbf478 Compare June 25, 2018 17:51
@fitzgen fitzgen merged commit 245f0f0 into rustwasm:master Jun 25, 2018
@fitzgen fitzgen deleted the attribute-for-static-methods branch June 25, 2018 18:14
@alexcrichton
Copy link
Contributor

FWIW this was sort of the intention of js_namespace, but having a few options isn't the end of the world! @fitzgen mind also updating the design doc with the new attribute?

@fitzgen
Copy link
Member Author

fitzgen commented Jun 27, 2018

Yes, I can do that when I get a chance. The reason js_namespace didn't work for this is because it creates a free function rather than a static method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants