WebGL wrappers. Additional core JS wrappers

This commit is contained in:
konsoletyper 2015-01-22 23:03:54 +04:00
parent 871667cacb
commit 1b0b47985d
25 changed files with 1107 additions and 10 deletions

View File

@ -0,0 +1,40 @@
/*
* 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.dom.browser;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface Screen extends JSObject {
@JSProperty
int getWidth();
@JSProperty
int getHeight();
@JSProperty
int getAvailWidth();
@JSProperty
int getAvailHeight();
@JSProperty
int getColorDepth();
}

View File

@ -32,6 +32,9 @@ public interface Window extends JSGlobal {
@JSProperty
HTMLDocument getDocument();
@JSProperty
Screen getScreen();
void alert(JSObject message);
void alert(String message);
@ -67,4 +70,22 @@ public interface Window extends JSGlobal {
@JSConstructor("Uint8ClampedArray")
Int8Array createUintClamped8Array(ArrayBuffer buffer, int offset, int length);
@JSConstructor("Int32Array")
Int8Array createInt32Array(int length);
@JSConstructor("Int32Array")
Int8Array createInt32Array(ArrayBuffer buffer);
@JSConstructor("Int32Array")
Int8Array createInt32Array(ArrayBuffer buffer, int offset, int length);
@JSConstructor("Float32Array")
Int8Array createFloat32Array(int length);
@JSConstructor("Float32Array")
Int8Array createFloat32Array(ArrayBuffer buffer);
@JSConstructor("Float32Array")
Int8Array createFloat32Array(ArrayBuffer buffer, int offset, int length);
}

View File

@ -0,0 +1,30 @@
/*
* 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.dom.typedarrays;
import org.teavm.jso.JSIndexer;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface Float32Array extends ArrayBufferView {
@JSIndexer
float get(int index);
@JSIndexer
void set(int index, float value);
}

View File

@ -0,0 +1,30 @@
/*
* 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.dom.typedarrays;
import org.teavm.jso.JSIndexer;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface Int32Array extends ArrayBufferView {
@JSIndexer
int get(int index);
@JSIndexer
void set(int index, int value);
}

View File

@ -0,0 +1,26 @@
/*
* 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.dom.webgl;
import org.teavm.jso.JSObject;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface WebGLActiveInfo extends JSObject {
}

View File

@ -23,6 +23,6 @@ import org.teavm.jso.JSObject;
* @author Alexey Andreev
*/
public interface WebGLContextAttributesFactory extends JSObject {
@JSConstructor("WebGLContextAttributes")
@JSConstructor("Object")
WebGLContextAttributes createWebGLContextAttributes();
}

View File

@ -22,5 +22,4 @@ import org.teavm.jso.JSObject;
* @author Alexey Andreev
*/
public interface WebGLProgram extends JSObject {
}

View File

