- out_java_struct = None
- if ("LDK" + struct_meth in opaque_structs or "LDK" + struct_meth in trait_structs) and not is_free:
- out_java_struct = open(f"{sys.argv[3]}/structs/{struct_meth}{consts.file_ext}", "a")
- if not args_known:
- out_java_struct.write("\t// Skipped " + re_match.group(2) + "\n")
- out_java_struct.close()
- out_java_struct = None
- else:
- meth_n = re_match.group(2)[len(struct_meth) + 1:]
- if not takes_self:
- out_java_struct.write("\tpublic static " + ret_info.java_hu_ty + " constructor_" + meth_n + "(")
- else:
- out_java_struct.write("\tpublic " + ret_info.java_hu_ty + " " + meth_n + "(")
- for idx, arg in enumerate(arg_names):
- if idx != 0:
- if not takes_self or idx > 1:
- out_java_struct.write(", ")
- elif takes_self:
- continue
- if arg.java_ty != "void":
- if arg.arg_name in default_constructor_args:
- for explode_idx, explode_arg in enumerate(default_constructor_args[arg.arg_name]):
- if explode_idx != 0:
- out_java_struct.write(", ")
- out_java_struct.write(explode_arg.java_hu_ty + " " + arg.arg_name + "_" + explode_arg.arg_name)
- else:
- out_java_struct.write(arg.java_hu_ty + " " + arg.arg_name)
-
-
- out_java.write(");\n")
- write_c(") {\n")
- if out_java_struct is not None:
- out_java_struct.write(") {\n")
-
- for info in arg_names:
- if info.arg_conv is not None:
- write_c("\t" + info.arg_conv.replace('\n', "\n\t") + "\n")
-
- if ret_info.ret_conv is not None:
- write_c("\t" + ret_conv_pfx.replace('\n', '\n\t'))
- elif ret_info.c_ty != "void":
- write_c("\t" + ret_info.c_ty + " ret_val = ")
- else:
- write_c("\t")
-
- if c_call_string is None:
- write_c(re_match.group(2) + "(")
- else:
- write_c(c_call_string)
- for idx, info in enumerate(arg_names):
- if info.arg_conv_name is not None:
- if idx != 0:
- write_c(", ")
- elif c_call_string is not None:
- continue
- write_c(info.arg_conv_name)
- write_c(")")
- if ret_info.ret_conv is not None:
- write_c(ret_conv_sfx.replace('\n', '\n\t'))
+ 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)
+ out_java.write(out_java_delta)
+
+ if is_free:
+ assert len(argument_types) == 1
+ assert return_type_info.c_ty == "void"
+ write_c(consts.c_fn_ty_pfx + "void " + consts.c_fn_name_define_pfx(method_name, True) + argument_types[0].c_ty + " " + argument_types[0].ty_info.var_name + ") {\n")
+ if argument_types[0].ty_info.passed_as_ptr and not argument_types[0].ty_info.rust_obj in opaque_structs:
+ write_c("\tif ((" + argument_types[0].ty_info.var_name + " & 1) != 0) return;\n")
+
+ for info in argument_types:
+ if info.arg_conv is not None:
+ write_c("\t" + info.arg_conv.replace('\n', "\n\t") + "\n")
+ assert c_call_string is None
+ write_c("\t" + method_name + "(")
+ if argument_types[0].arg_conv_name is not None:
+ write_c(argument_types[0].arg_conv_name)
+ write_c(");")
+ for info in argument_types:
+ if info.arg_conv_cleanup is not None:
+ write_c("\n\t" + info.arg_conv_cleanup.replace("\n", "\n\t"))
+ write_c("\n}\n\n")