-
Notifications
You must be signed in to change notification settings - Fork 514
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
Fix Value Type Out Parameters #1772
Conversation
Cool, thanks for the fix! |
Thank you for the quick merge! Are there any estimates on when there'll be another nuget release? I would like to use this fix in a project of mine but would want to avoid having to deal with git submodule or nuget shenanigans. |
I've pushed a new tag, v1.1. Hopefully when the build ends a new version is published: https://github.com/mono/CppSharp/actions/runs/6560441820 |
Thank you very much!! |
Should be up now. https://github.com/mono/CppSharp/releases/tag/v1.1 There is some kind of mismatch in the package/release version name, will have to figure that out, but should be good enough to use for now. |
Hmmm, it doesn't seem to be working for me. The |
Not sure, everything looks fine when I download the package and check its contents. The process is the same that the previous release was created with so dunno. |
Currently, using value types as out parameters generates incorrect code:
Given
the following code is generated:
This does not use the out parameter's internal value, but a newly created one, leaving the out parameter unchanged.
Following this PR the following code is generated:
Considerations:
fixed
statements are not being indented. I hope this is either 1. negligible or 2. easily fixable with greater understanding of the library.fixed
a local could be used and the result later copied into the out parameter. I assume this would be more expensive, as it'd require an extra copy of a potentially very large structure. (If this is a big concern, it should probably be benchmarked)Context.Return.Write($"new {typePrinter.IntPtrType}(&{arg})");
is duplicated once, with only the&
being omitted. I'm currently not seeing a clean solution, but there might be one.