Skip to content

Fix generated binding for functions returning structs. #191

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 1 commit into from
May 6, 2018

Conversation

ngg
Copy link
Contributor

@ngg ngg commented May 6, 2018

This only affects --no-modules and --nodejs modes.

Fixes #190.

@@ -56,9 +56,17 @@ impl<'a> Context<'a> {
let contents = deindent(contents);
let contents = contents.trim();
let global = if self.config.nodejs {
format!("module.exports.{} = {};\n", name, contents)
if contents.starts_with("class") {
format!("let {0} = null;\nmodule.exports.{0} = {0} = {1};\n", name, contents)
Copy link
Contributor

Choose a reason for hiding this comment

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

To avoid the null could this perhaps instead be let {0} = {1};\nmodule.exports.{0} = {0};\n?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even simpler solution: "{1}\nmodule.exports.{0} = {0};\n" (it seems to work perfectly)

@alexcrichton
Copy link
Contributor

Oops sorry about that!

This only affects --no-modules and --nodejs modes.

Fixes rustwasm#190.
@ngg ngg force-pushed the fix-no-modules-export branch from e2bbd77 to 02adf6d Compare May 6, 2018 16:19
@alexcrichton alexcrichton merged commit 94b59e0 into rustwasm:master May 6, 2018
@alexcrichton
Copy link
Contributor

👍

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