@ -15,12 +15,14 @@
*/
package org.teavm.dom.webgl;
import org.teavm.dom.canvas.ImageData;
import org.teavm.dom.html.HTMLCanvasElement;
import org.teavm.dom.html.HTMLImageElement;
import org.teavm.dom.typedarrays.ArrayBuffer;
import org.teavm.dom.typedarrays.ArrayBufferView;
import org.teavm.jso.JSArrayReader;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
import org.teavm.dom.typedarrays.Float32Array;
import org.teavm.dom.typedarrays.Int32Array;
import org.teavm.jso.*;
/**
*
@ -385,7 +387,10 @@ public interface WebGLRenderingContext extends JSObject {
boolean isContextLost();
JSArrayReader<JSObject> getSupportedExtensions();
JSStringArrayReader getSupportedExtensions();
@JSMethod("getSupportedExtensions")
String[] getSupportedExtensionArray();
JSObject getExtension(String name);
@ -437,4 +442,310 @@ public interface WebGLRenderingContext extends JSObject {
void colorMask(boolean red, boolean green, boolean blue, boolean alpha);
void compileShader(WebGLShader shader);
void compressedTexImage2D(int target, int level, int internalformat, int width, int height, int border,
ArrayBufferView data);
void compressedTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format,
ArrayBufferView data);
void copyTexImage2D(int target, int level, int internalformat, int x, int y, int width, int height, int border);
void copyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y, int width, int height);
WebGLBuffer createBuffer();
WebGLFramebuffer createFramebuffer();
WebGLProgram createProgram();
WebGLRenderbuffer createRenderbuffer();
WebGLShader createShader(int type);
WebGLTexture createTexture();
void cullFace(int mode);
void deleteBuffer(WebGLBuffer buffer);
void deleteFramebuffer(WebGLFramebuffer framebuffer);
void deleteProgram(WebGLProgram program);
void deleteRenderbuffer(WebGLRenderbuffer renderbuffer);
void deleteShader(WebGLShader shader);
void deleteTexture(WebGLTexture texture);
void depthFunc(int func);
void depthMask(boolean flag);
void depthRange(float zNear, float zFar);
void detachShader(WebGLProgram program, WebGLShader shader);
void disable(int cap);
void disableVertexAttribArray(int index);
void drawArrays(int mode, int first, int count);
void drawElements(int mode, int count, int type, int offset);
void enable(int cap);
void enableVertexAttribArray(int index);
void finish();
void flush();
void framebufferRenderbuffer(int target, int attachment, int renderbuffertarget, WebGLRenderbuffer renderbuffer);
void framebufferTexture2D(int target, int attachment, int textarget, WebGLTexture texture, int level);
void frontFace(int mode);
void generateMipmap(int target);
WebGLActiveInfo getActiveAttrib(WebGLProgram program, int index);
WebGLActiveInfo getActiveUniform(WebGLProgram program, int index);
JSArrayReader<WebGLShader> getAttachedShaders(WebGLProgram program);
@JSMethod("getAttachedShaders")
WebGLShader[] getAttachedShadersArray(WebGLProgram program);
int getAttribLocation(WebGLProgram program, String name);
JSObject getBufferParameter(int target, int pname);
JSObject getParameter(int pname);
int getError();
JSObject getFramebufferAttachmentParameter(int target, int attachment, int pname);
JSObject getProgramParameter(WebGLProgram program, int pname);
String getProgramInfoLog(WebGLProgram program);
JSObject getRenderbufferParameter(int target, int pname);
JSObject getShaderParameter(WebGLShader shader, int pname);
WebGLShaderPrecisionFormat getShaderPrecisionFormat(int shadertype, int precisiontype);
String getShaderInfoLog(WebGLShader shader);
String getShaderSource(WebGLShader shader);
JSObject getTexParameter(int target, int pname);
JSObject getUniform(WebGLProgram program, WebGLUniformLocation location);
WebGLUniformLocation getUniformLocation(WebGLProgram program, String name);
JSObject getVertexAttrib(int index, int pname);
int getVertexAttribOffset(int index, int pname);
void hint(int target, int mode);
boolean isBuffer(WebGLBuffer buffer);
boolean isEnabled(int cap);
boolean isFramebuffer(WebGLFramebuffer framebuffer);
boolean isProgram(WebGLProgram program);
boolean isRenderbuffer(WebGLRenderbuffer renderbuffer);
boolean isShader(WebGLShader shader);
boolean isTexture(WebGLTexture texture);
void lineWidth(float width);
void linkProgram(WebGLProgram program);
void pixelStorei(int pname, int param);
void polygonOffset(float factor, float units);
void readPixels(int x, int y, int width, int height, int format, int type, ArrayBufferView pixels);
void renderbufferStorage(int target, int internalformat, int width, int height);
void sampleCoverage(float value, boolean invert);
void scissor(int x, int y, int width, int height);
void shaderSource(WebGLShader shader, String source);
void stencilFunc(int func, int ref, int mask);
void stencilFuncSeparate(int face, int func, int ref, int mask);
void stencilMask(int mask);
void stencilMaskSeparate(int face, int mask);
void stencilOp(int fail, int zfail, int zpass);
void stencilOpSeparate(int face, int fail, int zfail, int zpass);
void texImage2D(int target, int level, int internalformat, int width, int height, int border, int format,
int type, ArrayBufferView pixels);
void texImage2D(int target, int level, int internalformat, int format, int type, ImageData pixels);
void texImage2D(int target, int level, int internalformat, int format, int type, HTMLImageElement image);
void texImage2D(int target, int level, int internalformat, int format, int type, HTMLCanvasElement canvas);
//void texImage2D(int target, int level, int internalformat, int format, int type, HTMLVideoElement video);
void texParameterf(int target, int pname, float param);
void texParameteri(int target, int pname, int param);
void texSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type,
ArrayBufferView pixels);
void texSubImage2D(int target, int level, int xoffset, int yoffset, int format, int type, ImageData pixels);
void texSubImage2D(int target, int level, int xoffset, int yoffset, int format, int type, HTMLImageElement image);
void texSubImage2D(int target, int level, int xoffset, int yoffset, int format, int type, HTMLCanvasElement canvas);
//void texSubImage2D(int target, int level, int xoffset, int yoffset, int format, int type, HTMLVideoElement video);
void uniform1f(WebGLUniformLocation location, float x);
void uniform1fv(WebGLUniformLocation location, Float32Array v);
void uniform1fv(WebGLUniformLocation location, JSFloatArrayReader v);
void uniform1fv(WebGLUniformLocation location, float[] v);
void uniform1i(WebGLUniformLocation location, int x);
void uniform1iv(WebGLUniformLocation location, Int32Array v);
void uniform1iv(WebGLUniformLocation location, JSIntArrayReader v);
void uniform1iv(WebGLUniformLocation location, int[] v);
void uniform2f(WebGLUniformLocation location, float x, float y);
void uniform2fv(WebGLUniformLocation location, Float32Array v);
void uniform2fv(WebGLUniformLocation location, JSFloatArrayReader v);
void uniform2fv(WebGLUniformLocation location, float[] v);
void uniform2i(WebGLUniformLocation location, int x, int y);
void uniform2iv(WebGLUniformLocation location, Int32Array v);
void uniform2iv(WebGLUniformLocation location, JSIntArrayReader v);
void uniform2iv(WebGLUniformLocation location, int[] v);
void uniform3f(WebGLUniformLocation location, float x, float y, float z);
void uniform3fv(WebGLUniformLocation location, Float32Array v);
void uniform3fv(WebGLUniformLocation location, JSFloatArrayReader v);
void uniform3fv(WebGLUniformLocation location, float[] v);
void uniform3i(WebGLUniformLocation location, int x, int y, int z);
void uniform3iv(WebGLUniformLocation location, Int32Array v);
void uniform3iv(WebGLUniformLocation location, JSIntArrayReader v);
void uniform3iv(WebGLUniformLocation location, int[] v);
void uniform4f(WebGLUniformLocation location, float x, float y, float z, float w);
void uniform4fv(WebGLUniformLocation location, Float32Array v);
void uniform4fv(WebGLUniformLocation location, JSFloatArrayReader v);
void uniform4fv(WebGLUniformLocation location, float[] v);
void uniform4i(WebGLUniformLocation location, int x, int y, int z, int w);
void uniform4iv(WebGLUniformLocation location, Int32Array v);
void uniform4iv(WebGLUniformLocation location, JSIntArrayReader v);
void uniform4iv(WebGLUniformLocation location, int[] v);
void uniformMatrix2fv(WebGLUniformLocation location, boolean transpose, Float32Array value);
void uniformMatrix2fv(WebGLUniformLocation location, boolean transpose, JSFloatArrayReader value);
void uniformMatrix2fv(WebGLUniformLocation location, boolean transpose, float[] value);
void uniformMatrix3fv(WebGLUniformLocation location, boolean transpose, Float32Array value);
void uniformMatrix3fv(WebGLUniformLocation location, boolean transpose, JSFloatArrayReader value);
void uniformMatrix3fv(WebGLUniformLocation location, boolean transpose, float[] value);
void uniformMatrix4fv(WebGLUniformLocation location, boolean transpose, Float32Array value);
void uniformMatrix4fv(WebGLUniformLocation location, boolean transpose, JSFloatArrayReader value);
void uniformMatrix4fv(WebGLUniformLocation location, boolean transpose, float[] value);
void useProgram(WebGLProgram program);
void validateProgram(WebGLProgram program);
void vertexAttrib1f(int indx, float x);
void vertexAttrib1fv(int indx, Float32Array values);
void vertexAttrib1fv(int indx, JSFloatArrayReader values);
void vertexAttrib1fv(int indx, float[] values);
void vertexAttrib2f(int indx, float x, float y);
void vertexAttrib2fv(int indx, Float32Array values);
void vertexAttrib2fv(int indx, JSFloatArrayReader values);
void vertexAttrib2fv(int indx, float[] values);
void vertexAttrib3f(int indx, float x, float y, float z);
void vertexAttrib3fv(int indx, Float32Array values);
void vertexAttrib3fv(int indx, JSFloatArrayReader values);
void vertexAttrib3fv(int indx, float[] values);
void vertexAttrib4f(int indx, float x, float y, float z, float w);
void vertexAttrib4fv(int indx, Float32Array values);
void vertexAttrib4fv(int indx, JSFloatArrayReader values);
void vertexAttrib4fv(int indx, float[] values);
void vertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, int offset);
void viewport(int x, int y, int width, int height);
}

View File

@ -0,0 +1,34 @@
/*
* 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.dom.webgl;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface WebGLShaderPrecisionFormat extends JSObject {
@JSProperty
int getRangeMin();
@JSProperty
int getRangeMax();
@JSProperty
int getPrecision();
}

View File

@ -0,0 +1,34 @@
/*
* 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.dom.webgl;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface WebGLUniformLocation extends JSObject {
@JSProperty
int getSize();
@JSProperty
int getType();
@JSProperty
String getName();
}

View File

@ -47,6 +47,12 @@ public final class JS {
public static native <T extends JSObject> JSArray<T> createArray(int size);
public static native JSIntArray createIntArray(int size);
public static native JSStringArray createStringArray(int size);
public static native JSFloatArray createFloatArray(int size);
@InjectedBy(JSNativeGenerator.class)
public static native JSObject getTypeName(JSObject obj);
@ -95,6 +101,78 @@ public final class JS {
return result;
}
public static JSIntArray wrap(int[] array) {
JSIntArray result = createIntArray(array.length);
for (int i = 0; i < array.length; ++i) {
result.set(i, array[i]);
}
return result;
}
public static JSArray<JSIntArray> wrap(int[][] array) {
JSArray<JSIntArray> result = createArray(array.length);
for (int i = 0; i < array.length; ++i) {
result.set(i, wrap(array[i]));
}
return result;
}
public static JSArray<JSArray<JSIntArray>> wrap(int[][][] array) {
JSArray<JSArray<JSIntArray>> result = createArray(array.length);
for (int i = 0; i < array.length; ++i) {
result.set(i, wrap(array[i]));
}
return result;
}
public static JSStringArray wrap(String[] array) {
JSStringArray result = createStringArray(array.length);
for (int i = 0; i < array.length; ++i) {
result.set(i, array[i]);
}
return result;
}
public static JSArray<JSStringArray> wrap(String[][] array) {
JSArray<JSStringArray> result = createArray(array.length);
for (int i = 0; i < array.length; ++i) {
result.set(i, wrap(array[i]));
}
return result;
}
public static JSArray<JSArray<JSStringArray>> wrap(String[][][] array) {
JSArray<JSArray<JSStringArray>> result = createArray(array.length);
for (int i = 0; i < array.length; ++i) {
result.set(i, wrap(array[i]));
}
return result;
}
public static JSFloatArray wrap(float[] array) {
JSFloatArray result = createFloatArray(array.length);
for (int i = 0; i < array.length; ++i) {
result.set(i, array[i]);
}
return result;
}
public static JSArray<JSFloatArray> wrap(float[][] array) {
JSArray<JSFloatArray> result = createArray(array.length);
for (int i = 0; i < array.length; ++i) {
result.set(i, wrap(array[i]));
}
return result;
}
public static JSArray<JSArray<JSFloatArray>> wrap(float[][][] array) {
JSArray<JSArray<JSFloatArray>> result = createArray(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);

View File

@ -37,13 +37,13 @@ public interface JSArray<T extends JSObject> extends JSArrayReader<T> {
String join();
JSArray<T> concat(JSArray<T> a);
JSArray<T> concat(JSArrayReader<T> a);
JSArray<T> concat(JSArray<T> a, JSArray<T> b);
JSArray<T> concat(JSArrayReader<T> a, JSArrayReader<T> b);
JSArray<T> concat(JSArray<T> a, JSArray<T> b, JSArray<T> c);
JSArray<T> concat(JSArrayReader<T> a, JSArrayReader<T> b, JSArrayReader<T> c);
JSArray<T> concat(JSArray<T> a, JSArray<T> b, JSArray<T> c, JSArray<T> d);
JSArray<T> concat(JSArrayReader<T> a, JSArrayReader<T> b, JSArrayReader<T> c, JSArrayReader<T> d);
T pop();

View File

@ -0,0 +1,28 @@
/*
* 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 <konsoletyper@gmail.com>
*/
public interface JSBooleanArrayReader extends JSObject {
@JSProperty
int getLength();
@JSIndexer
boolean get(int index);
}

