fn_arg = fn_arg[4:].strip()
is_primitive = True
elif fn_arg.startswith("bool"):
- java_ty = "boolean"
+ java_ty = consts.c_type_map['bool'][0]
c_ty = "jboolean"
fn_ty_arg = "Z"
arr_ty = "bool"
with open(f"{sys.argv[3]}/structs/TxOut{consts.file_ext}", "w") as out_java_struct:
out_java_struct.write(consts.hu_struct_file_prefix)
out_java_struct.write(consts.txout_defn)
+ out_java_struct.write(consts.hu_struct_file_suffix)
fn_line = "struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing)"
write_c(fn_line + " {")
write_c("\treturn CVec_u8Z_clone(&thing->script_pubkey);")
with open(f"{sys.argv[3]}/structs/BigEndianScalar{consts.file_ext}", "w") as out_java_struct:
out_java_struct.write(consts.hu_struct_file_prefix)
out_java_struct.write(consts.scalar_defn)
+ out_java_struct.write(consts.hu_struct_file_suffix)
fn_line = "struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing)"
write_c(fn_line + " {\n")
write_c("\tLDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };\n")
else:
assert(line == "\n")
- out_java.write(consts.bindings_footer)
+ out_java.write(consts.bindings_footer())
for struct_name in opaque_structs:
with open(f"{sys.argv[3]}/structs/{struct_name.replace('LDK', '')}{consts.file_ext}", "a") as out_java_struct:
- out_java_struct.write("}\n")
+ out_java_struct.write("}\n" + consts.hu_struct_file_suffix)
for struct_name in trait_structs:
with open(f"{sys.argv[3]}/structs/{struct_name.replace('LDK', '')}{consts.file_ext}", "a") as out_java_struct:
- out_java_struct.write("}\n")
+ out_java_struct.write("}\n" + consts.hu_struct_file_suffix)
for struct_name in complex_enums:
with open(f"{sys.argv[3]}/structs/{struct_name.replace('LDK', '').replace('COption', 'Option')}{consts.file_ext}", "a") as out_java_struct:
- out_java_struct.write("}\n")
+ out_java_struct.write("}\n" + consts.hu_struct_file_suffix)
for struct_name in result_types:
with open(f"{sys.argv[3]}/structs/{struct_name.replace('LDKCResult', 'Result')}{consts.file_ext}", "a") as out_java_struct:
- out_java_struct.write("}\n")
+ out_java_struct.write("}\n" + consts.hu_struct_file_suffix)
for struct_name in tuple_types:
struct_hu_name = struct_name.replace("LDKC2Tuple", "TwoTuple").replace("LDKC3Tuple", "ThreeTuple")
with open(f"{sys.argv[3]}/structs/{struct_hu_name}{consts.file_ext}", "a") as out_java_struct:
- out_java_struct.write("}\n")
+ out_java_struct.write("}\n" + consts.hu_struct_file_suffix)
with open(f"{sys.argv[4]}/bindings.c.body", "w") as out_c:
out_c.write(consts.c_file_pfx)
self.target = target
self.c_array_class_caches = set()
self.c_type_map = dict(
+ bool = ['boolean'],
uint8_t = ['byte'],
uint16_t = ['short'],
uint32_t = ['int'],
}
}"""
- self.bindings_footer = "}\n"
-
self.util_fn_pfx = """package org.ldk.structs;
import org.ldk.impl.bindings;
import org.ldk.enums.*;
import javax.annotation.Nullable;
"""
+ self.hu_struct_file_suffix = ""
self.c_fn_ty_pfx = "JNIEXPORT "
self.c_fn_args_pfx = "JNIEnv *env, jclass clz"
self.file_ext = ".java"
self.is_arr_some_check = ("", " != NULL")
self.get_native_arr_len_call = ("(*env)->GetArrayLength(env, ", ")")
+ def bindings_footer(self):
+ return "}\n"
+
def construct_jenv(self):
res = "JNIEnv *env;\n"
res += "jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);\n"
self.function_ptr_counter = 0
self.function_ptrs = {}
self.c_type_map = dict(
+ bool = ['boolean', 'boolean', 'XXX'],
uint8_t = ['number', 'number', 'Uint8Array'],
uint16_t = ['number', 'number', 'Uint16Array'],
uint32_t = ['number', 'number', 'Uint32Array'],
return "<git_version_ldk_garbagecollected>";
}"""
- self.bindings_footer = ""
-
self.common_base = """
function freer(f: () => void) { f() }
const finalizer = new FinalizationRegistry(freer);
import * as bindings from '../bindings.mjs'
"""
+ self.hu_struct_file_suffix = ""
self.util_fn_pfx = self.hu_struct_file_prefix + "\nexport class UtilMethods extends CommonBase {\n"
self.util_fn_sfx = "}"
self.c_fn_ty_pfx = ""
self.is_arr_some_check = ("", " != 0")
self.get_native_arr_len_call = ("", "->arr_len")
+ def bindings_footer(self):
+ return ""
+
def release_native_arr_ptr_call(self, ty_info, arr_var, arr_ptr_var):
return None
def create_native_arr_call(self, arr_len, ty_info):