to_hu_conv += "\t" + self.consts.var_decl_statement(subty.java_ty, conv_name, self.consts.get_java_arr_elem(subty, arr_name, idxc)) + ";\n"
to_hu_conv += "\t" + subty.to_hu_conv.replace("\n", "\n\t") + "\n"
to_hu_conv += "\t" + conv_name + "_arr[" + idxc + "] = " + subty.to_hu_conv_name + ";\n}"
+ cleanup = self.consts.cleanup_converted_native_array(ty_info, arr_name)
+ if cleanup is not None:
+ to_hu_conv += "\n" + cleanup
to_hu_conv_name = conv_name + "_arr"
from_hu_conv = self.consts.primitive_arr_from_hu(ty_info.subty, None, arr_name)
if subty.from_hu_conv is not None:
# Do a bit of a dance to move any excess [] to the end
conv += "[" + ty_info.subty.java_hu_ty.split("<")[0].split("[")[1]
return conv
+ def cleanup_converted_native_array(self, ty_info, arr_name):
+ return None
def primitive_arr_from_hu(self, mapped_ty, fixed_len, arr_name):
if fixed_len is not None:
return actualArray;
}
+
+export function freeWasmMemory(pointer: number) { wasm.TS_free(pointer); }
+
/* @internal */
export function getU32ArrayElem(arrayPointer: number, idx: number): number {
const actualArrayViewer = new Uint32Array(wasm.memory.buffer, arrayPointer + 4, idx + 1);
assert False
def constr_hu_array(self, ty_info, arr_len):
return "new Array(" + arr_len + ").fill(null)"
+ def cleanup_converted_native_array(self, ty_info, arr_name):
+ return "bindings.freeWasmMemory(" + arr_name + ")"
def primitive_arr_from_hu(self, mapped_ty, fixed_len, arr_name):
inner = arr_name