Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit e3c55a9

Browse files
committed
Revert "Improve Kotlin Binding Support (#685)"
This reverts commit 238ae5c.
1 parent 238ae5c commit e3c55a9

File tree

5 files changed

+15
-51
lines changed

5 files changed

+15
-51
lines changed

Util/Xamarin.Kotlin.BindingSupport/build.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
var TARGET = Argument("t", Argument("target", "Default"));
33

4-
var PACKAGE_VERSION = "0.3.0-preview";
4+
var PACKAGE_VERSION = "0.2.0-preview";
55

66
Task("externals")
77
.Does(() =>

Util/Xamarin.Kotlin.BindingSupport/native/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id 'java'
3-
id 'org.jetbrains.kotlin.jvm' version '1.3.0'
3+
id 'org.jetbrains.kotlin.jvm' version '1.3.41'
44
}
55

66
group 'xamarin.binding.kotlin'
@@ -17,8 +17,8 @@ dependencies {
1717
compile 'com.github.ajalt:clikt:2.1.0'
1818
compile 'xom:xom:1.3.2'
1919
compile 'org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.1.0'
20-
compile "org.jetbrains.kotlin:kotlin-stdlib:1.3.0"
21-
compile "org.jetbrains.kotlin:kotlin-reflect:1.3.0"
20+
compile "org.jetbrains.kotlin:kotlin-stdlib:1.3.41"
21+
compile "org.jetbrains.kotlin:kotlin-reflect:1.3.41"
2222
}
2323

