From: Matt Corallo Date: Sat, 5 Jun 2021 16:49:20 +0000 (+0000) Subject: Handle methods taking non-ref self by using standard conversion X-Git-Tag: v0.0.98~1^2~9 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=5f5d273d63baca66e94d6f34f485fc2398ee12f7;p=ldk-java Handle methods taking non-ref self by using standard conversion --- diff --git a/genbindings.py b/genbindings.py index f35932ef..a03fa4c4 100755 --- a/genbindings.py +++ b/genbindings.py @@ -416,12 +416,15 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java: argument_types = [] default_constructor_args = {} takes_self = False + takes_self_ptr = False args_known = True for argument_index, argument in enumerate(method_arguments): argument_conversion_info = type_mapping_generator.map_type(argument, False, None, is_free, True) if argument_index == 0 and argument_conversion_info.java_hu_ty == struct_meth: takes_self = True + if argument_conversion_info.ty_info.is_ptr: + takes_self_ptr = True if argument_conversion_info.arg_conv is not None and "Warning" in argument_conversion_info.arg_conv: if argument_conversion_info.rust_obj in constructor_fns: assert not is_free @@ -439,7 +442,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java: out_java.write("\t// " + line) (out_java_delta, out_c_delta, out_java_struct_delta) = \ - consts.map_function(argument_types, c_call_string, method_name, return_type_info, struct_meth, default_constructor_args, takes_self, args_known, type_mapping_generator, doc_comment) + consts.map_function(argument_types, c_call_string, method_name, return_type_info, struct_meth, default_constructor_args, takes_self, takes_self_ptr, args_known, type_mapping_generator, doc_comment) out_java.write(out_java_delta) if is_free: diff --git a/java_strings.py b/java_strings.py index 94998db1..223b544d 100644 --- a/java_strings.py +++ b/java_strings.py @@ -1034,7 +1034,7 @@ import java.util.Arrays; return out_opaque_struct_human - def map_function(self, argument_types, c_call_string, method_name, return_type_info, struct_meth, default_constructor_args, takes_self, args_known, type_mapping_generator, doc_comment): + def map_function(self, argument_types, c_call_string, method_name, return_type_info, struct_meth, default_constructor_args, takes_self, takes_self_as_ref, args_known, type_mapping_generator, doc_comment): out_java = "" out_c = "" out_java_struct = None @@ -1076,7 +1076,7 @@ import java.util.Arrays; for idx, arg in enumerate(argument_types): if idx != 0: if not takes_self or idx > 1: - out_java_struct += (", ") + out_java_struct += ", " elif takes_self: continue if arg.java_ty != "void": @@ -1177,6 +1177,8 @@ import java.util.Arrays; else: out_java_struct += ("\t\t" + info.from_hu_conv[1].replace("\n", "\n\t\t") + ";\n") + if takes_self and not takes_self_as_ref: + out_java_struct += "\t\t" + argument_types[0].from_hu_conv[1].replace("\n", "\n\t\t").replace("this_arg", "this") + ";\n" if return_type_info.to_hu_conv_name is not None: out_java_struct += ("\t\treturn " + return_type_info.to_hu_conv_name + ";\n") elif return_type_info.java_ty != "void" and return_type_info.rust_obj != "LDK" + struct_meth: diff --git a/typescript_strings.py b/typescript_strings.py index eb14c155..d5d4499d 100644 --- a/typescript_strings.py +++ b/typescript_strings.py @@ -933,7 +933,7 @@ const decodeString = (stringPointer, free = true) => { """ return out_opaque_struct_human - def map_function(self, argument_types, c_call_string, method_name, return_type_info, struct_meth, default_constructor_args, takes_self, args_known, type_mapping_generator, doc_comment): + def map_function(self, argument_types, c_call_string, method_name, return_type_info, struct_meth, default_constructor_args, takes_self, takes_self_as_ref, args_known, type_mapping_generator, doc_comment): out_java = "" out_c = "" out_java_struct = None