mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
JSO bugfixes and improvements
This commit is contained in:
parent
bb0cd3e180
commit
ad57f957cb
|
@ -652,7 +652,7 @@ public interface WebGLRenderingContext extends JSObject {
|
|||
|
||||
void uniform1fv(WebGLUniformLocation location, Float32Array v);
|
||||
|
||||
void uniform1fv(WebGLUniformLocation location, JSFloatArrayReader v);
|
||||
void uniform1fv(WebGLUniformLocation location, JSDoubleArrayReader v);
|
||||
|
||||
void uniform1fv(WebGLUniformLocation location, float[] v);
|
||||
|
||||
|
@ -668,7 +668,7 @@ public interface WebGLRenderingContext extends JSObject {
|
|||
|
||||
void uniform2fv(WebGLUniformLocation location, Float32Array v);
|
||||
|
||||
void uniform2fv(WebGLUniformLocation location, JSFloatArrayReader v);
|
||||
void uniform2fv(WebGLUniformLocation location, JSDoubleArrayReader v);
|
||||
|
||||
void uniform2fv(WebGLUniformLocation location, float[] v);
|
||||
|
||||
|
@ -684,7 +684,7 @@ public interface WebGLRenderingContext extends JSObject {
|
|||
|
||||
void uniform3fv(WebGLUniformLocation location, Float32Array v);
|
||||
|
||||
void uniform3fv(WebGLUniformLocation location, JSFloatArrayReader v);
|
||||
void uniform3fv(WebGLUniformLocation location, JSDoubleArrayReader v);
|
||||
|
||||
void uniform3fv(WebGLUniformLocation location, float[] v);
|
||||
|
||||
|
@ -700,7 +700,7 @@ public interface WebGLRenderingContext extends JSObject {
|
|||
|
||||
void uniform4fv(WebGLUniformLocation location, Float32Array v);
|
||||
|
||||
void uniform4fv(WebGLUniformLocation location, JSFloatArrayReader v);
|
||||
void uniform4fv(WebGLUniformLocation location, JSDoubleArrayReader v);
|
||||
|
||||
void uniform4fv(WebGLUniformLocation location, float[] v);
|
||||
|
||||
|
@ -714,19 +714,19 @@ public interface WebGLRenderingContext extends JSObject {
|
|||
|
||||
void uniformMatrix2fv(WebGLUniformLocation location, boolean transpose, Float32Array value);
|
||||
|
||||
void uniformMatrix2fv(WebGLUniformLocation location, boolean transpose, JSFloatArrayReader value);
|
||||
void uniformMatrix2fv(WebGLUniformLocation location, boolean transpose, JSDoubleArrayReader 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, JSDoubleArrayReader 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, JSDoubleArrayReader value);
|
||||
|
||||
void uniformMatrix4fv(WebGLUniformLocation location, boolean transpose, float[] value);
|
||||
|
||||
|
@ -738,7 +738,7 @@ public interface WebGLRenderingContext extends JSObject {
|
|||
|
||||
void vertexAttrib1fv(int indx, Float32Array values);
|
||||
|
||||
void vertexAttrib1fv(int indx, JSFloatArrayReader values);
|
||||
void vertexAttrib1fv(int indx, JSDoubleArrayReader values);
|
||||
|
||||
void vertexAttrib1fv(int indx, float[] values);
|
||||
|
||||
|
@ -746,7 +746,7 @@ public interface WebGLRenderingContext extends JSObject {
|
|||
|
||||
void vertexAttrib2fv(int indx, Float32Array values);
|
||||
|
||||
void vertexAttrib2fv(int indx, JSFloatArrayReader values);
|
||||
void vertexAttrib2fv(int indx, JSDoubleArrayReader values);
|
||||
|
||||
void vertexAttrib2fv(int indx, float[] values);
|
||||
|
||||
|
@ -754,7 +754,7 @@ public interface WebGLRenderingContext extends JSObject {
|
|||
|
||||
void vertexAttrib3fv(int indx, Float32Array values);
|
||||
|
||||
void vertexAttrib3fv(int indx, JSFloatArrayReader values);
|
||||
void vertexAttrib3fv(int indx, JSDoubleArrayReader values);
|
||||
|
||||
void vertexAttrib3fv(int indx, float[] values);
|
||||
|
||||
|
@ -762,7 +762,7 @@ public interface WebGLRenderingContext extends JSObject {
|
|||
|
||||
void vertexAttrib4fv(int indx, Float32Array values);
|
||||
|
||||
void vertexAttrib4fv(int indx, JSFloatArrayReader values);
|
||||
void vertexAttrib4fv(int indx, JSDoubleArrayReader values);
|
||||
|
||||
void vertexAttrib4fv(int indx, float[] values);
|
||||
|
||||
|
|
|
@ -47,13 +47,25 @@ public final class JS {
|
|||
throw new AssertionError("Unexpected type");
|
||||
}
|
||||
|
||||
public static native <T extends JSObject> JSArray<T> createArray(int size);
|
||||
public static <T extends JSObject> JSArray<T> createArray(int size) {
|
||||
return ((JSGlobal)JS.getGlobal()).newArray(size);
|
||||
}
|
||||
|
||||
public static native JSIntArray createIntArray(int size);
|
||||
public static JSIntArray createIntArray(int size) {
|
||||
return ((JSGlobal)JS.getGlobal()).newIntArray(size);
|
||||
}
|
||||
|
||||
public static native JSStringArray createStringArray(int size);
|
||||
public static JSStringArray createStringArray(int size) {
|
||||
return ((JSGlobal)JS.getGlobal()).newStringArray(size);
|
||||
}
|
||||
|
||||
public static native JSFloatArray createFloatArray(int size);
|
||||
public static JSBooleanArray createBooleanArray(int size) {
|
||||
return ((JSGlobal)JS.getGlobal()).newBooleanArray(size);
|
||||
}
|
||||
|
||||
public static JSDoubleArray createDoubleArray(int size) {
|
||||
return ((JSGlobal)JS.getGlobal()).newDoubleArray(size);
|
||||
}
|
||||
|
||||
@InjectedBy(JSNativeGenerator.class)
|
||||
public static native JSObject getTypeName(JSObject obj);
|
||||
|
@ -113,6 +125,102 @@ public final class JS {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static JSBooleanArray wrap(boolean[] array) {
|
||||
JSBooleanArray result = createBooleanArray(array.length);
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
result.set(i, array[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static JSArray<JSBooleanArray> wrap(boolean[][] array) {
|
||||
JSArray<JSBooleanArray> result = createArray(array.length);
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
result.set(i, wrap(array[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static JSArray<JSArray<JSBooleanArray>> wrap(boolean[][][] array) {
|
||||
JSArray<JSArray<JSBooleanArray>> result = createArray(array.length);
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
result.set(i, wrap(array[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static JSIntArray wrap(byte[] 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(byte[][] 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(byte[][][] 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 JSIntArray wrap(short[] 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(short[][] 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(short[][][] 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 JSIntArray wrap(char[] 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(char[][] 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(char[][][] 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 JSIntArray wrap(int[] array) {
|
||||
JSIntArray result = createIntArray(array.length);
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
|
@ -161,24 +269,48 @@ public final class JS {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static JSFloatArray wrap(float[] array) {
|
||||
JSFloatArray result = createFloatArray(array.length);
|
||||
public static JSDoubleArray wrap(float[] array) {
|
||||
JSDoubleArray result = createDoubleArray(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);
|
||||
public static JSArray<JSDoubleArray> wrap(float[][] array) {
|
||||
JSArray<JSDoubleArray> 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);
|
||||
public static JSArray<JSArray<JSDoubleArray>> wrap(float[][][] array) {
|
||||
JSArray<JSArray<JSDoubleArray>> result = createArray(array.length);
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
result.set(i, wrap(array[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static JSDoubleArray wrap(double[] array) {
|
||||
JSDoubleArray result = createDoubleArray(array.length);
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
result.set(i, array[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static JSArray<JSDoubleArray> wrap(double[][] array) {
|
||||
JSArray<JSDoubleArray> result = createArray(array.length);
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
result.set(i, wrap(array[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static JSArray<JSArray<JSDoubleArray>> wrap(double[][][] array) {
|
||||
JSArray<JSArray<JSDoubleArray>> result = createArray(array.length);
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
result.set(i, wrap(array[i]));
|
||||
}
|
||||
|
|
73
teavm-jso/src/main/java/org/teavm/jso/JSBooleanArray.java
Normal file
73
teavm-jso/src/main/java/org/teavm/jso/JSBooleanArray.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* 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 JSBooleanArray extends JSBooleanArrayReader {
|
||||
@JSIndexer
|
||||
void set(int index, boolean value);
|
||||
|
||||
int push(boolean a);
|
||||
|
||||
int push(boolean a, boolean b);
|
||||
|
||||
int push(boolean a, boolean b, boolean c);
|
||||
|
||||
int push(boolean a, boolean b, boolean c, boolean d);
|
||||
|
||||
boolean shift();
|
||||
|
||||
String join(String separator);
|
||||
|
||||
String join();
|
||||
|
||||
JSBooleanArray concat(JSBooleanArrayReader a);
|
||||
|
||||
JSBooleanArray concat(JSBooleanArray a, JSBooleanArray b);
|
||||
|
||||
JSBooleanArray concat(JSBooleanArray a, JSBooleanArray b, JSBooleanArray c);
|
||||
|
||||
JSBooleanArray concat(JSBooleanArray a, JSBooleanArray b, JSBooleanArray c, JSBooleanArray d);
|
||||
|
||||
boolean pop();
|
||||
|
||||
int unshift(boolean a);
|
||||
|
||||
int unshift(boolean a, boolean b);
|
||||
|
||||
int unshift(boolean a, boolean b, boolean c);
|
||||
|
||||
int unshift(boolean a, boolean b, boolean c, boolean d);
|
||||
|
||||
JSBooleanArray slice(int start);
|
||||
|
||||
JSBooleanArray slice(int start, int end);
|
||||
|
||||
JSBooleanArray reverse();
|
||||
|
||||
JSBooleanArray splice(int start, int count);
|
||||
|
||||
JSBooleanArray splice(int start, int count, boolean a);
|
||||
|
||||
JSBooleanArray splice(int start, int count, boolean a, boolean b);
|
||||
|
||||
JSBooleanArray splice(int start, int count, boolean a, boolean b, boolean c);
|
||||
|
||||
JSBooleanArray splice(int start, int count, boolean a, boolean b, boolean c, boolean d);
|
||||
}
|
77
teavm-jso/src/main/java/org/teavm/jso/JSDoubleArray.java
Normal file
77
teavm-jso/src/main/java/org/teavm/jso/JSDoubleArray.java
Normal 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 JSDoubleArray extends JSDoubleArrayReader {
|
||||
@JSIndexer
|
||||
void set(int index, double value);
|
||||
|
||||
int push(double a);
|
||||
|
||||
int push(double a, double b);
|
||||
|
||||
int push(double a, double b, double c);
|
||||
|
||||
int push(double a, double b, double c, double d);
|
||||
|
||||
double shift();
|
||||
|
||||
String join(String separator);
|
||||
|
||||
String join();
|
||||
|
||||
JSDoubleArray concat(JSDoubleArrayReader a);
|
||||
|
||||
JSDoubleArray concat(JSDoubleArray a, JSDoubleArray b);
|
||||
|
||||
JSDoubleArray concat(JSDoubleArray a, JSDoubleArray b, JSDoubleArray c);
|
||||
|
||||
JSDoubleArray concat(JSDoubleArray a, JSDoubleArray b, JSDoubleArray c, JSDoubleArray d);
|
||||
|
||||
double pop();
|
||||
|
||||
int unshift(double a);
|
||||
|
||||
int unshift(double a, double b);
|
||||
|
||||
int unshift(double a, double b, double c);
|
||||
|
||||
int unshift(double a, double b, double c, double d);
|
||||
|
||||
JSDoubleArray slice(int start);
|
||||
|
||||
JSDoubleArray slice(int start, int end);
|
||||
|
||||
JSDoubleArray reverse();
|
||||
|
||||
JSDoubleArray sort(JSDoubleSortFunction function);
|
||||
|
||||
JSDoubleArray sort();
|
||||
|
||||
JSDoubleArray splice(int start, int count);
|
||||
|
||||
JSDoubleArray splice(int start, int count, double a);
|
||||
|
||||
JSDoubleArray splice(int start, int count, double a, double b);
|
||||
|
||||
JSDoubleArray splice(int start, int count, double a, double b, double c);
|
||||
|
||||
JSDoubleArray splice(int start, int count, double a, double b, double c, double d);
|
||||
}
|
|
@ -20,6 +20,6 @@ package org.teavm.jso;
|
|||
* @author Alexey Andreev <konsoletyper@gmail.com>
|
||||
*/
|
||||
@JSFunctor
|
||||
public interface JSFloatSortFunction {
|
||||
int compare(float a, float b);
|
||||
public interface JSDoubleSortFunction {
|
||||
int compare(double a, double b);
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* 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 {
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
|
@ -35,6 +35,12 @@ public interface JSGlobal extends JSObject {
|
|||
@JSConstructor("Array")
|
||||
JSStringArray newStringArray(int sz);
|
||||
|
||||
@JSConstructor("Array")
|
||||
JSBooleanArray newBooleanArray();
|
||||
|
||||
@JSConstructor("Array")
|
||||
JSBooleanArray newBooleanArray(int sz);
|
||||
|
||||
@JSConstructor("Array")
|
||||
JSIntArray newIntArray();
|
||||
|
||||
|
@ -42,8 +48,8 @@ public interface JSGlobal extends JSObject {
|
|||
JSIntArray newIntArray(int sz);
|
||||
|
||||
@JSConstructor("Array")
|
||||
JSFloatArray newFloatArray();
|
||||
JSDoubleArray newDoubleArray();
|
||||
|
||||
@JSConstructor("Array")
|
||||
JSFloatArray newFloatArray(int sz);
|
||||
JSDoubleArray newDoubleArray(int sz);
|
||||
}
|
||||
|
|
|
@ -470,7 +470,7 @@ class JavascriptNativeProcessor {
|
|||
}
|
||||
Variable result = program.createVariable();
|
||||
InvokeInstruction insn = new InvokeInstruction();
|
||||
insn.setMethod(new MethodReference(JS.class.getName(), "wrap", type, ValueType.parse(JSObject.class)));
|
||||
insn.setMethod(new MethodReference(JS.class.getName(), "wrap", type, getWrapperType(type)));
|
||||
insn.getArguments().add(var);
|
||||
insn.setReceiver(result);
|
||||
insn.setType(InvocationType.SPECIAL);
|
||||
|
@ -479,6 +479,35 @@ class JavascriptNativeProcessor {
|
|||
return result;
|
||||
}
|
||||
|
||||
private ValueType getWrapperType(ValueType type) {
|
||||
if (type instanceof ValueType.Array) {
|
||||
ValueType itemType = ((ValueType.Array)type).getItemType();
|
||||
if (itemType instanceof ValueType.Primitive) {
|
||||
switch (((ValueType.Primitive)itemType).getKind()) {
|
||||
case BOOLEAN:
|
||||
return ValueType.parse(JSBooleanArray.class);
|
||||
case BYTE:
|
||||
case SHORT:
|
||||
case INTEGER:
|
||||
case CHARACTER:
|
||||
return ValueType.parse(JSIntArray.class);
|
||||
case FLOAT:
|
||||
case DOUBLE:
|
||||
return ValueType.parse(JSDoubleArray.class);
|
||||
case LONG:
|
||||
default:
|
||||
return ValueType.parse(JSArray.class);
|
||||
}
|
||||
} else if (itemType.isObject("java.lang.String")) {
|
||||
return ValueType.parse(JSStringArray.class);
|
||||
} else {
|
||||
return ValueType.parse(JSArray.class);
|
||||
}
|
||||
} else {
|
||||
return ValueType.parse(JSObject.class);
|
||||
}
|
||||
}
|
||||
|
||||
private MethodReader getMethod(MethodReference ref) {
|
||||
ClassReader cls = classSource.get(ref.getClassName());
|
||||
MethodReader method = cls.getMethod(ref.getDescriptor());
|
||||
|
|
Loading…
Reference in New Issue
Block a user