Previously for the full test suite (incl 64 HumanObjectPeerTest runs):
`991 allocations remained for 32165 bytes.`
After for the full test suite (incl 64 HumanObjectPeerTest runs):
`179 allocations remained for 5369 bytes.`
from_hu_conv = "bindings." + self.tuple_types[ty_info.rust_obj][1].replace("LDK", "") + "_new("
to_hu_conv_pfx = ""
to_hu_conv_sfx = ty_info.java_hu_ty + " " + ty_info.var_name + "_conv = new " + ty_info.java_hu_ty + "("
from_hu_conv = "bindings." + self.tuple_types[ty_info.rust_obj][1].replace("LDK", "") + "_new("
to_hu_conv_pfx = ""
to_hu_conv_sfx = ty_info.java_hu_ty + " " + ty_info.var_name + "_conv = new " + ty_info.java_hu_ty + "("
for idx, conv in enumerate(self.tuple_types[ty_info.rust_obj][0]):
if idx != 0:
to_hu_conv_sfx = to_hu_conv_sfx + ", "
for idx, conv in enumerate(self.tuple_types[ty_info.rust_obj][0]):
if idx != 0:
to_hu_conv_sfx = to_hu_conv_sfx + ", "
if conv_map.to_hu_conv is not None:
to_hu_conv_pfx = to_hu_conv_pfx + conv_map.to_hu_conv + ";\n"
to_hu_conv_sfx = to_hu_conv_sfx + conv_map.to_hu_conv_name
if conv_map.to_hu_conv is not None:
to_hu_conv_pfx = to_hu_conv_pfx + conv_map.to_hu_conv + ";\n"
to_hu_conv_sfx = to_hu_conv_sfx + conv_map.to_hu_conv_name
+ if to_hu_conv_refs is not None:
+ if conv_map.c_ty.endswith("Array"):
+ to_hu_conv_refs = None
+ else:
+ to_hu_conv_refs = to_hu_conv_refs + "\n" + conv_map.to_hu_conv_name + ".ptrs_to.add(" + ty_info.var_name + "_conv);"
else:
to_hu_conv_sfx = to_hu_conv_sfx + ty_info.var_name + "_" + chr(idx + ord("a"))
if conv_map.from_hu_conv is not None:
else:
to_hu_conv_sfx = to_hu_conv_sfx + ty_info.var_name + "_" + chr(idx + ord("a"))
if conv_map.from_hu_conv is not None:
else:
from_hu_conv = from_hu_conv + ty_info.var_name + "." + chr(idx + ord("a"))
else:
from_hu_conv = from_hu_conv + ty_info.var_name + "." + chr(idx + ord("a"))
+ if to_hu_conv_refs is None:
+ to_hu_conv = to_hu_conv_pfx + to_hu_conv_sfx + ");\n// Warning: We may not free the C tuple object!"
+ else:
+ to_hu_conv = to_hu_conv_pfx + to_hu_conv_sfx + ", () -> {\n"
+ to_hu_conv = to_hu_conv + "\tbindings." + ty_info.rust_obj.replace("LDK", "") + "_free(" + ty_info.var_name + ");\n"
+ to_hu_conv = to_hu_conv + "});" + to_hu_conv_refs
if not ty_info.is_ptr and not holds_ref:
ret_conv = (ty_info.rust_obj + "* " + ty_info.var_name + "_ref = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*" + ty_info.var_name + "_ref = ", ";")
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None,
ret_conv = ret_conv,
ret_conv_name = "(long)" + ty_info.var_name + "_ref",
if not ty_info.is_ptr and not holds_ref:
ret_conv = (ty_info.rust_obj + "* " + ty_info.var_name + "_ref = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*" + ty_info.var_name + "_ref = ", ";")
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None,
ret_conv = ret_conv,
ret_conv_name = "(long)" + ty_info.var_name + "_ref",
- to_hu_conv = to_hu_conv_pfx + to_hu_conv_sfx + ");", to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = (from_hu_conv + ")", from_hu_conv_sfx))
+ to_hu_conv = to_hu_conv, to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = (from_hu_conv + ")", from_hu_conv_sfx))
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None,
ret_conv = ("long " + ty_info.var_name + "_ref = (long)(&", ") | 1;"), ret_conv_name = ty_info.var_name + "_ref",
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None,
ret_conv = ("long " + ty_info.var_name + "_ref = (long)(&", ") | 1;"), ret_conv_name = ty_info.var_name + "_ref",
- to_hu_conv = to_hu_conv_pfx + to_hu_conv_sfx + ");", to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = (from_hu_conv + ")", from_hu_conv_sfx))
+ to_hu_conv = to_hu_conv, to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = (from_hu_conv + ")", from_hu_conv_sfx))
# The manually-defined types - TxOut and Transaction
assert ty_info.rust_obj == "LDKTxOut"
# The manually-defined types - TxOut and Transaction
assert ty_info.rust_obj == "LDKTxOut"
package org.ldk.util;
public class ThreeTuple<A, B, C> {
package org.ldk.util;
public class ThreeTuple<A, B, C> {
+ private Runnable finalize_run;
public A a;
public B b;
public C c;
public A a;
public B b;
public C c;
this.b = b;
this.c = c;
}
this.b = b;
this.c = c;
}
+ public ThreeTuple(A a, B b, C c, Runnable finalize_run) {
+ this(a, b, c);
+ this.finalize_run = finalize_run;
+ }
+ @Override
+ public void finalize() throws Throwable {
+ if (finalize_run != null) finalize_run.run();
+ super.finalize();
+ }
package org.ldk.util;
public class TwoTuple<A, B> {
package org.ldk.util;
public class TwoTuple<A, B> {
+ private Runnable finalize_run;
public A a;
public B b;
public TwoTuple(A a, B b) {
this.a = a;
this.b = b;
}
public A a;
public B b;
public TwoTuple(A a, B b) {
this.a = a;
this.b = b;
}
+ public TwoTuple(A a, B b, Runnable finalize_run) {
+ this(a, b);
+ this.finalize_run = finalize_run;
+ }
+ @Override
+ public void finalize() throws Throwable {
+ if (finalize_run != null) finalize_run.run();
+ super.finalize();
+ }