mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
html4j: implement undefined-to-null conversion
This commit is contained in:
parent
56a03e44b1
commit
c4ada881d2
|
@ -17,10 +17,6 @@ package org.teavm.html4j;
|
|||
|
||||
import org.teavm.backend.javascript.spi.GeneratedBy;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
public final class JavaScriptConv {
|
||||
private JavaScriptConv() {
|
||||
}
|
||||
|
|
|
@ -21,10 +21,6 @@ import org.teavm.backend.javascript.spi.Generator;
|
|||
import org.teavm.backend.javascript.spi.GeneratorContext;
|
||||
import org.teavm.model.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
public class JavaScriptConvGenerator implements Generator {
|
||||
static final MethodReference intValueMethod = new MethodReference(Integer.class, "intValue", int.class);
|
||||
static final MethodReference booleanValueMethod = new MethodReference(Boolean.class, "booleanValue", boolean.class);
|
||||
|
@ -66,7 +62,7 @@ public class JavaScriptConvGenerator implements Generator {
|
|||
private void generateToJavaScript(GeneratorContext context, SourceWriter writer) throws IOException {
|
||||
String obj = context.getParameterName(1);
|
||||
writer.append("if (" + obj + " === null || " + obj + " === undefined) {").softNewLine().indent();
|
||||
writer.append("return " + obj + ";").softNewLine();
|
||||
writer.append("return null;").softNewLine();
|
||||
|
||||
writer.outdent().append("} else if (typeof " + obj + " === 'number') {").indent().softNewLine();
|
||||
writer.append("return " + obj + ";").softNewLine();
|
||||
|
@ -118,7 +114,7 @@ public class JavaScriptConvGenerator implements Generator {
|
|||
String type = context.getParameterName(2);
|
||||
writer.append("if (" + obj + " === null || " + obj + " === undefined)").ws().append("{")
|
||||
.softNewLine().indent();
|
||||
writer.append("return " + obj + ";").softNewLine();
|
||||
writer.append("return null;").softNewLine();
|
||||
writer.outdent().append("} else if (" + type + ".$meta.item) {").indent().softNewLine();
|
||||
writer.append("var arr = $rt_createArray(" + type + ".$meta.item, " + obj + ".length);").softNewLine();
|
||||
writer.append("for (var i = 0; i < arr.data.length; ++i) {").indent().softNewLine();
|
||||
|
|
|
@ -56,12 +56,12 @@ public class JavaScriptTCKTest extends JavaScriptBodyTest {
|
|||
|
||||
@Test @Override
|
||||
public void callbackUnknownArray() {
|
||||
// super.callbackUnknownArray();
|
||||
super.callbackUnknownArray();
|
||||
}
|
||||
|
||||
@Test @Override
|
||||
public void callbackUnknown() {
|
||||
// super.callbackUnknown();
|
||||
super.callbackUnknown();
|
||||
}
|
||||
|
||||
@Test @Override
|
||||
|
@ -71,7 +71,7 @@ public class JavaScriptTCKTest extends JavaScriptBodyTest {
|
|||
|
||||
@Test @Override
|
||||
public void returnUnknownArray() {
|
||||
// super.returnUnknownArray();
|
||||
super.returnUnknownArray();
|
||||
}
|
||||
|
||||
@Test @Override
|
||||
|
@ -81,7 +81,7 @@ public class JavaScriptTCKTest extends JavaScriptBodyTest {
|
|||
|
||||
@Test @Override
|
||||
public void returnUnknown() {
|
||||
// super.returnUnknown();
|
||||
super.returnUnknown();
|
||||
}
|
||||
|
||||
@Test @Override
|
||||
|
@ -236,7 +236,7 @@ public class JavaScriptTCKTest extends JavaScriptBodyTest {
|
|||
|
||||
@Test @Override
|
||||
public void toStringOfAnEnum() {
|
||||
// super.toStringOfAnEnum();
|
||||
//super.toStringOfAnEnum();
|
||||
}
|
||||
|
||||
@Test @Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user