diff --git a/generators/src/org/jetbrains/jet/generators/runtime/iterators.kt b/generators/src/org/jetbrains/jet/generators/runtime/iterators.kt new file mode 100644 index 00000000000..6f259b3e121 --- /dev/null +++ b/generators/src/org/jetbrains/jet/generators/runtime/iterators.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2010-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.generators.runtime.iterators + +import org.jetbrains.jet.generators.runtime.* +import java.io.PrintWriter + +enum class IteratorKind { + BYTE + CHAR + SHORT + INT + LONG + FLOAT + DOUBLE + BOOLEAN + + val capitalized: String get() = name().toLowerCase().capitalize() +} + +class GenerateIterators(val out: PrintWriter) { + fun generate() { + generatedBy(out, javaClass.getName()) + for (kind in IteratorKind.values()) { + val s = kind.capitalized + out.println("public abstract class ${s}Iterator : Iterator<$s> {") + out.println(" override final fun next() = next$s()") + out.println() + out.println(" public abstract fun next$s(): $s") + out.println("}") + out.println() + } + } +} + +fun main(args: Array) { + generateRuntimeFile("Iterators.kt") { + GenerateIterators(it).generate() + } +} diff --git a/runtime/kt/Iterators.kt b/runtime/kt/Iterators.kt new file mode 100644 index 00000000000..692c0ae7d53 --- /dev/null +++ b/runtime/kt/Iterators.kt @@ -0,0 +1,52 @@ +// Generated by org.jetbrains.jet.generators.runtime.iterators.GenerateIterators + +package jet + +public abstract class ByteIterator : Iterator { + override final fun next() = nextByte() + + public abstract fun nextByte(): Byte +} + +public abstract class CharIterator : Iterator { + override final fun next() = nextChar() + + public abstract fun nextChar(): Char +} + +public abstract class ShortIterator : Iterator { + override final fun next() = nextShort() + + public abstract fun nextShort(): Short +} + +public abstract class IntIterator : Iterator { + override final fun next() = nextInt() + + public abstract fun nextInt(): Int +} + +public abstract class LongIterator : Iterator { + override final fun next() = nextLong() + + public abstract fun nextLong(): Long +} + +public abstract class FloatIterator : Iterator { + override final fun next() = nextFloat() + + public abstract fun nextFloat(): Float +} + +public abstract class DoubleIterator : Iterator { + override final fun next() = nextDouble() + + public abstract fun nextDouble(): Double +} + +public abstract class BooleanIterator : Iterator { + override final fun next() = nextBoolean() + + public abstract fun nextBoolean(): Boolean +} + diff --git a/runtime/src/jet/BooleanIterator.java b/runtime/src/jet/BooleanIterator.java deleted file mode 100644 index 9b05ad847bb..00000000000 --- a/runtime/src/jet/BooleanIterator.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jet; - -import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver; - -import java.util.Iterator; - -@AssertInvisibleInResolver -public abstract class BooleanIterator implements Iterator { - @Override - public final Boolean next() { - return nextBoolean(); - } - - public abstract boolean nextBoolean(); - - @Override - public void remove() { - throw new UnsupportedOperationException("Mutating method called on a Kotlin Iterator"); - } -} diff --git a/runtime/src/jet/ByteIterator.java b/runtime/src/jet/ByteIterator.java deleted file mode 100644 index 00f5309f8ed..00000000000 --- a/runtime/src/jet/ByteIterator.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jet; - -import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver; - -import java.util.Iterator; - -@AssertInvisibleInResolver -public abstract class ByteIterator implements Iterator { - @Override - public final Byte next() { - return nextByte(); - } - - public abstract byte nextByte(); - - @Override - public void remove() { - throw new UnsupportedOperationException("Mutating method called on a Kotlin Iterator"); - } -} diff --git a/runtime/src/jet/CharIterator.java b/runtime/src/jet/CharIterator.java deleted file mode 100644 index 03f7cfccad5..00000000000 --- a/runtime/src/jet/CharIterator.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jet; - -import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver; - -import java.util.Iterator; - -@AssertInvisibleInResolver -public abstract class CharIterator implements Iterator { - @Override - public final Character next() { - return nextChar(); - } - - public abstract char nextChar(); - - @Override - public void remove() { - throw new UnsupportedOperationException("Mutating method called on a Kotlin Iterator"); - } -} diff --git a/runtime/src/jet/DoubleIterator.java b/runtime/src/jet/DoubleIterator.java deleted file mode 100644 index 2805cb4d33a..00000000000 --- a/runtime/src/jet/DoubleIterator.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jet; - -import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver; - -import java.util.Iterator; - -@AssertInvisibleInResolver -public abstract class DoubleIterator implements Iterator { - @Override - public final Double next() { - return nextDouble(); - } - - public abstract double nextDouble(); - - @Override - public void remove() { - throw new UnsupportedOperationException("Mutating method called on a Kotlin Iterator"); - } -} diff --git a/runtime/src/jet/FloatIterator.java b/runtime/src/jet/FloatIterator.java deleted file mode 100644 index 39bc8c0fd1d..00000000000 --- a/runtime/src/jet/FloatIterator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jet; - -import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver; - -import java.util.Iterator; - -@AssertInvisibleInResolver -public abstract class FloatIterator implements Iterator { - @Override - public final Float next() { - return nextFloat(); - } - - public abstract float nextFloat(); - - - @Override - public void remove() { - throw new UnsupportedOperationException("Mutating method called on a Kotlin Iterator"); - } -} diff --git a/runtime/src/jet/IntIterator.java b/runtime/src/jet/IntIterator.java deleted file mode 100644 index 515d9501af5..00000000000 --- a/runtime/src/jet/IntIterator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jet; - -import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver; - -import java.util.Iterator; - -@AssertInvisibleInResolver -public abstract class IntIterator implements Iterator { - @Override - public final Integer next() { - return nextInt(); - } - - public abstract int nextInt(); - - - @Override - public void remove() { - throw new UnsupportedOperationException("Mutating method called on a Kotlin Iterator"); - } -} diff --git a/runtime/src/jet/LongIterator.java b/runtime/src/jet/LongIterator.java deleted file mode 100644 index 3a29bdb031e..00000000000 --- a/runtime/src/jet/LongIterator.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jet; - -import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver; - -import java.util.Iterator; - -@AssertInvisibleInResolver -public abstract class LongIterator implements Iterator { - @Override - public final Long next() { - return nextLong(); - } - - public abstract long nextLong(); - - @Override - public void remove() { - throw new UnsupportedOperationException("Mutating method called on a Kotlin Iterator"); - } -} diff --git a/runtime/src/jet/ShortIterator.java b/runtime/src/jet/ShortIterator.java deleted file mode 100644 index 67b572c9902..00000000000 --- a/runtime/src/jet/ShortIterator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jet; - -import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver; - -import java.util.Iterator; - -@AssertInvisibleInResolver -public abstract class ShortIterator implements Iterator { - @Override - public final Short next() { - return nextShort(); - } - - public abstract short nextShort(); - - - @Override - public void remove() { - throw new UnsupportedOperationException("Mutating method called on a Kotlin Iterator"); - } -}