mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-08 07:54:11 -08:00
Add javadocs to JSO annotations
This commit is contained in:
parent
a5ffd11151
commit
0064abeab7
|
@ -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 <code>window</code> object in the browser.
|
||||
* @return global object.
|
||||
|
|
|
@ -21,6 +21,14 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* <p>Marks abstract member method as a JavaScript constructor. This is equivalent to the following:</p>
|
||||
*
|
||||
* <pre>{@code
|
||||
* @JSBody(params = ..., script = "return new this.constructorName(...);")
|
||||
* }</pre>
|
||||
*
|
||||
* <p>where <code>constructorName</code> is method's name by default or a name, directly specified by
|
||||
* this annotation.</p>
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
|
|
|
@ -21,6 +21,21 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* <p>Marks abstract member method either as an getter indexer or setter indexer.</p>
|
||||
*
|
||||
* <p>Getter indexer is a method that returns value and takes exactly one parameter. In
|
||||
* this case annotation is equivalent to this:</p>
|
||||
*
|
||||
* <pre>{@code
|
||||
* @JSBody(params = "index", script = "return this[index];")
|
||||
* }</pre>
|
||||
*
|
||||
* <p>Setter indexer is a method that takes two parameter and does not return any value.
|
||||
* Ins this case annotation is equivalent to the following:</p>
|
||||
*
|
||||
* <pre>{@code
|
||||
* @JSBody(params = { "index", "value" }, script = "this[index] = value;")
|
||||
* }</pre>
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
|
|
|
@ -21,6 +21,14 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* <p>Marks abstract member method as a JavaScript method. This is equivalent to the following:</p>
|
||||
*
|
||||
* <pre>{@code
|
||||
* @JSBody(params = ..., script = "return new this.methodName(...);")
|
||||
* }</pre>
|
||||
*
|
||||
* <p>where <code>methodName</code> is method's name by default or a name, directly specified by
|
||||
* this annotation.</p>
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
|
|
|
@ -21,6 +21,26 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* <p>Marks abstract member method as either a getter or a setter.</p>
|
||||
*
|
||||
* <p>Getter's name must conform the Java Beans specification, i.e. start with <code>get</code> prefix
|
||||
* (or <code>is</code> in case of boolean getter). It must not take any parameters and must return a value.
|
||||
* For getter annotation is equivalent to the following:</p>
|
||||
*
|
||||
* <pre>{@code
|
||||
* @JSBody(params = {}, script = "return this.propertyName;")
|
||||
* }</pre>
|
||||
*
|
||||
* <p>Setter's name must conform the Java Beans specification, i.e. start with <code>set</code> prefix
|
||||
* It must take exactly one parameter and must not return a value.
|
||||
* For setter annotation is equivalent to the following:</p>
|
||||
*
|
||||
* <pre>{@code
|
||||
* @JSBody(params = "value", script = "this.propertyName = value;")
|
||||
* }</pre>
|
||||
*
|
||||
* <p>By default <code>propertyName</code> is calculated from method's name according to Java Beans specification,
|
||||
* otherwise the name specified by annotation is taken.</p>
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user