View File

@ -0,0 +1,28 @@
/*
* 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 <konsoletyper@gmail.com>
*/
public interface JSByteArrayReader extends JSObject {
@JSProperty
int getLength();
@JSIndexer
byte get(int index);
}

View File

@ -0,0 +1,28 @@
/*
* 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 <konsoletyper@gmail.com>
*/
public interface JSDoubleArrayReader extends JSObject {
@JSProperty
int getLength();
@JSIndexer
double get(int index);
}

View File

@ -0,0 +1,24 @@
/*
* 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 <konsoletyper@gmail.com>
*/
public interface JSFloatArray extends JSFloatArrayReader {
}

View File

@ -0,0 +1,83 @@
/*
* 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 <konsoletyper@gmail.com>
*/
public interface JSFloatArrayReader extends JSObject {
@JSProperty
int getLength();
@JSIndexer
float get(int index);
@JSIndexer
void set(int index, float value);
int push(float a);
int push(float a, float b);
int push(float a, float b, float c);
int push(float a, float b, float c, float d);
float shift();
String join(String separator);
String join();
JSFloatArray concat(JSFloatArrayReader a);
JSFloatArray concat(JSFloatArray a, JSFloatArray b);
JSFloatArray concat(JSFloatArray a, JSFloatArray b, JSFloatArray c);
JSFloatArray concat(JSFloatArray a, JSFloatArray b, JSFloatArray c, JSFloatArray d);
float pop();
int unshift(float a);
int unshift(float a, float b);
int unshift(float a, float b, float c);
int unshift(float a, float b, float c, float d);
JSFloatArray slice(int start);
JSFloatArray slice(int start, int end);
JSFloatArray reverse();
JSFloatArray sort(JSFloatSortFunction function);
JSFloatArray sort();
JSFloatArray splice(int start, int count);
JSFloatArray splice(int start, int count, float a);
JSFloatArray splice(int start, int count, float a, float b);
JSFloatArray splice(int start, int count, float a, float b, float c);
JSFloatArray splice(int start, int count, float a, float b, float c, float d);
}

