if ty_info.arr_access is None:
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None,
- ret_conv = ("jstring " + ty_info.var_name + "_conv = (*env)->NewStringUTF(env, ", ");"), ret_conv_name = ty_info.var_name + "_conv",
+ ret_conv = ("jstring " + ty_info.var_name + "_conv = " + self.consts.owned_str_to_c_call[0], self.consts.owned_str_to_c_call[1] + ";"), ret_conv_name = ty_info.var_name + "_conv",
to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
else:
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
";\nchar* " + ty_info.var_name + "_buf = MALLOC(" + ty_info.var_name + "_str." + ty_info.arr_len + " + 1, \"str conv buf\");\n" +
"memcpy(" + ty_info.var_name + "_buf, " + ty_info.var_name + "_str." + ty_info.arr_access + ", " + ty_info.var_name + "_str." + ty_info.arr_len + ");\n" +
ty_info.var_name + "_buf[" + ty_info.var_name + "_str." + ty_info.arr_len + "] = 0;\n" +
- "jstring " + ty_info.var_name + "_conv = (*env)->NewStringUTF(env, " + ty_info.var_name + "_str." + ty_info.arr_access + ");\n" +
+ "jstring " + ty_info.var_name + "_conv = " + self.consts.owned_str_to_c_call[0] + ty_info.var_name + "_str." + ty_info.arr_access + self.consts.owned_str_to_c_call[1] + ";\n" +
"FREE(" + ty_info.var_name + "_buf);"),
ret_conv_name = ty_info.var_name + "_conv", to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
elif ty_info.var_name == "" and not print_void:
self.ptr_c_ty = "int64_t"
self.ptr_native_ty = "long"
self.result_c_ty = "jclass"
+ self.owned_str_to_c_call = ("(*env)->NewStringUTF(env, ", ")")
self.ptr_arr = "jobjectArray"
self.get_native_arr_len_call = ("(*env)->GetArrayLength(env, ", ")")
self.get_native_arr_ptr_call = ("(*env)->GetPrimitiveArrayCritical(env, ", ", NULL)")
typedef struct int64_tArray {uint32_t len;int64_t *ptr;} int64_tArray;
typedef struct uint32_tArray {uint32_t len;int32_t *ptr;} uint32_tArray;
typedef struct int8_tArray {uint32_t len;int8_t *ptr;} int8_tArray;
+typedef struct jstring {} jstring;
+
+jstring conv_owned_string(const char* _src) { jstring a; return a; }
typedef bool jboolean;
self.ptr_c_ty = "uint32_t"
self.ptr_native_ty = "number" # "uint32_t"
self.result_c_ty = "uint32_t"
+ self.owned_str_to_c_call = ("conv_owned_string(", ")")
self.ptr_arr = "uint32_tArray"
self.get_native_arr_len_call = ("", ".len")
self.get_native_arr_ptr_call = ("", ".ptr")