Skip to content

Commit

Permalink
[java] StringWriter.WriteCodePoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
pfusik committed Feb 28, 2024
1 parent f9cbcd8 commit 66d88e4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions GenJava.fu
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,10 @@ public class GenJava : GenTyped
WriteCall("System.err.print(Character.toChars", args[0]);
WriteChar(')');
}
else if (obj.Type.AsClassType().Class.Id == FuId.StringWriterClass) {
WriteMethodCall(obj, "append(Character.toString", args[0]);
WriteChar(')');
}
else {
Write("try { ");
WriteMethodCall(obj, "append(Character.toString", args[0]);
Expand Down
4 changes: 4 additions & 0 deletions libfut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18135,6 +18135,10 @@ void GenJava::writeCallExpr(const FuExpr * obj, const FuMethod * method, const s
writeCall("System.err.print(Character.toChars", (*args)[0].get());
writeChar(')');
}
else if (obj->type->asClassType()->class_->id == FuId::stringWriterClass) {
writeMethodCall(obj, "append(Character.toString", (*args)[0].get());
writeChar(')');
}
else {
write("try { ");
writeMethodCall(obj, "append(Character.toString", (*args)[0].get());
Expand Down
4 changes: 4 additions & 0 deletions libfut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18786,6 +18786,10 @@ protected override void WriteCallExpr(FuExpr obj, FuMethod method, List<FuExpr>
WriteCall("System.err.print(Character.toChars", args[0]);
WriteChar(')');
}
else if (obj.Type.AsClassType().Class.Id == FuId.StringWriterClass) {
WriteMethodCall(obj, "append(Character.toString", args[0]);
WriteChar(')');
}
else {
Write("try { ");
WriteMethodCall(obj, "append(Character.toString", args[0]);
Expand Down
4 changes: 4 additions & 0 deletions libfut.js
Original file line number Diff line number Diff line change
Expand Up @@ -19301,6 +19301,10 @@ export class GenJava extends GenTyped
this.writeCall("System.err.print(Character.toChars", args[0]);
this.writeChar(41);
}
else if (obj.type.asClassType().class.id == FuId.STRING_WRITER_CLASS) {
this.writeMethodCall(obj, "append(Character.toString", args[0]);
this.writeChar(41);
}
else {
this.write("try { ");
this.writeMethodCall(obj, "append(Character.toString", args[0]);
Expand Down
4 changes: 2 additions & 2 deletions test/JsonElement.fu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if CPP
#if CPP || JAVA
abstract class JsonElement
{
public virtual bool IsObject() => false;
Expand Down Expand Up @@ -352,7 +352,7 @@ public static class Test
{
public static bool Run()
{
JsonElement# json; //FAIL: c java TODO; cl
JsonElement# json; //FAIL: c TODO; cl
json = JsonElement.Parse("\"foo\"");
if (!json.IsString() || json.GetString() != "foo")
return false;
Expand Down

0 comments on commit 66d88e4

Please sign in to comment.