refactored the JS kotlin code so that we've a simple naming convention (*Code.kt") to refer to library code which needs to generate JS code to separate those files from the pure definitions which just refer to existing JS code already - this will help make it easier to keep the maven build and the js test cases in sync
This commit is contained in:
@@ -35,10 +35,12 @@ public trait Runnable {
|
|||||||
public open fun run() : Unit;
|
public open fun run() : Unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
library
|
||||||
public trait Comparable<T> {
|
public trait Comparable<T> {
|
||||||
public fun compareTo(that: T): Int
|
public fun compareTo(that: T): Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
library
|
||||||
public trait Appendable {
|
public trait Appendable {
|
||||||
public open fun append(csq: CharSequence?): Appendable?
|
public open fun append(csq: CharSequence?): Appendable?
|
||||||
public open fun append(csq: CharSequence?, start: Int, end: Int): Appendable?
|
public open fun append(csq: CharSequence?, start: Int, end: Int): Appendable?
|
||||||
|
|||||||
@@ -17,48 +17,12 @@ public trait Iterator<T> {
|
|||||||
open public fun remove() : Unit = js.noImpl
|
open public fun remove() : Unit = js.noImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Collections {
|
|
||||||
library("collectionsMax")
|
|
||||||
public fun max<T>(col : Collection<T>, comp : Comparator<T>) : T = js.noImpl
|
|
||||||
|
|
||||||
// TODO should be immutable!
|
|
||||||
public val emptyList: List<Any> = ArrayList<Any>()
|
|
||||||
public val emptyMap: Map<Any, Any> = HashMap<Any,Any>()
|
|
||||||
|
|
||||||
public val <T> EMPTY_LIST: List<T>
|
|
||||||
get() = emptyList<T>()
|
|
||||||
|
|
||||||
public val <K,V> EMPTY_MAP: Map<K,V>
|
|
||||||
get() = emptyMap<K,V>()
|
|
||||||
|
|
||||||
public fun <T> emptyList(): List<T> = emptyList as List<T>
|
|
||||||
public fun <K,V> emptyMap(): Map<K,V> = emptyMap as Map<K,V>
|
|
||||||
|
|
||||||
public fun <in T> sort(list: List<T>): Unit {
|
|
||||||
throw UnsupportedOperationException()
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun <in T> sort(list: List<T>, comparator: java.util.Comparator<T>): Unit {
|
|
||||||
throw UnsupportedOperationException()
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun <T> reverse(list: List<T>): Unit {
|
|
||||||
val size = list.size()
|
|
||||||
for (i in 0.upto(size / 2)) {
|
|
||||||
val i2 = size - i
|
|
||||||
val tmp = list[i]
|
|
||||||
list[i] = list[i2]
|
|
||||||
list[i2] = tmp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
library
|
library
|
||||||
public trait Collection<E>: Iterable<E> {
|
public trait Collection<E>: Iterable<E> {
|
||||||
open public fun size(): Int
|
open public fun size(): Int
|
||||||
open public fun isEmpty(): Boolean
|
open public fun isEmpty(): Boolean
|
||||||
open public fun contains(o: Any?): Boolean
|
open public fun contains(o: Any?): Boolean
|
||||||
override public fun iterator(): Iterator<E>
|
override public fun iterator(): java.util.Iterator<E>
|
||||||
public fun toArray(): Array<E>
|
public fun toArray(): Array<E>
|
||||||
// open public fun toArray<T>(a : Array<out T>) : Array<T>
|
// open public fun toArray<T>(a : Array<out T>) : Array<T>
|
||||||
open public fun add(e: E): Boolean
|
open public fun add(e: E): Boolean
|
||||||
@@ -76,7 +40,7 @@ public abstract class AbstractCollection<E>() : Collection<E> {
|
|||||||
|
|
||||||
override public fun isEmpty(): Boolean = js.noImpl
|
override public fun isEmpty(): Boolean = js.noImpl
|
||||||
override public fun contains(o: Any?): Boolean = js.noImpl
|
override public fun contains(o: Any?): Boolean = js.noImpl
|
||||||
override public fun iterator(): Iterator<E> = js.noImpl
|
override public fun iterator(): java.util.Iterator<E> = js.noImpl
|
||||||
|
|
||||||
override public fun add(e: E): Boolean = js.noImpl
|
override public fun add(e: E): Boolean = js.noImpl
|
||||||
override public fun remove(o: Any?): Boolean = js.noImpl
|
override public fun remove(o: Any?): Boolean = js.noImpl
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package java.util
|
||||||
|
|
||||||
|
import java.lang.*
|
||||||
|
|
||||||
|
public object Collections {
|
||||||
|
library("collectionsMax")
|
||||||
|
public fun max<T>(col : Collection<T>, comp : Comparator<T>) : T = js.noImpl
|
||||||
|
|
||||||
|
// TODO should be immutable!
|
||||||
|
public val emptyList: List<Any> = ArrayList<Any>()
|
||||||
|
public val emptyMap: Map<Any, Any> = HashMap<Any,Any>()
|
||||||
|
|
||||||
|
public val <T> EMPTY_LIST: List<T>
|
||||||
|
get() = emptyList<T>()
|
||||||
|
|
||||||
|
public val <K,V> EMPTY_MAP: Map<K,V>
|
||||||
|
get() = emptyMap<K,V>()
|
||||||
|
|
||||||
|
public fun <T> emptyList(): List<T> = emptyList as List<T>
|
||||||
|
public fun <K,V> emptyMap(): Map<K,V> = emptyMap as Map<K,V>
|
||||||
|
|
||||||
|
public fun <in T> sort(list: List<T>): Unit {
|
||||||
|
throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun <in T> sort(list: List<T>, comparator: java.util.Comparator<T>): Unit {
|
||||||
|
throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun <T> reverse(list: List<T>): Unit {
|
||||||
|
val size = list.size()
|
||||||
|
for (i in 0.upto(size / 2)) {
|
||||||
|
val i2 = size - i
|
||||||
|
val tmp = list[i]
|
||||||
|
list[i] = list[i2]
|
||||||
|
list[i2] = tmp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,8 @@ native public fun String.indexOf(str : String, fromIndex : Int) : Int = js.noImp
|
|||||||
native public fun String.lastIndexOf(str: String) : Int = js.noImpl
|
native public fun String.lastIndexOf(str: String) : Int = js.noImpl
|
||||||
native public fun String.lastIndexOf(str : String, fromIndex : Int) : Int = js.noImpl
|
native public fun String.lastIndexOf(str : String, fromIndex : Int) : Int = js.noImpl
|
||||||
|
|
||||||
native public fun String.split(regex : String) : Array<String> = js.noImpl
|
// Defined in javalang.kt
|
||||||
|
//native public fun String.split(regex : String) : Array<String> = js.noImpl
|
||||||
|
|
||||||
native public fun String.substring(beginIndex : Int) : String = js.noImpl
|
native public fun String.substring(beginIndex : Int) : String = js.noImpl
|
||||||
native public fun String.substring(beginIndex : Int, endIndex : Int) : String = js.noImpl
|
native public fun String.substring(beginIndex : Int, endIndex : Int) : String = js.noImpl
|
||||||
@@ -56,28 +56,31 @@ public abstract class Config {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public static final List<String> LIB_FILES_WITH_DECLARATIONS = Arrays.asList(
|
public static final List<String> LIB_FILES_WITH_DECLARATIONS = Arrays.asList(
|
||||||
"/core/annotations.kt",
|
"/core/annotations.kt",
|
||||||
"/jquery/common.kt",
|
|
||||||
"/jquery/ui.kt",
|
|
||||||
"/core/javautil.kt",
|
|
||||||
"/core/javalang.kt",
|
|
||||||
"/core/javaio.kt",
|
|
||||||
"/core/kotlin.kt",
|
|
||||||
"/core/date.kt",
|
|
||||||
"/core/core.kt",
|
"/core/core.kt",
|
||||||
"/core/math.kt",
|
"/core/date.kt",
|
||||||
"/core/json.kt",
|
|
||||||
"/stdlib/browser.kt",
|
|
||||||
"/core/dom.kt",
|
"/core/dom.kt",
|
||||||
|
"/core/javaio.kt",
|
||||||
|
"/core/javalang.kt",
|
||||||
|
"/core/javautil.kt",
|
||||||
|
"/core/json.kt",
|
||||||
|
"/core/kotlin.kt",
|
||||||
|
"/core/math.kt",
|
||||||
|
"/core/string.kt",
|
||||||
"/dom/domcore.kt",
|
"/dom/domcore.kt",
|
||||||
"/dom/html/htmlcore.kt",
|
"/dom/html/htmlcore.kt",
|
||||||
"/dom/html5/canvas.kt",
|
"/dom/html5/canvas.kt",
|
||||||
"/dom/html/window.kt",
|
"/dom/html/window.kt",
|
||||||
|
"/jquery/common.kt",
|
||||||
|
"/jquery/ui.kt",
|
||||||
"/junit/core.kt",
|
"/junit/core.kt",
|
||||||
"/qunit/core.kt"
|
"/qunit/core.kt",
|
||||||
|
"/stdlib/browser.kt"
|
||||||
);
|
);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static final List<String> LIB_FILES_WITH_CODE = Lists.newArrayList();
|
public static final List<String> LIB_FILES_WITH_CODE = Arrays.asList(
|
||||||
|
"/core/javautilCode.kt"
|
||||||
|
);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static final List<String> LIB_FILE_NAMES = Lists.newArrayList();
|
public static final List<String> LIB_FILE_NAMES = Lists.newArrayList();
|
||||||
@@ -91,12 +94,11 @@ public abstract class Config {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static final List<String> LIB_FILE_NAMES_DEPENDENT_ON_STDLIB = Arrays.asList(
|
public static final List<String> LIB_FILE_NAMES_DEPENDENT_ON_STDLIB = Arrays.asList(
|
||||||
"/stdlib/dom.kt",
|
"/core/stringsCode.kt",
|
||||||
"/stdlib/jutil.kt",
|
"/stdlib/domCode.kt",
|
||||||
//"/stdlib/JUMaps.kt",
|
"/stdlib/jutilCode.kt",
|
||||||
"/stdlib/test.kt",
|
//"/stdlib/JUMapsCode.kt",
|
||||||
"/core/stringDefs.kt",
|
"/stdlib/testCode.kt"
|
||||||
"/core/strings.kt"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final String LIBRARIES_LOCATION = "js/js.libraries/src";
|
public static final String LIBRARIES_LOCATION = "js/js.libraries/src";
|
||||||
|
|||||||
@@ -161,6 +161,24 @@ var kotlin = {set:function (receiver, key, value) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Kotlin.Runnable = Kotlin.$createClass({
|
||||||
|
initialize: function () {
|
||||||
|
},
|
||||||
|
run: throwAbstractFunctionInvocationError
|
||||||
|
});
|
||||||
|
|
||||||
|
Kotlin.Comparable = Kotlin.$createClass({
|
||||||
|
initialize: function () {
|
||||||
|
},
|
||||||
|
compareTo: throwAbstractFunctionInvocationError
|
||||||
|
});
|
||||||
|
|
||||||
|
Kotlin.Appendable = Kotlin.$createClass({
|
||||||
|
initialize: function () {
|
||||||
|
},
|
||||||
|
append: throwAbstractFunctionInvocationError
|
||||||
|
});
|
||||||
|
|
||||||
Kotlin.parseInt = function (str) {
|
Kotlin.parseInt = function (str) {
|
||||||
return parseInt(str, 10);
|
return parseInt(str, 10);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,25 +31,20 @@
|
|||||||
<mkdir dir="${basedir}/target/generated-js-definitions"/>
|
<mkdir dir="${basedir}/target/generated-js-definitions"/>
|
||||||
<copy todir="${basedir}/target/generated-js-definitions">
|
<copy todir="${basedir}/target/generated-js-definitions">
|
||||||
<fileset dir="${kotlin-js-lib-srcdir}">
|
<fileset dir="${kotlin-js-lib-srcdir}">
|
||||||
|
<exclude name="**/*Code.kt"/>
|
||||||
<exclude name="core/dom/core.kt"/>
|
<exclude name="core/dom/core.kt"/>
|
||||||
<exclude name="core/strings.kt"/>
|
|
||||||
<exclude name="html5/localstorage.kt"/>
|
<exclude name="html5/localstorage.kt"/>
|
||||||
<exclude name="jquery/common.kt"/>
|
<exclude name="jquery/common.kt"/>
|
||||||
<exclude name="jquery/ui.kt"/>
|
<exclude name="jquery/ui.kt"/>
|
||||||
<exclude name="dom/html/htmlcore.kt"/>
|
<exclude name="dom/html/htmlcore.kt"/>
|
||||||
<exclude name="dom/html5/canvas.kt"/>
|
<exclude name="dom/html5/canvas.kt"/>
|
||||||
<exclude name="dom/html/window.kt"/>
|
<exclude name="dom/html/window.kt"/>
|
||||||
<exclude name="stdlib/test.kt"/>
|
|
||||||
<exclude name="stdlib/dom.kt"/>
|
|
||||||
<exclude name="stdlib/jutil.kt"/>
|
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
<copy todir="${basedir}/target/generated-js-library">
|
<copy todir="${basedir}/target/generated-js-library">
|
||||||
<fileset dir="${kotlin-js-lib-srcdir}">
|
<fileset dir="${kotlin-js-lib-srcdir}">
|
||||||
<include name="stdlib/test.kt"/>
|
<include name="**/*Code.kt"/>
|
||||||
<include name="stdlib/jutil.kt"/>
|
<exclude name="**/JUtilMapsCode.kt"/>
|
||||||
<include name="stdlib/dom.kt"/>
|
|
||||||
<include name="core/strings.kt"/>
|
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
<copy todir="${basedir}/target/generated-js-library/kotlin">
|
<copy todir="${basedir}/target/generated-js-library/kotlin">
|
||||||
@@ -70,16 +65,22 @@
|
|||||||
<include name="Iterators.kt"/>
|
<include name="Iterators.kt"/>
|
||||||
<include name="JUtil.kt"/>
|
<include name="JUtil.kt"/>
|
||||||
<include name="JUtilCollections.kt"/>
|
<include name="JUtilCollections.kt"/>
|
||||||
|
<!--
|
||||||
<include name="JUtilMaps.kt"/>
|
<include name="JUtilMaps.kt"/>
|
||||||
|
-->
|
||||||
<include name="JLangIterables.kt"/>
|
<include name="JLangIterables.kt"/>
|
||||||
<include name="JLangIterablesLazy.kt"/>
|
<include name="JLangIterablesLazy.kt"/>
|
||||||
<include name="JLangIterablesSpecial.kt"/>
|
<include name="JLangIterablesSpecial.kkt"/>
|
||||||
<!--
|
<!--
|
||||||
<include name="Ordering.kt"/>
|
<include name="Ordering.kt"/>
|
||||||
-->
|
-->
|
||||||
<include name="Standard.kt"/>
|
<include name="Standard.kt"/>
|
||||||
<include name="Strings.kt"/>
|
<include name="Strings.kt"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
|
<fileset dir="${basedir}/../../stdlib/src/generated">
|
||||||
|
<include name="JUtilIteratorsFromJLangIterables.kt"/>
|
||||||
|
<include name="JUtilIterablesFromJUtilCollections.kt"/>
|
||||||
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
<copy tofile="${basedir}/target/generated-js-library/kotlin-lib.js"
|
<copy tofile="${basedir}/target/generated-js-library/kotlin-lib.js"
|
||||||
file="${kotlin-js-lib-srcdir}/../../js.translator/testFiles/kotlin_lib.js"/>
|
file="${kotlin-js-lib-srcdir}/../../js.translator/testFiles/kotlin_lib.js"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user