public interface JSObject
The base type for all overlay types. Overlay types are Java types that represent JavaScript object, and therefore can be passed to and from JavaScript code.
An overlay type is an abstract class or an interface that extends/implements JSObject. An overlay type has following restrictions:
To simplify creation of overlay objects, you can use shortcut annotations instead of JSBody:
JSMethod, JSProperty and JSIndexer.
Example:
public abstract class Int32Array implements JSObject {
@JSBody(params = {}, script = "return this.length;")
public native int getLength();
@JSIndexer
public abstract int get(int index);
@JSIndexer
public abstract void set(int index, int value);
@JSBody(params = "length", script = "return new Int32Array(length);")
public static native ArrayBuffer create(int length);
@JSBody(params = "buffer", script = "return new Int32Array(buffer);")
public static native ArrayBuffer create(ArrayBuffer buffer);
@JSBody(params = { "buffer", "offset", "length" },
script = "return new Int32Array(buffer, offset, length);")
public static native ArrayBuffer create(ArrayBuffer buffer, int offset, int length);
}
JSBody| Modifier and Type | Method and Description |
|---|---|
default <T extends JSObject> |
cast() |
default <T extends JSObject> T cast()
Copyright © 2017. All rights reserved.