Skip to content

WIP: Add string #281

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

Closed
wants to merge 1 commit into from
Closed

Conversation

jonathan-s
Copy link
Contributor

@jonathan-s jonathan-s commented Jun 20, 2018

Work in progress to add string.

@jonathan-s
Copy link
Contributor Author

@fitzgen So when trying to add a new type to represent String similar to object and then add the method new. When testing that that the type is actually string it instead gives me the type object. I'm confused about that, any clues would be helpful.

@fitzgen
Copy link
Member

fitzgen commented Jun 20, 2018

Ah yes, this is a nasty corner of JS:

stringggg

@fitzgen
Copy link
Member

fitzgen commented Jun 20, 2018

I don't know if we should make String::new return js::Object or if we should just skip bindings to it altogether (it really isn't that useful...).

We should test receiving a js::String and checking its length for sure though!

@fitzgen
Copy link
Member

fitzgen commented Jun 20, 2018

I don't know if we should make String::new return js::Object or if we should just skip bindings to it altogether (it really isn't that useful...).

For this PR, let's just skip it. We can think it over in the meantime.

@jonathan-s
Copy link
Contributor Author

jonathan-s commented Jun 21, 2018 via email

@fitzgen
Copy link
Member

fitzgen commented Jun 21, 2018

Here is an example of using JS getters and setters from Rust code:

#[wasm_bindgen(method, getter)]
fn number(this: &MyClass) -> u32;
#[wasm_bindgen(method, setter)]
fn set_number(this: &MyClass, number: u32) -> MyClass;

The Rust side ends up doing .length() but it is translated into a get on the JS thing.

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.

2 participants