- base_ty = ty_info.subty.java_hu_ty.split("[")[0].split("<")[0]
- to_hu_conv = ty_info.java_hu_ty + " " + conv_name + "_arr = new " + base_ty + "[" + arr_name + ".length]"
- if "[" in ty_info.subty.java_hu_ty.split("<")[0]:
- # Do a bit of a dance to move any excess [] to the end
- to_hu_conv += "[" + ty_info.subty.java_hu_ty.split("<")[0].split("[")[1]
- to_hu_conv += ";\nfor (int " + idxc + " = 0; " + idxc + " < " + arr_name + ".length; " + idxc + "++) {\n"
- to_hu_conv += "\t" + subty.java_ty + " " + conv_name + " = " + 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}"
+ to_hu_conv = self.consts.var_decl_statement(self.consts.c_type_map["uint32_t"][0], conv_name + "_len", self.consts.get_java_arr_len(arr_name)) + ";\n"
+ to_hu_conv += self.consts.var_decl_statement(ty_info.java_hu_ty, conv_name + "_arr", self.consts.constr_hu_array(ty_info, conv_name + "_len"))
+ to_hu_conv += ";\n"
+ pfx = ""
+ if is_nullable:
+ to_hu_conv += "if (" + arr_name + " != null) {\n"
+ pfx = "\t"
+ to_hu_conv += pfx + self.consts.for_n_in_range(idxc, "0", conv_name + "_len") + "\n"
+
+ to_hu_conv += pfx + "\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 += pfx + "\t" + subty.to_hu_conv.replace("\n", "\n\t" + pfx) + "\n"
+ to_hu_conv += pfx + "\t" + conv_name + "_arr[" + idxc + "] = " + subty.to_hu_conv_name + ";\n"
+ to_hu_conv += pfx + "}"
+ if is_nullable:
+ to_hu_conv += "\n}"
+ cleanup = self.consts.cleanup_converted_native_array(ty_info, arr_name)
+ if cleanup is not None:
+ to_hu_conv += "\n" + cleanup