From 0064abeab79eb1456a75494dc844433ab9b67a1e Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 8 Sep 2015 22:04:26 +0300 Subject: [PATCH] Add javadocs to JSO annotations --- .../main/java/org/teavm/jso/plugin/JS.java | 22 -------------- .../java/org/teavm/jso/JSConstructor.java | 8 +++++ .../main/java/org/teavm/jso/JSIndexer.java | 15 ++++++++++ .../src/main/java/org/teavm/jso/JSMethod.java | 8 +++++ .../main/java/org/teavm/jso/JSProperty.java | 20 +++++++++++++ .../src/main/java/org/teavm/jso/JSType.java | 29 ------------------- 6 files changed, 51 insertions(+), 51 deletions(-) delete mode 100644 teavm-jso/src/main/java/org/teavm/jso/JSType.java 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.

* * @author Alexey Andreev */ diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSIndexer.java b/teavm-jso/src/main/java/org/teavm/jso/JSIndexer.java index 18bdf0e8a..7f07f22ec 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/JSIndexer.java +++ b/teavm-jso/src/main/java/org/teavm/jso/JSIndexer.java @@ -21,6 +21,21 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** + *

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.

* * @author Alexey Andreev */ diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSProperty.java b/teavm-jso/src/main/java/org/teavm/jso/JSProperty.java index c61a89ebe..7cdfc6b24 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/JSProperty.java +++ b/teavm-jso/src/main/java/org/teavm/jso/JSProperty.java @@ -21,6 +21,26 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** + *

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.

* * @author Alexey Andreev */ diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSType.java b/teavm-jso/src/main/java/org/teavm/jso/JSType.java deleted file mode 100644 index c82fc6399..000000000 --- a/teavm-jso/src/main/java/org/teavm/jso/JSType.java +++ /dev/null @@ -1,29 +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 enum JSType { - UNDEFINED, - BOOLEAN, - NUMBER, - STRING, - FUNCTION, - OBJECT -}