X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=gen_type_mapping.py;h=07d892bfce5d4d847b26eabb5dc7ccbb4bc5a58c;hb=a83a158cba5a1f164e18b064e9cafc749365099a;hp=d78057b6a3a29acba9b18c57ead2ba7cba5b1ff1;hpb=6884c87ff29249df35c246e86e4d6e38bc930d34;p=ldk-java diff --git a/gen_type_mapping.py b/gen_type_mapping.py index d78057b6..07d892bf 100644 --- a/gen_type_mapping.py +++ b/gen_type_mapping.py @@ -17,7 +17,8 @@ class TypeMappingGenerator: def map_type(self, fn_arg, print_void, ret_arr_len, is_free, holds_ref): ty_info = self.java_c_types(fn_arg, ret_arr_len) - return self.map_type_with_info(ty_info, print_void, ret_arr_len, is_free, holds_ref) + mapped_info = self.map_type_with_info(ty_info, print_void, ret_arr_len, is_free, holds_ref) + return mapped_info def map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, holds_ref): if ty_info.c_ty == "void": @@ -243,7 +244,6 @@ class TypeMappingGenerator: arg_conv = opaque_arg_conv, arg_conv_name = "&" + ty_info.var_name + "_conv", arg_conv_cleanup = None, ret_conv = (ty_info.rust_obj + " " + ty_info.var_name + "_var = *", opaque_ret_conv_suf), ret_conv_name = ty_info.var_name + "_ref", - # to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");", to_hu_conv = self.consts.to_hu_conv_templates['ptr'].replace('{human_type}', ty_info.java_hu_ty).replace('{var_name}', ty_info.var_name), to_hu_conv_name = ty_info.var_name + "_hu_conv", from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", "this.ptrs_to.add(" + ty_info.var_name + ")")) @@ -252,7 +252,6 @@ class TypeMappingGenerator: arg_conv = opaque_arg_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, ret_conv = (ty_info.rust_obj + " " + ty_info.var_name + "_var = ", opaque_ret_conv_suf), ret_conv_name = ty_info.var_name + "_ref", - # to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");", to_hu_conv = self.consts.to_hu_conv_templates['default'].replace('{human_type}', ty_info.java_hu_ty).replace('{var_name}', ty_info.var_name), to_hu_conv_name = ty_info.var_name + "_hu_conv", from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", "this.ptrs_to.add(" + ty_info.var_name + ")")) @@ -274,9 +273,7 @@ class TypeMappingGenerator: if needs_full_clone and (ty_info.rust_obj.replace("LDK", "") + "_clone") in self.clone_fns: base_conv = base_conv + "\n" + ty_info.var_name + "_conv = " + ty_info.rust_obj.replace("LDK", "") + "_clone(" + ty_info.var_name + ");" else: - base_conv = base_conv + "\nif (" + ty_info.var_name + "_conv.free == " + ty_info.rust_obj + "_JCalls_free) {\n" - base_conv = base_conv + "\t// If this_arg is a JCalls struct, then we need to increment the refcnt in it.\n" - base_conv = base_conv + "\t" + ty_info.rust_obj + "_JCalls_clone(" + ty_info.var_name + "_conv.this_arg);\n}" + base_conv = base_conv + self.consts.trait_struct_inc_refcnt(ty_info) if needs_full_clone: base_conv = base_conv + "// Warning: we may need a move here but can't do a full clone!\n"