View File

@ -0,0 +1,25 @@
/*
* 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 <konsoletyper@gmail.com>
*/
@JSFunctor
public interface JSFloatSortFunction {
int compare(float a, float b);
}

View File

@ -28,4 +28,22 @@ public interface JSGlobal extends JSObject {
@JSConstructor
<T extends JSObject> JSArray<T> newArray(int sz);
@JSConstructor("Array")
JSStringArray newStringArray();
@JSConstructor("Array")
JSStringArray newStringArray(int sz);
@JSConstructor("Array")
JSIntArray newIntArray();
@JSConstructor("Array")
JSIntArray newIntArray(int sz);
@JSConstructor("Array")
JSFloatArray newFloatArray();
@JSConstructor("Array")
JSFloatArray newFloatArray(int sz);
}

View File

@ -0,0 +1,77 @@
/*
* 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 <konsoletyper@gmail.com>
*/
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);
}

View File

@ -0,0 +1,28 @@
/*
* 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 <konsoletyper@gmail.com>
*/
public interface JSIntArrayReader extends JSObject {
@JSProperty
int getLength();
@JSIndexer
int get(int index);
}

View File

@ -0,0 +1,25 @@
/*
* 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 <konsoletyper@gmail.com>
*/
@JSFunctor
public interface JSIntSortFunction extends JSObject {
int compare(int a, int b);
}

View File

@ -0,0 +1,28 @@
/*
* 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 <konsoletyper@gmail.com>
*/
public interface JSShortArrayReader extends JSObject {
@JSProperty
int getLength();
@JSIndexer
short get(int index);
}

View File

@ -0,0 +1,77 @@
/*
* 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 <konsoletyper@gmail.com>
*/
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);
}

View File

@ -0,0 +1,25 @@
/*
* 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 <konsoletyper@gmail.com>
*/
@JSFunctor
public interface JSStringSortFunction extends JSObject {
int compare(String a, String b);
}