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

Adjust PreserveSig emission #789

Merged
merged 5 commits into from
Feb 1, 2022

Conversation

riverar
Copy link
Collaborator

@riverar riverar commented Jan 31, 2022

Fixes #559

Removes PreserveSig emission for all APIs by default. Adds PreserveSig emission for class methods explicitly marked with [PreserveSig] in emitter.settings.rsp. (Interface methods were already covered previously.)

Metadata diff is too large to be useful, as you can imagine.

@riverar riverar requested a review from sotteson1 January 31, 2022 23:21
@sotteson1 sotteson1 merged commit afd9e33 into microsoft:master Feb 1, 2022
@riverar riverar deleted the rafael/preservesig-emission branch February 1, 2022 02:57
@AArnott
Copy link
Member

AArnott commented Feb 1, 2022

FWIW I feel PreserveSig should remain on standard C methods. Only the COM interface methods should lack preservesig because those are the ones we expect to be projected with a different signature.

@kennykerr
Copy link
Contributor

Hate to disagree but I've been applying transformations on methods and free functions alike and it would be a major step back not to. Developers love it.

@AArnott
Copy link
Member

AArnott commented Feb 1, 2022

@kennykerr I'm very curious now. Are you saying that win32 methods like CreateFile don't return values anymore? Methods that return hresult, win32 error codes, lstatus, etc... will throw instead of return error codes?

@kennykerr
Copy link
Contributor

It's more nuanced than that. First of all, it's not about "throwing". Rust doesn't have exceptions. It's about permitting or preventing transformation of some kind. Whether it's a method or free function, it can have a signature that may benefit from some transformation. This doesn't mean that every function that lacks the PreserveSig bit will be transformed. The bit just ensures that any transformation that would otherwise apply will be ignored, and the original signature will be preserved.

As an example, CreateFileA will always have its signature preserved and return a handle directly regardless of whether the PreserveSig bit is set because no other transformation is applicable. DoDragDrop on the other hand would be transformed unless the PreserveSig bit is set.

@AArnott
Copy link
Member

AArnott commented Feb 1, 2022

That makes sense. In CsWin32 we can deal with it either way, so if it's useful to you as-is, that's fine by me.

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.

Add an attribute for identifying methods and functions that return alternative success codes
4 participants