making progress on porting kotlin/dom to JS; added AbstractList and RuntimeException/UnsupportedOperationException support to the kotlin-lib.js and fixed up a gremlin (Iterator is a trait not a class)
This commit is contained in:
@@ -16,7 +16,7 @@ public fun comparator<T>(f : (T, T) -> Int) : Comparator<T> = js.noImpl
|
||||
|
||||
|
||||
library
|
||||
public open class Iterator<T>() {
|
||||
public trait Iterator<T> {
|
||||
open fun next() : T = js.noImpl
|
||||
open fun hasNext() : Boolean = js.noImpl
|
||||
open fun remove() : Unit = js.noImpl
|
||||
@@ -67,6 +67,14 @@ public trait Collection<erased E> : java.lang.Iterable<E> {
|
||||
open fun clear() : Unit
|
||||
}
|
||||
|
||||
library
|
||||
public abstract open class AbstractCollection<erased E> : Collection<E> {
|
||||
}
|
||||
|
||||
library
|
||||
public abstract open class AbstractList<erased E> : AbstractCollection<E>, List<E> {
|
||||
}
|
||||
|
||||
library
|
||||
public trait List<erased E> : Collection<E> {
|
||||
override fun size() : Int
|
||||
|
||||
@@ -286,14 +286,16 @@ var Kotlin;
|
||||
|
||||
Kotlin.Exceptions = {};
|
||||
Kotlin.Exception = Kotlin.Class.create();
|
||||
Kotlin.RuntimeException = Kotlin.Class.create(Kotlin.Exception);
|
||||
Kotlin.Exceptions.IndexOutOfBounds = Kotlin.Class.create(Kotlin.Exception);
|
||||
Kotlin.Exceptions.NullPointerException = Kotlin.Class.create(Kotlin.Exception);
|
||||
Kotlin.Exceptions.UnsupportedOperationException = Kotlin.Class.create(Kotlin.Exception);
|
||||
Kotlin.Exceptions.NoSuchElementException = Kotlin.Class.create(Kotlin.Exception);
|
||||
|
||||
Kotlin.throwNPE = function() {
|
||||
throw new Kotlin.Exceptions.NullPointerException();
|
||||
};
|
||||
|
||||
|
||||
Kotlin.ArrayList = Class.create({
|
||||
initialize:function () {
|
||||
this.array = [];
|
||||
@@ -358,6 +360,50 @@ var Kotlin;
|
||||
});
|
||||
|
||||
|
||||
Kotlin.AbstractList = Class.create({
|
||||
set:function (index, value) {
|
||||
throw new Kotlin.Exceptions.UnsupportedOperationException();
|
||||
},
|
||||
iterator:function () {
|
||||
return new Kotlin.ArrayIterator(this);
|
||||
},
|
||||
isEmpty:function () {
|
||||
return (this.size() === 0);
|
||||
},
|
||||
add:function (element) {
|
||||
throw new Kotlin.Exceptions.UnsupportedOperationException();
|
||||
},
|
||||
addAll:function (collection) {
|
||||
var it = collection.iterator();
|
||||
while (it.hasNext()) {
|
||||
this.add(it.next());
|
||||
}
|
||||
},
|
||||
remove:function(value) {
|
||||
for (var i = 0; i < this.$size; ++i) {
|
||||
if (this.array[i] == value) {
|
||||
this.removeByIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
removeByIndex:function (index) {
|
||||
throw new Kotlin.Exceptions.UnsupportedOperationException();
|
||||
},
|
||||
clear:function () {
|
||||
throw new Kotlin.Exceptions.UnsupportedOperationException();
|
||||
},
|
||||
contains:function (obj) {
|
||||
for (var i = 0; i < this.$size; ++i) {
|
||||
if (Kotlin.equals(this.array[i], obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Kotlin.parseInt = function (str) {
|
||||
return parseInt(str, 10);
|
||||
}
|
||||
@@ -444,6 +490,7 @@ var Kotlin;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Kotlin.RangeIterator = Kotlin.Class.create(Kotlin.Iterator, {
|
||||
initialize:function (start, count, reversed) {
|
||||
this.$start = start;
|
||||
|
||||
Reference in New Issue
Block a user