X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=genbindings.py;h=3c79bb8fa94789fd245dd4e6f6891442ac0d62d7;hb=10dd56344c75a6fdfe108963f99afdc911eaf8d3;hp=67de282141766d5422cc5911e3a2add7e3a6ddd1;hpb=2f8218ecc6d7c18fb331e5429960e296dd43b943;p=ldk-java diff --git a/genbindings.py b/genbindings.py index 67de2821..3c79bb8f 100755 --- a/genbindings.py +++ b/genbindings.py @@ -28,10 +28,17 @@ elif sys.argv[6] == "typescript": target = typescript_strings.Target.NODEJS if len(sys.argv) == 8 and sys.argv[7] == 'browser': target = typescript_strings.Target.BROWSER -elif sys.argv[6] == "c_sharp": +elif sys.argv[6].startswith("c_sharp"): import csharp_strings from csharp_strings import Consts - target = csharp_strings.Target.CSHARP + if sys.argv[6] == "c_sharp-win": + target = csharp_strings.Target.WINDOWS + elif sys.argv[6] == "c_sharp-darwin": + target = csharp_strings.Target.PTHREAD + elif sys.argv[6] == "c_sharp-linux": + target = csharp_strings.Target.LINUX + else: + assert False elif sys.argv[6] == "python": import python_strings from python_strings import Consts @@ -655,7 +662,8 @@ with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}", expected_struct in result_types or expected_struct in tuple_types) and not is_free impl_on_utils = not impl_on_struct and (not is_free and not method_name.endswith("_clone") and not method_name.startswith("TxOut") and not method_name.startswith("TxIn") and - not method_name.startswith("BigEndianScalar") and not method_name.startswith("_") and + not method_name.startswith("BigEndianScalar") and not method_name.startswith("WitnessProgram") and + not method_name.startswith("_") and method_name != "check_platform" and method_name != "Result_read" and not expected_struct in unitary_enums and ((not method_name.startswith("C2Tuple_") and not method_name.startswith("C3Tuple_")) @@ -1099,46 +1107,11 @@ with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}", 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);") - write_c("}") - map_fn(fn_line + "\n", re.compile("(.*) (TxOut_get_script_pubkey) \((.*)\)").match(fn_line), None, None, None) - fn_line = "uint64_t TxOut_get_value (struct LDKTxOut* thing)" - write_c(fn_line + " {") - write_c("\treturn thing->value;") - write_c("}") - map_fn(fn_line + "\n", re.compile("(.*) (TxOut_get_value) \((.*)\)").match(fn_line), None, None, None) elif struct_name == "LDKTxIn": with open(f"{sys.argv[3]}/structs/TxIn{consts.file_ext}", "w") as out_java_struct: out_java_struct.write(consts.hu_struct_file_prefix) out_java_struct.write(consts.txin_defn) out_java_struct.write(consts.hu_struct_file_suffix) - fn_line = "struct LDKWitness TxIn_get_witness (struct LDKTxIn* thing)" - write_c(fn_line + " {") - write_c("\treturn Witness_clone(&thing->witness);") - write_c("}") - map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_witness) \((.*)\)").match(fn_line), None, None, None) - fn_line = "struct LDKCVec_u8Z TxIn_get_script_sig (struct LDKTxIn* thing)" - write_c(fn_line + " {") - write_c("\treturn CVec_u8Z_clone(&thing->script_sig);") - write_c("}") - map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_script_sig) \((.*)\)").match(fn_line), None, None, None) - fn_line = "LDKThirtyTwoBytes TxIn_get_previous_txid (struct LDKTxIn* thing)" - write_c(fn_line + " {") - write_c("\treturn thing->previous_txid;") - write_c("}") - map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_previous_txid) \((.*)\)").match(fn_line), None, None, None) - fn_line = "uint32_t TxIn_get_previous_vout (struct LDKTxIn* thing)" - write_c(fn_line + " {") - write_c("\treturn thing->previous_vout;") - write_c("}") - map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_previous_vout) \((.*)\)").match(fn_line), None, None, None) - fn_line = "uint32_t TxIn_get_sequence (struct LDKTxIn* thing)" - write_c(fn_line + " {") - write_c("\treturn thing->sequence;") - write_c("}") - map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_sequence) \((.*)\)").match(fn_line), None, None, None) elif struct_name == "LDKBigEndianScalar": 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) @@ -1159,6 +1132,11 @@ with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}", fn_line = "static void BigEndianScalar_free (struct LDKBigEndianScalar thing)" write_c(fn_line + " {}\n") map_fn(fn_line + "\n", re.compile("static (.*) (BigEndianScalar_free) \((.*)\)").match(fn_line), None, None, None) + elif struct_name == "LDKWitnessProgram": + with open(f"{sys.argv[3]}/structs/WitnessProgram{consts.file_ext}", "w") as out_java_struct: + out_java_struct.write(consts.hu_struct_file_prefix) + out_java_struct.write(consts.witness_program_defn) + out_java_struct.write(consts.hu_struct_file_suffix) else: pass # Everything remaining is a byte[] of some form cur_block_obj = None