This repository was archived by the owner on Dec 12, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the last PR, I added a GCHandle to all the vtable representations (both C# and Swift).
This PR builds on that and adds the GCHandle to be the first argument for all of the receivers.
I'm not really happy with this because the code in MarshalEngineCSafeSwiftToCSharp was full of magic numbers in the marshaling code. The problem is that the meaning of the index depends HEAVILY on the context in which they're used so making variables to represent them makes things worse IMHO (in terms of complication), but better in terms of future usage. Since in future usage, a lot (if not all) of this code is going to go away due to runtime support for the same actions, I'm not too too concerned of leaving it how it is.
When you call a receiver (this is the C# function that gets called from Swift in order to implement a virtual or protocol method), you will have the following arguments:
The Return pointer is there if the return type can't be marshaled directly or when the implementation may throw. If it can throw, then the return type is a Medusa tuple which contains a bool to indicate whether or not the exception was thrown, a pointer to space for the return value (if there was no exception), and a pointer to the exception if the exception was thrown.