2424
compileKotlin {

Util/Xamarin.Kotlin.BindingSupport/native/src/main/kotlin/xamarin/binding/kotlin/bindingsupport/ProcessXmlCommand.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ class ProcessXmlCommand : CliktCommand(name = "KotlinBindingSupport") {
2020
val outputFile: File? by option("-o", "--output", help = "path to the output transform file")
2121
.file(fileOkay = true, folderOkay = false)
2222

23-
val ignoreFile: File? by option("-i", "--ignore", help = "path to the ignore file")
24-
.file(fileOkay = true, folderOkay = false)
25-
2623
val companions: Processor.CompanionProcessing by option("--companions", help = "indicate how to handle companions")
2724
.choice(
2825
"default" to Processor.CompanionProcessing.Default,
@@ -35,7 +32,7 @@ class ProcessXmlCommand : CliktCommand(name = "KotlinBindingSupport") {
3532
.flag(default = false)
3633

3734
override fun run() {
38-
val proc = Processor(xmlFile, jarFiles, outputFile, ignoreFile)
35+
val proc = Processor(xmlFile, jarFiles, outputFile)
3936
proc.verbose = verbose
4037
proc.companions = companions
4138
proc.process()

Util/Xamarin.Kotlin.BindingSupport/native/src/main/kotlin/xamarin/binding/kotlin/bindingsupport/Processor.kt

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import java.lang.reflect.Constructor
1010
import java.lang.reflect.Executable
1111
import java.lang.reflect.Field
1212
import java.lang.reflect.Method
13+
import java.net.URL
1314
import java.net.URLClassLoader
1415
import kotlin.reflect.KFunction
1516
import kotlin.reflect.KVisibility
1617
import kotlin.reflect.jvm.kotlinFunction
1718
import kotlin.reflect.jvm.kotlinProperty
1819

19-
class Processor(xmlFile: File, jarFiles: List<File>, outputFile: File?, ignoreFile: File?) {
20+
class Processor(xmlFile: File, jarFiles: List<File>, outputFile: File?) {
2021

2122
private fun expressionClasses() =
2223
"/api/package/*[local-name()='class' or local-name()='interface']"
@@ -47,8 +48,6 @@ class Processor(xmlFile: File, jarFiles: List<File>, outputFile: File?, ignoreFi
4748
private val outputFile: File?
4849
private val xtransformsdoc: Document
4950

50-
private val ignored: List<String>
51-
5251
init {
5352
val urls = jarFiles.map { file -> file.toURI().toURL() }
5453
loader = URLClassLoader(urls.toTypedArray())
@@ -58,12 +57,6 @@ class Processor(xmlFile: File, jarFiles: List<File>, outputFile: File?, ignoreFi
5857

5958
xtransformsdoc = Document(Element("metadata"))
6059
this.outputFile = outputFile
61-
62-
if (ignoreFile != null) {
63-
ignored = ignoreFile.readLines()
64-
} else {
65-
ignored = emptyList()
66-
}
6760
}
6861

6962
fun process() {
@@ -203,13 +196,13 @@ class Processor(xmlFile: File, jarFiles: List<File>, outputFile: File?, ignoreFi
203196

204197
// remove the members that are not meant to be used
205198
processMembers(xclass, "constructor") {
206-
shouldRemoveMember(it, jclass.declaredConstructors + jclass.constructors)
199+
shouldRemoveMember(it, jclass.declaredConstructors)
207200
}
208201
processMembers(xclass, "method") {
209-
shouldRemoveMember(it, jclass.declaredMethods + jclass.methods)
202+
shouldRemoveMember(it, jclass.declaredMethods)
210203
}
211204
processMembers(xclass, "field") {
212-
shouldRemoveField(it, jclass.declaredFields + jclass.fields)
205+
shouldRemoveField(it, jclass.declaredFields)
213206
}
214207
}
215208

@@ -260,12 +253,6 @@ class Processor(xmlFile: File, jarFiles: List<File>, outputFile: File?, ignoreFi
260253

261254
logVerbose("Checking the class \"${xpackage}.${xname}\"...")
262255

263-
// make sure we haven't been told to ignore this
264-
if (ignored.contains("${xpackage}.${xname}")) {
265-
logVerbose("Ignoring class \"${xpackage}.${xname}\" because it was found in the ignore file...")
266-
return ProcessResult.Ignore
267-
}
268-
269256
// before we check anything, make sure that the parent class is visible
270257
var lastPeriod = xname.lastIndexOf(".")
271258
while (lastPeriod != -1) {
@@ -332,12 +319,6 @@ class Processor(xmlFile: File, jarFiles: List<File>, outputFile: File?, ignoreFi
332319
val xtype = xmember.localName
333320
val xfullname = "${xpackage}.${xclassname}.${xname}"
334321

335-
// make sure we haven't been told to ignore this
336-
if (ignored.contains(xfullname)) {
337-
logVerbose("Ignoring member \"${xfullname}\" because it was found in the ignore file...")
338-
return ProcessResult.Ignore
339-
}
340-
341322
// before doing any complex checks, make sure it is not an invalid member
342323
if (invalidKeywords.any { check -> check(xname) })
343324
return ProcessResult.RemoveGenerated
@@ -429,12 +410,6 @@ class Processor(xmlFile: File, jarFiles: List<File>, outputFile: File?, ignoreFi
429410
val xtype = xmember.getAttributeValue("type")
430411
val xfullname = "${xpackage}.${xclassname}.${xname}"
431412

432-
// make sure we haven't been told to ignore this
433-
if (ignored.contains(xfullname)) {
434-
logVerbose("Ignoring field \"${xfullname}\" because it was found in the ignore file...")
435-
return ProcessResult.Ignore
436-
}
437-
438413
// before doing any complex checks, make sure it is not an invalid member
439414
if (invalidKeywords.any { check -> check(xname) }) {
440415
return ProcessResult.RemoveGenerated
@@ -792,14 +767,14 @@ private val Element.parentElement: Element
792767

793768
private val KmPackage.functionOverloads: List<Pair<KmFunction, List<KmValueParameter>>>
794769
get() = this.functions.map {
795-
it to it.valueParameters.getOverloads(it.receiverParameterType)
770+
it to it.valueParameters.getOverloads()
796771
}.flatMap { overload ->
797772
overload.second.map { params -> overload.first to params }
798773
}
799774

800775
private val KmClass.functionOverloads: List<Pair<KmFunction, List<KmValueParameter>>>
801776
get() = this.functions.map {
802-
it to it.valueParameters.getOverloads(it.receiverParameterType)
777+
it to it.valueParameters.getOverloads()
803778
}.flatMap { overload ->
804779
overload.second.map { params -> overload.first to params }
805780
}
@@ -811,15 +786,9 @@ private val KmClass.constructorOverloads: List<Pair<KmConstructor, List<KmValueP
811786
overload.second.map { params -> overload.first to params }
812787
}
813788

814-
private fun List<KmValueParameter>.getOverloads(receiverParameterType: KmType? = null): List<List<KmValueParameter>> {
789+
private fun List<KmValueParameter>.getOverloads(): List<List<KmValueParameter>> {
815790
val overloads = mutableListOf<List<KmValueParameter>>()
816-
if (receiverParameterType == null) {
817-
overloads.add(this)
818-
} else {
819-
val t = KmValueParameter(0, "this")
820-
t.type = receiverParameterType
821-
overloads.add(listOf(t) + this)
822-
}
791+
overloads.add(this)
823792
while (Flag.ValueParameter.DECLARES_DEFAULT_VALUE(overloads.last().lastOrNull()?.flags ?: 0)) {
824793
val l = overloads.last()
825794
overloads.add(l.take(l.size - 1))

Util/Xamarin.Kotlin.BindingSupport/source/Xamarin.Kotlin.BindingSupport.targets

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,21 @@
99
<PropertyGroup>
1010
<KotlinBindingSupportJar Condition="'$(KotlinBindingSupportJar)' == ''">$(MSBuildThisFileDirectory)binding-support-1.0.jar</KotlinBindingSupportJar>
1111
<KotlinBindingSupportExtraArgs Condition="'$(KotlinBindingSupportExtraArgs)' == ''"></KotlinBindingSupportExtraArgs>
12-
<KotlinBindingSupportIgnorePath Condition="'$(KotlinBindingSupportIgnorePath)' == ''"></KotlinBindingSupportIgnorePath>
1312
<KotlinBindingSupportOutputPath Condition="'$(KotlinBindingSupportOutputPath)' == ''">$(IntermediateOutputPath)\KotlinBindingSupport.generated.xml</KotlinBindingSupportOutputPath>
1413
</PropertyGroup>
1514

1615
<!-- private properties -->
1716
<PropertyGroup>
1817
<_KotlinBindingJavaPath Condition="'$(_KotlinBindingJavaPath)' == '' and '$(OS)' == 'Unix'">$(JavaSdkDirectory)\bin\java</_KotlinBindingJavaPath>
1918
<_KotlinBindingJavaPath Condition="'$(_KotlinBindingJavaPath)' == '' and '$(OS)' != 'Unix'">$(JavaSdkDirectory)\bin\java.exe</_KotlinBindingJavaPath>
20-
<_KotlinBindingSupportIgnore Condition="'$(KotlinBindingSupportIgnorePath)' != ''">--ignore &quot;$(KotlinBindingSupportIgnorePath)&quot;</_KotlinBindingSupportIgnore>
2119
</PropertyGroup>
2220

2321
<ItemGroup>
2422
<_KotlinBindingReferenceJar Include="@(EmbeddedJar);@(InputJar)" />
2523
<_KotlinBindingReferenceJar Include="@(EmbeddedReferenceJar);@(ReferenceJar);@(_AdditionalJavaLibraryReferences)" />
2624
</ItemGroup>
2725

28-
<Exec Command="&quot;$(_KotlinBindingJavaPath)&quot; -jar &quot;$(KotlinBindingSupportJar)&quot; --xml &quot;$(ApiOutputFile)&quot; --jar &quot;@(_KotlinBindingReferenceJar, '&quot; --jar &quot;')&quot; --output &quot;$(KotlinBindingSupportOutputPath)&quot; $(_KotlinBindingSupportIgnore) $(KotlinBindingSupportExtraArgs)" />
26+
<Exec Command="&quot;$(_KotlinBindingJavaPath)&quot; -jar &quot;$(KotlinBindingSupportJar)&quot; --xml &quot;$(ApiOutputFile)&quot; --jar &quot;@(_KotlinBindingReferenceJar, '&quot; --jar &quot;')&quot; --output &quot;$(KotlinBindingSupportOutputPath)&quot; $(KotlinBindingSupportExtraArgs)" />
2927

3028
<ItemGroup>
3129
<!-- insert the generated transform at the beginning -->

0 commit comments

Comments
 (0)