mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix bugs in JSBody
This commit is contained in:
parent
4adf789142
commit
b8fa0a541a
|
@ -15,10 +15,7 @@
|
|||
*/
|
||||
package org.teavm.jso;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -26,5 +23,6 @@ import java.lang.annotation.Target;
|
|||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Inherited
|
||||
public @interface JSFunctor {
|
||||
}
|
||||
|
|
|
@ -36,16 +36,15 @@ public class JSBodyGenerator implements Generator {
|
|||
List<AnnotationValue> paramNames = annot.getValue("params").getList();
|
||||
|
||||
int bodyParamCount = isStatic ? method.parameterCount() : method.parameterCount() - 1;
|
||||
int offset = isStatic ? 1 : 0;
|
||||
|
||||
writer.append("if (!").appendMethodBody(methodRef).append(".$native)").ws().append('{').indent().newLine();
|
||||
writer.appendMethodBody(methodRef).append(".$native").ws().append('=').ws().append("function(");
|
||||
int count = method.parameterCount() + (isStatic ? 0 : 1);
|
||||
int count = method.parameterCount();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (i > 0) {
|
||||
writer.append(',').ws();
|
||||
}
|
||||
writer.append('_').append(context.getParameterName(i + offset));
|
||||
writer.append('_').append(context.getParameterName(i + 1));
|
||||
}
|
||||
writer.append(')').ws().append('{').softNewLine().indent();
|
||||
|
||||
|
@ -68,7 +67,7 @@ public class JSBodyGenerator implements Generator {
|
|||
if (i > 0) {
|
||||
writer.append(',').ws();
|
||||
}
|
||||
writer.append('_').append(context.getParameterName(i + offset));
|
||||
writer.append('_').append(context.getParameterName(i + 1));
|
||||
}
|
||||
writer.append(");").softNewLine();
|
||||
writer.outdent().append("};").softNewLine();
|
||||
|
@ -81,7 +80,7 @@ public class JSBodyGenerator implements Generator {
|
|||
if (i > 0) {
|
||||
writer.append(',').ws();
|
||||
}
|
||||
writer.append(context.getParameterName(i + offset));
|
||||
writer.append(context.getParameterName(i + 1));
|
||||
}
|
||||
writer.append(");").softNewLine();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user