diff --git a/teavm-jso-impl/src/main/java/org/teavm/jso/plugin/JS.java b/teavm-jso-impl/src/main/java/org/teavm/jso/plugin/JS.java
index 9d1c2026b..8e3bd8901 100644
--- a/teavm-jso-impl/src/main/java/org/teavm/jso/plugin/JS.java
+++ b/teavm-jso-impl/src/main/java/org/teavm/jso/plugin/JS.java
@@ -22,7 +22,6 @@ import org.teavm.javascript.spi.GeneratedBy;
import org.teavm.javascript.spi.InjectedBy;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
-import org.teavm.jso.JSType;
import org.teavm.jso.core.JSArray;
import org.teavm.jso.core.JSArrayReader;
import org.teavm.jso.core.JSBoolean;
@@ -38,27 +37,6 @@ final class JS {
private JS() {
}
- public static JSType getType(JSObject obj) {
- switch (unwrapString(getTypeName(obj))) {
- case "boolean":
- return JSType.OBJECT;
- case "number":
- return JSType.NUMBER;
- case "string":
- return JSType.STRING;
- case "function":
- return JSType.FUNCTION;
- case "object":
- return JSType.OBJECT;
- case "undefined":
- return JSType.UNDEFINED;
- }
- throw new AssertionError("Unexpected type");
- }
-
- @JSBody(params = "obj", script = "return 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.
diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSConstructor.java b/teavm-jso/src/main/java/org/teavm/jso/JSConstructor.java
index 3e5cf7240..76b25140c 100644
--- a/teavm-jso/src/main/java/org/teavm/jso/JSConstructor.java
+++ b/teavm-jso/src/main/java/org/teavm/jso/JSConstructor.java
@@ -21,6 +21,14 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
+ *
Marks abstract member method as a JavaScript constructor. This is equivalent to the following:
+ * + *{@code + * @JSBody(params = ..., script = "return new this.constructorName(...);") + * }+ * + *
where constructorName
is method's name by default or a name, directly specified by
+ * this annotation.
Marks abstract member method either as an getter indexer or setter indexer.
+ * + *Getter indexer is a method that returns value and takes exactly one parameter. In + * this case annotation is equivalent to this:
+ * + *{@code + * @JSBody(params = "index", script = "return this[index];") + * }+ * + *
Setter indexer is a method that takes two parameter and does not return any value. + * Ins this case annotation is equivalent to the following:
+ * + *{@code + * @JSBody(params = { "index", "value" }, script = "this[index] = value;") + * }* * @author Alexey Andreev */ diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSMethod.java b/teavm-jso/src/main/java/org/teavm/jso/JSMethod.java index 185ea626f..9029492ec 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/JSMethod.java +++ b/teavm-jso/src/main/java/org/teavm/jso/JSMethod.java @@ -21,6 +21,14 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** + *
Marks abstract member method as a JavaScript method. This is equivalent to the following:
+ * + *{@code + * @JSBody(params = ..., script = "return new this.methodName(...);") + * }+ * + *
where methodName
is method's name by default or a name, directly specified by
+ * this annotation.
Marks abstract member method as either a getter or a setter.
+ * + *Getter's name must conform the Java Beans specification, i.e. start with get
prefix
+ * (or is
in case of boolean getter). It must not take any parameters and must return a value.
+ * For getter annotation is equivalent to the following:
{@code + * @JSBody(params = {}, script = "return this.propertyName;") + * }+ * + *
Setter's name must conform the Java Beans specification, i.e. start with set
prefix
+ * It must take exactly one parameter and must not return a value.
+ * For setter annotation is equivalent to the following:
{@code + * @JSBody(params = "value", script = "this.propertyName = value;") + * }+ * + *
By default propertyName
is calculated from method's name according to Java Beans specification,
+ * otherwise the name specified by annotation is taken.