From ac5d53ef086420ca1e2d900dae3f8062543ac261 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Mon, 7 Sep 2015 18:24:30 +0300 Subject: [PATCH] Starting to refactor JSO --- .../java/org/teavm/dom/browser/Window.java | 5 +- .../org/teavm/dom/indexeddb/IDBIndex.java | 7 +- .../teavm/dom/indexeddb/IDBObjectStore.java | 5 +- teavm-jso/src/main/java/org/teavm/jso/JS.java | 198 ++++++------------ .../src/main/java/org/teavm/jso/JSArray.java | 65 +++--- .../{JSIntArrayReader.java => JSBoolean.java} | 17 +- .../java/org/teavm/jso/JSBooleanArray.java | 73 ------- .../org/teavm/jso/JSBooleanArrayReader.java | 28 --- .../java/org/teavm/jso/JSByteArrayReader.java | 28 --- .../java/org/teavm/jso/JSDoubleArray.java | 77 ------- .../org/teavm/jso/JSDoubleArrayReader.java | 28 --- .../org/teavm/jso/JSDoubleSortFunction.java | 25 --- .../main/java/org/teavm/jso/JSExpression.java | 41 ++++ .../src/main/java/org/teavm/jso/JSGlobal.java | 55 ----- .../main/java/org/teavm/jso/JSIntArray.java | 77 ------- .../java/org/teavm/jso/JSIntSortFunction.java | 25 --- .../src/main/java/org/teavm/jso/JSNumber.java | 54 ++++- .../org/teavm/jso/JSShortArrayReader.java | 28 --- .../java/org/teavm/jso/JSStringArray.java | 77 ------- .../org/teavm/jso/JSStringArrayReader.java | 28 --- .../org/teavm/jso/JSStringSortFunction.java | 25 --- 21 files changed, 217 insertions(+), 749 deletions(-) rename teavm-jso/src/main/java/org/teavm/jso/{JSIntArrayReader.java => JSBoolean.java} (62%) delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSBooleanArray.java delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSBooleanArrayReader.java delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSByteArrayReader.java delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSDoubleArray.java delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSDoubleArrayReader.java delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSDoubleSortFunction.java create mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSExpression.java delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSGlobal.java delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSIntArray.java delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSIntSortFunction.java delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSShortArrayReader.java delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSStringArray.java delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSStringArrayReader.java delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSStringSortFunction.java diff --git a/teavm-dom/src/main/java/org/teavm/dom/browser/Window.java b/teavm-dom/src/main/java/org/teavm/dom/browser/Window.java index 93b28b8a9..8cdd5b4f2 100644 --- a/teavm-dom/src/main/java/org/teavm/dom/browser/Window.java +++ b/teavm-dom/src/main/java/org/teavm/dom/browser/Window.java @@ -19,9 +19,8 @@ import org.teavm.dom.ajax.XMLHttpRequest; import org.teavm.dom.events.EventTarget; import org.teavm.dom.html.HTMLDocument; import org.teavm.dom.json.JSON; -import org.teavm.dom.typedarrays.*; +import org.teavm.dom.typedarrays.TypedArrayFactory; import org.teavm.jso.JSConstructor; -import org.teavm.jso.JSGlobal; import org.teavm.jso.JSObject; import org.teavm.jso.JSProperty; @@ -29,7 +28,7 @@ import org.teavm.jso.JSProperty; * * @author Alexey Andreev */ -public interface Window extends JSGlobal, EventTarget, StorageProvider, TypedArrayFactory { +public interface Window extends JSObject, EventTarget, StorageProvider, TypedArrayFactory { @JSProperty HTMLDocument getDocument(); diff --git a/teavm-dom/src/main/java/org/teavm/dom/indexeddb/IDBIndex.java b/teavm-dom/src/main/java/org/teavm/dom/indexeddb/IDBIndex.java index fd6561067..82f184b02 100644 --- a/teavm-dom/src/main/java/org/teavm/dom/indexeddb/IDBIndex.java +++ b/teavm-dom/src/main/java/org/teavm/dom/indexeddb/IDBIndex.java @@ -16,9 +16,9 @@ package org.teavm.dom.indexeddb; import org.teavm.jso.JS; +import org.teavm.jso.JSBody; import org.teavm.jso.JSObject; import org.teavm.jso.JSProperty; -import org.teavm.jso.JSStringArray; import org.teavm.jso.JSType; /** @@ -37,10 +37,13 @@ public abstract class IDBIndex implements JSObject, IDBCursorSource { if (JS.getType(result) == JSType.STRING) { return new String[] { JS.unwrapString(result) }; } else { - return JS.unwrapStringArray((JSStringArray) result); + return unwrapStringArray(result); } } + @JSBody(params = {}, script = "return this;") + private native String[] unwrapStringArray(JSObject obj); + @JSProperty public abstract boolean isMultiEntry(); diff --git a/teavm-dom/src/main/java/org/teavm/dom/indexeddb/IDBObjectStore.java b/teavm-dom/src/main/java/org/teavm/dom/indexeddb/IDBObjectStore.java index 9c9e30c0e..4ece47aa9 100644 --- a/teavm-dom/src/main/java/org/teavm/dom/indexeddb/IDBObjectStore.java +++ b/teavm-dom/src/main/java/org/teavm/dom/indexeddb/IDBObjectStore.java @@ -33,10 +33,13 @@ public abstract class IDBObjectStore implements JSObject, IDBCursorSource { if (JS.getType(result) == JSType.STRING) { return new String[] { JS.unwrapString(result) }; } else { - return JS.unwrapStringArray((JSStringArray) result); + return unwrapStringArray(result); } } + @JSBody(params = {}, script = "return this;") + private native String[] unwrapStringArray(JSObject obj); + @JSProperty public abstract String[] getIndexNames(); diff --git a/teavm-jso/src/main/java/org/teavm/jso/JS.java b/teavm-jso/src/main/java/org/teavm/jso/JS.java index 1fd5b647b..e6db11c1d 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/JS.java +++ b/teavm-jso/src/main/java/org/teavm/jso/JS.java @@ -49,34 +49,14 @@ public final class JS { throw new AssertionError("Unexpected type"); } - public static JSArray createArray(int size) { - return ((JSGlobal) JS.getGlobal()).newArray(size); - } - - public static JSIntArray createIntArray(int size) { - return ((JSGlobal) JS.getGlobal()).newIntArray(size); - } - - public static JSStringArray createStringArray(int size) { - return ((JSGlobal) JS.getGlobal()).newStringArray(size); - } - - public static JSBooleanArray createBooleanArray(int size) { - return ((JSGlobal) JS.getGlobal()).newBooleanArray(size); - } - - public static JSDoubleArray createDoubleArray(int size) { - return ((JSGlobal) JS.getGlobal()).newDoubleArray(size); - } - - @InjectedBy(JSNativeGenerator.class) - public static native JSObject getTypeName(JSObject obj); + @JSExpression(params = "obj", expr = "typeof(obj)") + private static native JSObject getTypeName(JSObject obj); /** * Gets global JavaScript object, that is similar to the window object in the browser. * @return global object. */ - @InjectedBy(JSNativeGenerator.class) + @JSExpression(params = "obj", expr = "window") public static native JSObject getGlobal(); @InjectedBy(JSNativeGenerator.class) @@ -85,29 +65,11 @@ public final class JS { @InjectedBy(JSNativeGenerator.class) public static native JSObject wrap(char c); - @InjectedBy(JSNativeGenerator.class) - public static native JSObject wrap(int num); - - @InjectedBy(JSNativeGenerator.class) - public static native JSObject wrap(float num); - - @InjectedBy(JSNativeGenerator.class) - public static native JSObject wrap(double num); - - @InjectedBy(JSNativeGenerator.class) - public static native JSObject wrap(boolean num); - - @InjectedBy(JSNativeGenerator.class) - public static native JSObject wrap(byte num); - - @InjectedBy(JSNativeGenerator.class) - public static native JSObject wrap(short num); - @InjectedBy(JSNativeGenerator.class) public static native JSObject marshall(Object obj); public static JSArray wrap(T[] array) { - JSArray result = createArray(array.length); + JSArray result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, array[i]); } @@ -115,7 +77,7 @@ public final class JS { } public static JSArray> wrap(T[][] array) { - JSArray> result = createArray(array.length); + JSArray> result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } @@ -123,71 +85,71 @@ public final class JS { } public static JSArray>> wrap(T[][][] array) { - JSArray>> result = createArray(array.length); + JSArray>> result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } return result; } - public static JSBooleanArray wrap(boolean[] array) { - JSBooleanArray result = createBooleanArray(array.length); + public static JSArray wrap(boolean[] array) { + JSArray result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { - result.set(i, array[i]); + result.set(i, JSBoolean.valueOf(array[i])); } return result; } - public static JSArray wrap(boolean[][] array) { - JSArray result = createArray(array.length); + public static JSArray> wrap(boolean[][] array) { + JSArray> result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } return result; } - public static JSArray> wrap(boolean[][][] array) { - JSArray> result = createArray(array.length); + public static JSArray>> wrap(boolean[][][] array) { + JSArray>> result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } return result; } - public static JSIntArray wrap(byte[] array) { - JSIntArray result = createIntArray(array.length); + public static JSArray wrap(byte[] array) { + JSArray result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { - result.set(i, array[i]); + result.set(i, JSNumber.valueOf(array[i])); } return result; } - public static JSArray wrap(byte[][] array) { - JSArray result = createArray(array.length); + public static JSArray> wrap(byte[][] array) { + JSArray> result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } return result; } - public static JSArray> wrap(byte[][][] array) { - JSArray> result = createArray(array.length); + public static JSArray>> wrap(byte[][][] array) { + JSArray>> result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } return result; } - public static JSIntArray wrap(short[] array) { - JSIntArray result = createIntArray(array.length); + public static JSArray wrap(short[] array) { + JSArray result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { - result.set(i, array[i]); + result.set(i, JSNumber.valueOf(array[i])); } return result; } public static JSArray wrap(short[][] array) { - JSArray result = createArray(array.length); + JSArray result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } @@ -195,7 +157,7 @@ public final class JS { } public static JSArray> wrap(short[][][] array) { - JSArray> result = createArray(array.length); + JSArray> result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } @@ -211,7 +173,7 @@ public final class JS { } public static JSArray wrap(char[][] array) { - JSArray result = createArray(array.length); + JSArray result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } @@ -219,7 +181,7 @@ public final class JS { } public static JSArray> wrap(char[][][] array) { - JSArray> result = createArray(array.length); + JSArray> result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } @@ -235,7 +197,7 @@ public final class JS { } public static JSArray wrap(int[][] array) { - JSArray result = createArray(array.length); + JSArray result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } @@ -243,7 +205,7 @@ public final class JS { } public static JSArray> wrap(int[][][] array) { - JSArray> result = createArray(array.length); + JSArray> result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } @@ -251,7 +213,7 @@ public final class JS { } public static JSStringArray wrap(String[] array) { - JSStringArray result = createStringArray(array.length); + JSStringArray result = JSStringArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, array[i]); } @@ -259,7 +221,7 @@ public final class JS { } public static JSArray wrap(String[][] array) { - JSArray result = createArray(array.length); + JSArray result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } @@ -267,7 +229,7 @@ public final class JS { } public static JSArray> wrap(String[][][] array) { - JSArray> result = createArray(array.length); + JSArray> result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } @@ -283,7 +245,7 @@ public final class JS { } public static JSArray wrap(float[][] array) { - JSArray result = createArray(array.length); + JSArray result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } @@ -291,7 +253,7 @@ public final class JS { } public static JSArray> wrap(float[][][] array) { - JSArray> result = createArray(array.length); + JSArray> result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } @@ -307,7 +269,7 @@ public final class JS { } public static JSArray wrap(double[][] array) { - JSArray result = createArray(array.length); + JSArray result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } @@ -315,33 +277,13 @@ public final class JS { } public static JSArray> wrap(double[][][] array) { - JSArray> result = createArray(array.length); + JSArray> result = JSArray.create(array.length); for (int i = 0; i < array.length; ++i) { result.set(i, wrap(array[i])); } return result; } - @InjectedBy(JSNativeGenerator.class) - public static native boolean unwrapBoolean(JSObject obj); - - public static byte unwrapByte(JSObject obj) { - return (byte) unwrapInt(obj); - } - - public static short unwrapShort(JSObject obj) { - return (short) unwrapInt(obj); - } - - @InjectedBy(JSNativeGenerator.class) - public static native int unwrapInt(JSObject obj); - - @InjectedBy(JSNativeGenerator.class) - public static native float unwrapFloat(JSObject obj); - - @InjectedBy(JSNativeGenerator.class) - public static native double unwrapDouble(JSObject obj); - @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native String unwrapString(JSObject obj); @@ -377,101 +319,101 @@ public final class JS { return result; } - public static String[] unwrapStringArray(JSStringArray array) { - String[] result = new String[array.getLength()]; - for (int i = 0; i < result.length; ++i) { - result[i] = array.get(i); - } - return result; - } - - public static String[][] unwrapStringArray2(JSArray array) { - String[][] result = new String[array.getLength()][]; - for (int i = 0; i < result.length; ++i) { - result[i] = unwrapStringArray(array.get(i)); - } - return result; - } - - public static String[][][] unwrapStringArray3(JSArray> array) { - String[][][] result = new String[array.getLength()][][]; - for (int i = 0; i < result.length; ++i) { - result[i] = unwrapStringArray2(array.get(i)); - } - return result; - } - - @InjectedBy(JSNativeGenerator.class) + @JSExpression(params = "obj", expr = "typeof(obj) === 'undefined'") public static native boolean isUndefined(JSObject obj); + @JSExpression(params = { "instance", "method" }, expr = "instance[method]()") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method); + @JSExpression(params = { "instance", "method", "a" }, expr = "instance[method](a)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a); + @JSExpression(params = { "instance", "method", "a", "b" }, expr = "instance[method](a, b)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a, JSObject b); + @JSExpression(params = { "instance", "method", "a", "b", "c" }, expr = "instance[method](a, b, c)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a, JSObject b, JSObject c); + @JSExpression(params = { "instance", "method", "a", "b", "c", "d" }, expr = "instance[method](a, b, c, d)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a, JSObject b, JSObject c, JSObject d); + @JSExpression(params = { "instance", "method", "a", "b", "c", "d", "e" }, expr = "instance[method](a, b, c, d, e)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a, JSObject b, JSObject c, JSObject d, JSObject e); + @JSExpression(params = { "instance", "method", "a", "b", "c", "d", "e", "f" }, + expr = "instance[method](a, b, c, d, e, f)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a, JSObject b, JSObject c, JSObject d, JSObject e, JSObject f); + @JSExpression(params = { "instance", "method", "a", "b", "c", "d", "e", "f", "g" }, + expr = "instance[method](a, b, c, d, e, f, g)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a, JSObject b, JSObject c, JSObject d, JSObject e, JSObject f, JSObject g); + @JSExpression(params = { "instance", "method", "a", "b", "c", "d", "e", "f", "g", "h" }, + expr = "instance[method](a, b, c, d, e, f, g, h)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a, JSObject b, JSObject c, JSObject d, JSObject e, JSObject f, JSObject g, JSObject h); + @JSExpression(params = { "instance", "method", "a", "b", "c", "d", "e", "f", "g", "h", "i" }, + expr = "instance[method](a, b, c, d, e, f, g, h, i)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a, JSObject b, JSObject c, JSObject d, JSObject e, JSObject f, JSObject g, JSObject h, JSObject i); + @JSExpression(params = { "instance", "method", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" }, + expr = "instance[method](a, b, c, d, e, f, g, h, i, j)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a, JSObject b, JSObject c, JSObject d, JSObject e, JSObject f, JSObject g, JSObject h, JSObject i, JSObject j); + @JSExpression(params = { "instance", "method", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k" }, + expr = "instance[method](a, b, c, d, e, f, g, h, i, j, k)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a, JSObject b, JSObject c, JSObject d, JSObject e, JSObject f, JSObject g, JSObject h, JSObject i, JSObject j, JSObject k); + @JSExpression(params = { "instance", "method", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l" }, + expr = "instance[method](a, b, c, d, e, f, g, h, i, j, k, l)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a, JSObject b, JSObject c, JSObject d, JSObject e, JSObject f, JSObject g, JSObject h, JSObject i, JSObject j, JSObject k, JSObject l); + @JSExpression(params = { "instance", "method", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m" }, + expr = "instance[method](a, b, c, d, e, f, g, h, i, j, k, l, m)") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject invoke(JSObject instance, JSObject method, JSObject a, JSObject b, JSObject c, JSObject d, JSObject e, JSObject f, JSObject g, JSObject h, JSObject i, JSObject j, JSObject k, JSObject l, JSObject m); + @JSExpression(params = { "instance", "method" }, + expr = "new instance[method]()") @InjectedBy(JSNativeGenerator.class) @PluggableDependency(JSNativeGenerator.class) public static native JSObject instantiate(JSObject instance, JSObject constructor); @@ -529,25 +471,11 @@ public final class JS { }; } - public static Iterable iterate(final JSStringArrayReader array) { - return () -> new Iterator() { - int index; - @Override public boolean hasNext() { - return index < array.getLength(); - } - @Override public String next() { - return array.get(index++); - } - @Override public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - - @InjectedBy(JSNativeGenerator.class) + @JSExpression(params = { "instance", "index" }, expr = "instance[index]") public static native JSObject get(JSObject instance, JSObject index); @InjectedBy(JSNativeGenerator.class) + @JSExpression(params = { "instance", "index", "obj" }, expr = "instance[index] = obj") public static native void set(JSObject instance, JSObject index, JSObject obj); @GeneratedBy(JSNativeGenerator.class) diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSArray.java b/teavm-jso/src/main/java/org/teavm/jso/JSArray.java index ff080c26a..a2618b626 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/JSArray.java +++ b/teavm-jso/src/main/java/org/teavm/jso/JSArray.java @@ -20,59 +20,68 @@ package org.teavm.jso; * @author Alexey Andreev * @param */ -public interface JSArray extends JSArrayReader { +public abstract class JSArray implements JSArrayReader { + private JSArray() { + } + @JSIndexer - void set(int index, T value); + public abstract void set(int index, T value); - int push(T a); + public abstract int push(T a); - int push(T a, T b); + public abstract int push(T a, T b); - int push(T a, T b, T c); + public abstract int push(T a, T b, T c); - int push(T a, T b, T c, T d); + public abstract int push(T a, T b, T c, T d); - T shift(); + public abstract T shift(); - String join(String separator); + public abstract String join(String separator); - String join(); + public abstract String join(); - JSArray concat(JSArrayReader a); + public abstract JSArray concat(JSArrayReader a); - JSArray concat(JSArrayReader a, JSArrayReader b); + public abstract JSArray concat(JSArrayReader a, JSArrayReader b); - JSArray concat(JSArrayReader a, JSArrayReader b, JSArrayReader c); + public abstract JSArray concat(JSArrayReader a, JSArrayReader b, JSArrayReader c); - JSArray concat(JSArrayReader a, JSArrayReader b, JSArrayReader c, JSArrayReader d); + public abstract JSArray concat(JSArrayReader a, JSArrayReader b, JSArrayReader c, JSArrayReader d); - T pop(); + public abstract T pop(); - int unshift(T a); + public abstract int unshift(T a); - int unshift(T a, T b); + public abstract int unshift(T a, T b); - int unshift(T a, T b, T c); + public abstract int unshift(T a, T b, T c); - int unshift(T a, T b, T c, T d); + public abstract int unshift(T a, T b, T c, T d); - JSArray slice(int start); + public abstract JSArray slice(int start); - JSArray slice(int start, int end); + public abstract JSArray slice(int start, int end); - JSArray reverse(); + public abstract JSArray reverse(); - JSArray sort(JSSortFunction function); + public abstract JSArray sort(JSSortFunction function); - JSArray sort(); + public abstract JSArray sort(); - JSArray splice(int start, int count); + public abstract JSArray splice(int start, int count); - JSArray splice(int start, int count, T a); + public abstract JSArray splice(int start, int count, T a); - JSArray splice(int start, int count, T a, T b); + public abstract JSArray splice(int start, int count, T a, T b); - JSArray splice(int start, int count, T a, T b, T c); + public abstract JSArray splice(int start, int count, T a, T b, T c); - JSArray splice(int start, int count, T a, T b, T c, T d); + public abstract JSArray splice(int start, int count, T a, T b, T c, T d); + + @JSExpression(params = {}, expr = "new Array()") + public static native JSArray create(); + + @JSExpression(params = "size", expr = "new Array(size)") + public static native JSArray create(int size); } diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSIntArrayReader.java b/teavm-jso/src/main/java/org/teavm/jso/JSBoolean.java similarity index 62% rename from teavm-jso/src/main/java/org/teavm/jso/JSIntArrayReader.java rename to teavm-jso/src/main/java/org/teavm/jso/JSBoolean.java index 768583608..71437778c 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/JSIntArrayReader.java +++ b/teavm-jso/src/main/java/org/teavm/jso/JSBoolean.java @@ -19,10 +19,17 @@ package org.teavm.jso; * * @author Alexey Andreev */ -public interface JSIntArrayReader extends JSObject { - @JSProperty - int getLength(); +public abstract class JSBoolean implements JSObject { + private JSBoolean() { + } - @JSIndexer - int get(int index); + public final boolean booleanValue() { + return booleanValue(this); + } + + @JSExpression(params = "value", expr = "value") + private static native boolean booleanValue(JSBoolean value); + + @JSExpression(params = "value", expr = "value") + public static native JSBoolean valueOf(boolean value); } diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSBooleanArray.java b/teavm-jso/src/main/java/org/teavm/jso/JSBooleanArray.java deleted file mode 100644 index 0daeb6883..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSBooleanArray.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2015 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -public interface JSBooleanArray extends JSBooleanArrayReader { - @JSIndexer - void set(int index, boolean value); - - int push(boolean a); - - int push(boolean a, boolean b); - - int push(boolean a, boolean b, boolean c); - - int push(boolean a, boolean b, boolean c, boolean d); - - boolean shift(); - - String join(String separator); - - String join(); - - JSBooleanArray concat(JSBooleanArrayReader a); - - JSBooleanArray concat(JSBooleanArray a, JSBooleanArray b); - - JSBooleanArray concat(JSBooleanArray a, JSBooleanArray b, JSBooleanArray c); - - JSBooleanArray concat(JSBooleanArray a, JSBooleanArray b, JSBooleanArray c, JSBooleanArray d); - - boolean pop(); - - int unshift(boolean a); - - int unshift(boolean a, boolean b); - - int unshift(boolean a, boolean b, boolean c); - - int unshift(boolean a, boolean b, boolean c, boolean d); - - JSBooleanArray slice(int start); - - JSBooleanArray slice(int start, int end); - - JSBooleanArray reverse(); - - JSBooleanArray splice(int start, int count); - - JSBooleanArray splice(int start, int count, boolean a); - - JSBooleanArray splice(int start, int count, boolean a, boolean b); - - JSBooleanArray splice(int start, int count, boolean a, boolean b, boolean c); - - JSBooleanArray splice(int start, int count, boolean a, boolean b, boolean c, boolean d); -} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSBooleanArrayReader.java b/teavm-jso/src/main/java/org/teavm/jso/JSBooleanArrayReader.java deleted file mode 100644 index 7232f1541..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSBooleanArrayReader.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2015 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -public interface JSBooleanArrayReader extends JSObject { - @JSProperty - int getLength(); - - @JSIndexer - boolean get(int index); -} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSByteArrayReader.java b/teavm-jso/src/main/java/org/teavm/jso/JSByteArrayReader.java deleted file mode 100644 index 007f3786b..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSByteArrayReader.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2015 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -public interface JSByteArrayReader extends JSObject { - @JSProperty - int getLength(); - - @JSIndexer - byte get(int index); -} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSDoubleArray.java b/teavm-jso/src/main/java/org/teavm/jso/JSDoubleArray.java deleted file mode 100644 index 88e10e559..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSDoubleArray.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2015 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -public interface JSDoubleArray extends JSDoubleArrayReader { - @JSIndexer - void set(int index, double value); - - int push(double a); - - int push(double a, double b); - - int push(double a, double b, double c); - - int push(double a, double b, double c, double d); - - double shift(); - - String join(String separator); - - String join(); - - JSDoubleArray concat(JSDoubleArrayReader a); - - JSDoubleArray concat(JSDoubleArray a, JSDoubleArray b); - - JSDoubleArray concat(JSDoubleArray a, JSDoubleArray b, JSDoubleArray c); - - JSDoubleArray concat(JSDoubleArray a, JSDoubleArray b, JSDoubleArray c, JSDoubleArray d); - - double pop(); - - int unshift(double a); - - int unshift(double a, double b); - - int unshift(double a, double b, double c); - - int unshift(double a, double b, double c, double d); - - JSDoubleArray slice(int start); - - JSDoubleArray slice(int start, int end); - - JSDoubleArray reverse(); - - JSDoubleArray sort(JSDoubleSortFunction function); - - JSDoubleArray sort(); - - JSDoubleArray splice(int start, int count); - - JSDoubleArray splice(int start, int count, double a); - - JSDoubleArray splice(int start, int count, double a, double b); - - JSDoubleArray splice(int start, int count, double a, double b, double c); - - JSDoubleArray splice(int start, int count, double a, double b, double c, double d); -} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSDoubleArrayReader.java b/teavm-jso/src/main/java/org/teavm/jso/JSDoubleArrayReader.java deleted file mode 100644 index ec563700a..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSDoubleArrayReader.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2015 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -public interface JSDoubleArrayReader extends JSObject { - @JSProperty - int getLength(); - - @JSIndexer - double get(int index); -} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSDoubleSortFunction.java b/teavm-jso/src/main/java/org/teavm/jso/JSDoubleSortFunction.java deleted file mode 100644 index f9a556760..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSDoubleSortFunction.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2015 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -@JSFunctor -public interface JSDoubleSortFunction { - int compare(double a, double b); -} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSExpression.java b/teavm-jso/src/main/java/org/teavm/jso/JSExpression.java new file mode 100644 index 000000000..1bcea4ca3 --- /dev/null +++ b/teavm-jso/src/main/java/org/teavm/jso/JSExpression.java @@ -0,0 +1,41 @@ +/* + * Copyright 2015 Alexey Andreev. + * + * 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.teavm.jso; + +/** + *

Indicates that method is to have native JavaScript implementation, which can be written as a + * single JavaScript expression. + * Method only can take and return primitive values and {@link JSObject}s. + * JSExpression script can't call Java methods, but you can pass callbacks wrapped into {@link JSFunctor}. + * Note that unless method is static, it must belong to class that implements {@link JSObject}. + * If applied to non-native method, original Java body will be overwritten by JavaScript.

+ * + *

Use this annotation instead of JSBody when possible, since this can increase performance and + * reduce generated JavaScript size.

+ * + * @author Alexey Andreev + */ +public @interface JSExpression { + /** + *

How method parameters are named inside JavaScript implementation.

+ */ + String[] params(); + + /** + *

JavaScript expression.

+ */ + String expr(); +} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSGlobal.java b/teavm-jso/src/main/java/org/teavm/jso/JSGlobal.java deleted file mode 100644 index d97762451..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSGlobal.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2014 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -public interface JSGlobal extends JSObject { - @JSConstructor - JSObject newObject(); - - @JSConstructor - JSArray newArray(); - - @JSConstructor - JSArray newArray(int sz); - - @JSConstructor("Array") - JSStringArray newStringArray(); - - @JSConstructor("Array") - JSStringArray newStringArray(int sz); - - @JSConstructor("Array") - JSBooleanArray newBooleanArray(); - - @JSConstructor("Array") - JSBooleanArray newBooleanArray(int sz); - - @JSConstructor("Array") - JSIntArray newIntArray(); - - @JSConstructor("Array") - JSIntArray newIntArray(int sz); - - @JSConstructor("Array") - JSDoubleArray newDoubleArray(); - - @JSConstructor("Array") - JSDoubleArray newDoubleArray(int sz); -} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSIntArray.java b/teavm-jso/src/main/java/org/teavm/jso/JSIntArray.java deleted file mode 100644 index 14b92a52d..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSIntArray.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2015 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -public interface JSIntArray extends JSIntArrayReader { - @JSIndexer - void set(int index, int value); - - int push(int a); - - int push(int a, int b); - - int push(int a, int b, int c); - - int push(int a, int b, int c, int d); - - int shift(); - - int join(int separator); - - int join(); - - JSIntArray concat(JSIntArrayReader a); - - JSIntArray concat(JSIntArrayReader a, JSIntArrayReader b); - - JSIntArray concat(JSIntArrayReader a, JSIntArrayReader b, JSIntArrayReader c); - - JSIntArray concat(JSIntArrayReader a, JSIntArrayReader b, JSIntArrayReader c, JSIntArrayReader d); - - int pop(); - - int unshift(int a); - - int unshift(int a, int b); - - int unshift(int a, int b, int c); - - int unshift(int a, int b, int c, int d); - - JSIntArray slice(int start); - - JSIntArray slice(int start, int end); - - JSIntArray reverse(); - - JSIntArray sort(JSIntSortFunction function); - - JSIntArray sort(); - - JSIntArray splice(int start, int count); - - JSIntArray splice(int start, int count, int a); - - JSIntArray splice(int start, int count, int a, int b); - - JSIntArray splice(int start, int count, int a, int b, int c); - - JSIntArray splice(int start, int count, int a, int b, int c, int d); -} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSIntSortFunction.java b/teavm-jso/src/main/java/org/teavm/jso/JSIntSortFunction.java deleted file mode 100644 index b89e9c1df..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSIntSortFunction.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2015 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -@JSFunctor -public interface JSIntSortFunction extends JSObject { - int compare(int a, int b); -} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSNumber.java b/teavm-jso/src/main/java/org/teavm/jso/JSNumber.java index b9f6ad434..6f5fde8c0 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/JSNumber.java +++ b/teavm-jso/src/main/java/org/teavm/jso/JSNumber.java @@ -19,5 +19,57 @@ package org.teavm.jso; * * @author Alexey Andreev */ -public interface JSNumber extends JSObject { +public abstract class JSNumber implements JSObject { + private JSNumber() { + } + + public final double doubleValue() { + return doubleValue(this); + } + + @JSExpression(params = "number", expr = "number") + private static native double doubleValue(JSNumber number); + + public final int intValue() { + return intValue(this); + } + + @JSExpression(params = "number", expr = "number") + private static native int intValue(JSNumber number); + + public final byte byteValue() { + return byteValue(this); + } + + @JSExpression(params = "number", expr = "number") + private static native byte byteValue(JSNumber number); + + public final short shortValue() { + return shortValue(this); + } + + @JSExpression(params = "number", expr = "number") + private static native short shortValue(JSNumber number); + + public final float floatValue() { + return floatValue(this); + } + + @JSExpression(params = "number", expr = "number") + private static native float floatValue(JSNumber number); + + @JSExpression(params = "value", expr = "value") + public static native JSNumber valueOf(byte value); + + @JSExpression(params = "value", expr = "value") + public static native JSNumber valueOf(short value); + + @JSExpression(params = "value", expr = "value") + public static native JSNumber valueOf(int value); + + @JSExpression(params = "value", expr = "value") + public static native JSNumber valueOf(float value); + + @JSExpression(params = "value", expr = "value") + public static native JSNumber valueOf(double value); } diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSShortArrayReader.java b/teavm-jso/src/main/java/org/teavm/jso/JSShortArrayReader.java deleted file mode 100644 index 2b9512ad8..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSShortArrayReader.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2015 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -public interface JSShortArrayReader extends JSObject { - @JSProperty - int getLength(); - - @JSIndexer - short get(int index); -} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSStringArray.java b/teavm-jso/src/main/java/org/teavm/jso/JSStringArray.java deleted file mode 100644 index 17a24a805..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSStringArray.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2015 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -public interface JSStringArray extends JSStringArrayReader { - @JSIndexer - void set(int index, String value); - - int push(String a); - - int push(String a, String b); - - int push(String a, String b, String c); - - int push(String a, String b, String c, String d); - - String shift(); - - String join(String separator); - - String join(); - - JSStringArray concat(JSStringArrayReader a); - - JSStringArray concat(JSStringArrayReader a, JSStringArrayReader b); - - JSStringArray concat(JSStringArrayReader a, JSStringArrayReader b, JSStringArrayReader c); - - JSStringArray concat(JSStringArrayReader a, JSStringArrayReader b, JSStringArrayReader c, JSStringArrayReader d); - - String pop(); - - int unshift(String a); - - int unshift(String a, String b); - - int unshift(String a, String b, String c); - - int unshift(String a, String b, String c, String d); - - JSStringArray slice(int start); - - JSStringArray slice(int start, int end); - - JSStringArray reverse(); - - JSStringArray sort(JSStringSortFunction function); - - JSStringArray sort(); - - JSStringArray splice(int start, int count); - - JSStringArray splice(int start, int count, String a); - - JSStringArray splice(int start, int count, String a, String b); - - JSStringArray splice(int start, int count, String a, String b, String c); - - JSStringArray splice(int start, int count, String a, String b, String c, String d); -} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSStringArrayReader.java b/teavm-jso/src/main/java/org/teavm/jso/JSStringArrayReader.java deleted file mode 100644 index 38b9f85ae..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSStringArrayReader.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2015 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -public interface JSStringArrayReader extends JSObject { - @JSProperty - int getLength(); - - @JSIndexer - String get(int index); -} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSStringSortFunction.java b/teavm-jso/src/main/java/org/teavm/jso/JSStringSortFunction.java deleted file mode 100644 index 08d781b53..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSStringSortFunction.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2015 Alexey Andreev. - * - * 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.teavm.jso; - -/** - * - * @author Alexey Andreev - */ -@JSFunctor -public interface JSStringSortFunction extends JSObject { - int compare(String a, String b); -}