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

JS Functions can accept struct params as JS objects #734

Merged
merged 46 commits into from
Dec 13, 2024

Conversation

ambiguousname
Copy link
Member

@ambiguousname ambiguousname commented Nov 21, 2024

Fixes #720.

TODO:

  • Add test for nested struct construction
  • Don't think nested structs are actually recognized yet. Need to update struct construction code to fix this.
  • Label parameters correctly in typescript
  • StructTypeName_Obj with recursive structs also need StructTypeName | StructTypeName_Obj labeling in typescript

@ambiguousname ambiguousname added the B-js JS backend label Nov 21, 2024
Copy link
Contributor

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

Nice. I wodner if we should also make this clear in the typescript types or let it be under the hood.

@ambiguousname
Copy link
Member Author

ambiguousname commented Dec 5, 2024

All that's left is one test that's returning an error. I think it's something to do with a receiveBuffer being created when the generated WASM doesn't call for one, am investigating.

Edit: Found the cause. Opened #739

@ambiguousname ambiguousname changed the title JS Functions can accept Javascript objects JS Functions can accept struct params as JS objects Dec 5, 2024
@ambiguousname
Copy link
Member Author

Need to do some generation in other languages, but this is good to review now.

@ambiguousname ambiguousname marked this pull request as ready for review December 5, 2024 20:59
tool/src/js/gen.rs Outdated Show resolved Hide resolved
@ambiguousname
Copy link
Member Author

Waiting on #742 to be merged before I update this (so I can revert the CyclicStruct feature tests)

@Manishearth Manishearth merged commit b9aab0c into rust-diplomat:main Dec 13, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-js JS backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JS2 constructors: structs and enums should autoconvert at parameter/struct boundaries
2 participants