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:
James Strachan
2012-07-05 10:34:00 +01:00
parent 038f79a77a
commit 925e5b2236
12 changed files with 93 additions and 66 deletions
+2
View File
@@ -35,10 +35,12 @@ public trait Runnable {
public open fun run() : Unit;
}
library
public trait Comparable<T> {
public fun compareTo(that: T): Int
}
library
public trait Appendable {
public open fun append(csq: CharSequence?): Appendable?
public open fun append(csq: CharSequence?, start: Int, end: Int): Appendable?
+2 -38
View File
@@ -17,48 +17,12 @@ public trait Iterator<T> {
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
public trait Collection<E>: Iterable<E> {
open public fun size(): Int
open public fun isEmpty(): 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>
// open public fun toArray<T>(a : Array<out T>) : Array<T>
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 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 remove(o: Any?): Boolean = js.noImpl
+39
View File
@@ -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, 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, endIndex : Int) : String = js.noImpl