Add workarounds for Android JNI quirks
[ldk-java] / genbindings.py
index eefc9937464fe31e879b8ff393e31725a0248290..be4bc64ef4c29221f2aac10a5b50413768c722b5 100755 (executable)
@@ -14,8 +14,12 @@ else:
     sys.exit(1)
 
 target = None
-if sys.argv[6] == "java":
+if sys.argv[6] == "java" or sys.argv[6] == "android":
+    import java_strings
     from java_strings import Consts
+    target = java_strings.Target.JAVA
+    if sys.argv[6] == "android":
+        target = java_strings.Target.ANDROID
 elif sys.argv[6] == "typescript":
     import typescript_strings
     from typescript_strings import Consts
@@ -597,7 +601,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java:
                 if res_map.from_hu_conv is not None:
                     out_java_struct.write("\t\t\tthis(null, bindings.C" + human_ty + "_ok(" + res_map.from_hu_conv[0] + "));\n")
                     if res_map.from_hu_conv[1] != "":
-                        out_java_struct.write("\t\t\t" + res_map.from_hu_conv[1] + ";\n")
+                        out_java_struct.write("\t\t\t" + res_map.from_hu_conv[1].replace("\n", "\n\t\t\t") + ";\n")
                 else:
                     out_java_struct.write("\t\t\tthis(null, bindings.C" + human_ty + "_ok(res));\n")
             out_java_struct.write("\t\t}\n\t}\n\n")
@@ -635,7 +639,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java:
                 if err_map.from_hu_conv is not None:
                     out_java_struct.write("\t\t\tthis(null, bindings.C" + human_ty + "_err(" + err_map.from_hu_conv[0] + "));\n")
                     if err_map.from_hu_conv[1] != "":
-                        out_java_struct.write("\t\t\t" + err_map.from_hu_conv[1] + ";\n")
+                        out_java_struct.write("\t\t\t" + err_map.from_hu_conv[1].replace("\n", "\n\t\t\t") + ";\n")
                 else:
                     out_java_struct.write("\t\t\tthis(null, bindings.C" + human_ty + "_err(err));\n")
             out_java_struct.write("\t\t}\n\t}\n}\n")