more of the stdlib compiling to JS

This commit is contained in:
James Strachan
2012-06-23 06:58:40 +01:00
parent b712719ae4
commit 4a4cf0467f
5 changed files with 10 additions and 11 deletions
-1
View File
@@ -21,7 +21,6 @@ public trait Iterator<T> {
open fun remove() : Unit = js.noImpl
}
library
val Collections = object {
library("collectionsMax")
public fun max<T>(col : Collection<T>, comp : Comparator<T>) : T = js.noImpl
@@ -39,6 +39,7 @@ public class StdLibTestToJSTest extends StdLibTestSupport {
generateJavaScriptFiles(EcmaVersion.all(),
"libraries/stdlib/test",
"ListTest.kt",
"StringTest.kt",
"js/SimpleTest.kt");
}
@@ -40,8 +40,7 @@ public class StdLibToJSTest extends StdLibTestSupport {
generateJavaScriptFiles(EcmaVersion.all(),
"libraries/stdlib/src",
"kotlin/Preconditions.kt",
// TODO re-enable when we've got the filter stuff ported to JS
//"kotlin/dom/Dom.kt",
"kotlin/dom/Dom.kt",
"kotlin/support/AbstractIterator.kt");
}
}
+8 -6
View File
@@ -11,6 +11,9 @@ import java.lang.IndexOutOfBoundsException
// Properties
private val EmptyElementList: List<Element> = Collections.emptyList<Element>()!!
private val EmptyNodeList: List<Node> = Collections.emptyList<Node>()!!
var Node.text : String
get() {
return textContent
@@ -120,8 +123,7 @@ inline fun Document?.elements(namespaceUri: String, localName: String): List<Ele
inline fun NodeList?.toList(): List<Node> {
return if (this == null) {
// TODO the following is easier to convert to JS
//Collections.EMPTY_LIST as List<Node>
ArrayList<Node>()
EmptyNodeList
}
else {
NodeListAsList(this)
@@ -131,7 +133,7 @@ inline fun NodeList?.toList(): List<Node> {
inline fun NodeList?.toElementList(): List<Element> {
return if (this == null) {
// TODO the following is easier to convert to JS
//Collections.EMPTY_LIST as List<Element>
//EmptyElementList
ArrayList<Element>()
}
else {
@@ -153,13 +155,13 @@ fun Document?.get(selector: String): List<Element> {
return if (element != null)
arrayList<Element>(element)
else
Collections.EMPTY_LIST as List<Element>
EmptyElementList
} else {
// assume its a vanilla element name
elements(selector)
}
} else {
Collections.EMPTY_LIST as List<Element>
EmptyElementList
}
}
@@ -174,7 +176,7 @@ fun Element.get(selector: String): List<Element> {
return if (element != null)
arrayList<Element>(element)
else
Collections.EMPTY_LIST as List<Element>
EmptyElementList
} else {
// assume its a vanilla element name
elements(selector)
@@ -53,12 +53,10 @@
</fileset>
</copy>
<copy todir="${basedir}/target/generated-js-library/kotlin">
<!--
<fileset dir="${basedir}/../../stdlib/src/kotlin/dom">
<include name="**/*.kt"/>
<exclude name="**/*JVM.kt"/>
</fileset>
-->
<fileset dir="${basedir}/../../stdlib/src/kotlin/support">
<include name="**/*.kt"/>
<exclude name="**/*JVM.kt"/>