You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think some of the signatures generated by the script are wrong. I will explain why I think this is the case, but I'd like someone else to validate it as well, as I haven't gotten around to testing it yet.
Consider the example of LLVMDiagnosticHandler. On the C side, it is defined as:
If this is the case, an LLVMSharp user might not be able to create a useful handler, because the C# compiler will force any handler to overwrite the out parameter explicitly (or the C# compiler will insert an implicit overwrite). This means that anything passed to the handler from the C++ side will be lost (and the handler could even corrupt the state of the C++ side). Changing the script to generate ref instead of out should fix that.
I don't know how many other types may have this issue -- this simply happened to be the first one I attempted to work on.
The text was updated successfully, but these errors were encountered:
I think some of the signatures generated by the script are wrong. I will explain why I think this is the case, but I'd like someone else to validate it as well, as I haven't gotten around to testing it yet.
Consider the example of
LLVMDiagnosticHandler
. On the C side, it is defined as:Where
LLVMDiagnosticInfoRef
is:Because of this, I'm guessing
LLVMDiagnosticHandler
is seen by the script as:And the script emits the following delegate type:
On the C++ side, setting the diagnostic handler simply saves the passed arguments and, at a later point, another function calls the function pointer and passes a
const DiagnosticInfo&
to it. I think this means that the C++ side expects that first parameter to be an input parameter passed by reference, while the C# side assumes it is an output parameter.If this is the case, an LLVMSharp user might not be able to create a useful handler, because the C# compiler will force any handler to overwrite the
out
parameter explicitly (or the C# compiler will insert an implicit overwrite). This means that anything passed to the handler from the C++ side will be lost (and the handler could even corrupt the state of the C++ side). Changing the script to generateref
instead ofout
should fix that.I don't know how many other types may have this issue -- this simply happened to be the first one I attempted to work on.
The text was updated successfully, but these errors were encountered: