else:
bindings_instantiator += ", " + first_to_lower(var.arg_name)
else:
- bindings_instantiator += ", " + first_to_lower(var[1]) + ".bindings_instance"
+ bindings_instantiator += ", " + first_to_lower(var[1]) + ".instance_idx"
super_instantiator += first_to_lower(var[1]) + "_impl, "
pointer_to_adder += "\t\timpl_holder.held.ptrs_to.push(" + first_to_lower(var[1]) + ");\n"
impl_constructor_arguments += f", {first_to_lower(var[1])}_impl: {var[0].replace('LDK', '')}Interface"
trait_constructor_arguments += ", " + var.arg_name
else:
super_constructor_statements += "\t\tconst " + first_to_lower(var[1]) + " = " + var[1] + ".new_impl(" + super_instantiator + ");\n"
- trait_constructor_arguments += ", " + first_to_lower(var[1]) + ".bindings_instance"
+ trait_constructor_arguments += ", " + first_to_lower(var[1]) + ".instance_idx"
for suparg in var[2]:
if isinstance(suparg, ConvInfo):
trait_constructor_arguments += ", " + suparg.arg_name
/* @internal */
public bindings_instance?: bindings.{struct_name};
+ /* @internal */
+ public instance_idx?: number;
+
/* @internal */
constructor(_dummy: object, ptr: bigint) {{
super(ptr, bindings.{struct_name.replace("LDK","")}_free);
const impl_holder: {struct_name}Holder = new {struct_name}Holder();
let structImplementation = {{
{out_interface_implementation_overrides} }} as bindings.{struct_name};
-{super_constructor_statements} const ptr: bigint = bindings.{struct_name}_new(structImplementation{bindings_instantiator});
+{super_constructor_statements} const ptr_idx: [bigint, number] = bindings.{struct_name}_new(structImplementation{bindings_instantiator});
- impl_holder.held = new {struct_name.replace("LDK", "")}(null, ptr);
+ impl_holder.held = new {struct_name.replace("LDK", "")}(null, ptr_idx[0]);
+ impl_holder.held.instance_idx = ptr_idx[1];
impl_holder.held.bindings_instance = structImplementation;
{pointer_to_adder} return impl_holder.held;
}}
out_typescript_bindings += "}\n\n"
+ c_call_extra_args = ""
out_typescript_bindings += f"/* @internal */\nexport function {struct_name}_new(impl: {struct_name}"
for var in flattened_field_var_conversions:
if isinstance(var, ConvInfo):
out_typescript_bindings += f", {var.arg_name}: {var.java_ty}"
+ c_call_extra_args += f", {var.arg_name}"
else:
- out_typescript_bindings += f", {var[1]}: {var[0]}"
+ out_typescript_bindings += f", {var[1]}: number"
+ c_call_extra_args += f", {var[1]}"
+
- out_typescript_bindings += f"""): bigint {{
+ out_typescript_bindings += f"""): [bigint, number] {{
if(!isWasmInitialized) {{
throw new Error("initializeWasm() must be awaited first!");
}}
if (js_objs[i] == null || js_objs[i] == undefined) {{ new_obj_idx = i; break; }}
}}
js_objs[i] = new WeakRef(impl);
- return wasm.TS_{struct_name}_new(i);
+ return [wasm.TS_{struct_name}_new(i{c_call_extra_args}), i];
}}
"""