mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
This commit is contained in:
parent
11f270e3ef
commit
71da76ee06
|
@ -101,6 +101,9 @@
|
|||
<debugInformationGenerated>true</debugInformationGenerated>
|
||||
<sourceMapsGenerated>true</sourceMapsGenerated>
|
||||
<sourceFilesCopied>true</sourceFilesCopied>
|
||||
<additionalScripts>
|
||||
|
||||
</additionalScripts>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
|
@ -106,9 +106,10 @@ public class JavaScriptBodyGenerator implements Generator {
|
|||
if (i > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
ValueType paramType = simplifyParamType(reader.parameterType(i));
|
||||
sb.append(naming.getFullNameFor(JavaScriptConvGenerator.fromJsMethod)).append("(p").append(i)
|
||||
.append(", ")
|
||||
.append(Renderer.typeToClsString(naming, reader.parameterType(i))).append(")");
|
||||
.append(Renderer.typeToClsString(naming, paramType)).append(")");
|
||||
}
|
||||
sb.append(")); })(");
|
||||
if (ident != null) {
|
||||
|
@ -116,6 +117,16 @@ public class JavaScriptBodyGenerator implements Generator {
|
|||
}
|
||||
return sb.toString();
|
||||
}
|
||||
private ValueType simplifyParamType(ValueType type) {
|
||||
if (type instanceof ValueType.Object) {
|
||||
return ValueType.object("java.lang.Object");
|
||||
} else if (type instanceof ValueType.Array) {
|
||||
ValueType.Array array = (ValueType.Array)type;
|
||||
return ValueType.arrayOf(simplifyParamType(array.getItemType()));
|
||||
} else {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
private MethodReader findMethod(String clsName, MethodDescriptor desc) {
|
||||
while (clsName != null) {
|
||||
ClassReader cls = classSource.get(clsName);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package org.teavm.html4j.test;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
public interface Callback {
|
||||
void exec(Calendar input);
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
package org.teavm.html4j.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import java.util.Calendar;
|
||||
import net.java.html.js.JavaScriptBody;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -60,6 +61,18 @@ public class JavaScriptBodyTest {
|
|||
assertEquals(23, invokeStaticCallback(new AImpl()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unusedArgumentIgnored() {
|
||||
final int[] array = new int[1];
|
||||
invokeCallback(new Callback() {
|
||||
@Override
|
||||
public void exec(Calendar input) {
|
||||
array[0] = 23;
|
||||
}
|
||||
});
|
||||
assertEquals(23, array[0]);
|
||||
}
|
||||
|
||||
private static class AImpl implements A {
|
||||
@Override public int foo() {
|
||||
return 23;
|
||||
|
@ -95,4 +108,8 @@ public class JavaScriptBodyTest {
|
|||
"@org.teavm.html4j.test.JavaScriptBodyTest::staticCallback(" +
|
||||
"Lorg/teavm/html4j/test/A;)(a)", javacall = true)
|
||||
private native int invokeStaticCallback(A a);
|
||||
|
||||
@JavaScriptBody(args = "callback", body = "callback.@org.teavm.html4j.test.Callback::exec(" +
|
||||
"Ljava/util/Calendar;)(null)", javacall = true)
|
||||
private native void invokeCallback(Callback callback);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user