Skip to content

Commit

Permalink
[XA.Tools.Bytecode] Add Kotlin support to our binding process. (#505)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jpobst authored and jonpryor committed Nov 22, 2019
1 parent 5fa8c18 commit 439bd83
Show file tree
Hide file tree
Showing 54 changed files with 1,121 additions and 106 deletions.
2 changes: 2 additions & 0 deletions src/Xamarin.Android.Tools.Bytecode/ClassFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public bool IsStatic {
public bool IsEnum {
get {return (AccessFlags & ClassAccessFlags.Enum) != 0;}
}

public override string ToString () => ThisClass?.Name.Value;
}

[Flags]
Expand Down
3 changes: 1 addition & 2 deletions src/Xamarin.Android.Tools.Bytecode/ClassPath.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
Expand All @@ -8,7 +8,6 @@
using System.Xml.Linq;
using System.Xml.XPath;
using System.Text;
using Xamarin.Android.Tools.Bytecode.Kotlin;

namespace Xamarin.Android.Tools.Bytecode {

Expand Down
Loading

0 comments on commit 439bd83

Please sign in to comment.