-
Notifications
You must be signed in to change notification settings - Fork 57
[XA.Tools.Bytecode] Add Kotlin support to our binding process. #505
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
Conversation
f9497c7
to
84ccb6d
Compare
1344d14
to
024530f
Compare
The last bullet point gives me some pause:
Does this happen with virtual instance members? I fear the answer is "yes". Thus, consider the Kotlin code: class ExampleBase {
public open fun foo(value : Int) {
}
public open fun foo(value : UInt) {
}
} Compile & Disassemble it, and:
Based on the bullet point, I think we'd bind this as: [Register ("ExampleBase", DoNotGenerateAcw=true)]
partial class ExampleBase {
[Register ("foo", ...)]
public virtual void Foo (int value) {
_members.InstanceMethods.InvokeVirtualVoidMethod ("foo.(I)V", this, ...);
}
[Register ("foo-WZ4Q5Ns", ...)]
public virtual void Foo (int value) {
_members.InstanceMethods.InvokeVirtualVoidMethod ("foo-WZ4Q5Ns.(I)V", this, ...);
}
} At which point I scratch my head. For starters, that can't compile: there's two Even if it could compile, the // C#
class MyDerivedExample : ExampleBase {
// Assume we "somehow" override the foo(UInt) overload
public override void Foo (int value) {
}
} There's not actually any way to override Now, if we bound As-is, though, I cannot tell what this PR would do with the above Kotlin class. Is this already handled and I just don't see it? Should it be addressed? |
Yeah, that appears to be an issue that we will need to think through and fix. Perhaps if we have a Given that it is likely a rare corner case (that could be fixable via |
Context: #525 Various fixes and enhancements to allow better default Kotlin libraries bindings: * Hide Kotlin-internal classes, constructors, and methods. * Hide implementation methods (`*-impl*`). * Rename extension method parameter like `$this$decodeBase64` to `obj`. * Use Kotlin provided method parameter names instead of `p0`, `p1`, etc. * Rename any method with a `-<mangling>` to drop the invalid part, e.g. `add-H4uI21a` is bound as `add`. ("Name mangling" like this is how Kotlin ensures `add(UInt)` and `add(Int)` don't clash when compiled to [Java][1].) Note that the final bullet point -- "removing" name mangling -- may result in C# code which is either not valid or not entirely usable. See Issue #525 for details. This will be addressed "later". [1]: https://kotlinlang.org/docs/reference/inline-classes.html#mangling
Various fixes and enhancements to allow better default Kotlin libraries bindings.
*-impl*
).$this$decodeBase64
toobj
.p0
,p1
, etc.hyphen-<hashcode>
to drop the invalid part (add-H4uI21a
->add
).add (UInt)
andadd (Int)
don't clash when compiled to Java.