Skip to content
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

Generate bindings for indexed struct properties #1467

Merged
merged 2 commits into from
Apr 26, 2019

Conversation

RReverser
Copy link
Member

This allows to export fields of tuple-like structs as indexed JS properties.

While we could rename it to _0, $0 or something else, this feels like the most natural mapping of "indexed" properties to JavaScript concepts, and just works out of the box with current JS and TypeScript codegens.

This allows to export fields of tuple-like structs as indexed JS properties.
@alexcrichton
Copy link
Contributor

Seems reasonable to me, thanks @RReverser! Could you ensure that this is documented in the reference as well?

@RReverser
Copy link
Member Author

Ah yes. I'm leaving for the Easter holiday now but can back to it afterwards.

@RReverser
Copy link
Member Author

@alexcrichton Hmm, I might need help figuring out where best to put it. There currently doesn't seem to be a dedicated section describing how named properties are bound on the JS side? (I've found only exported_types.rs, but it doesn't demonstrate properties usage, only the class itself)

@alexcrichton
Copy link
Contributor

Ah that's true yeah, mind starting a page which describes the JS api created for exported rust structures? It could go in the area for attributes on exports perhaps in the reference

@RReverser
Copy link
Member Author

I'm thinking maybe just adding some property usage to the same existing exported-rust-types.md + exported_types.rs + exported_types.js?

@RReverser
Copy link
Member Author

I've added property examples to files mentioned above, let me know how it looks.

@alexcrichton alexcrichton merged commit cd7aa71 into rustwasm:master Apr 26, 2019
@alexcrichton
Copy link
Contributor

Thanks!

@RReverser RReverser deleted the tuple-structs branch April 26, 2019 14:22
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.

None yet

2 participants