From 82afbefb5d833a7ee37323e9691503c36d51bcbd Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 5 Aug 2021 03:18:28 +0000 Subject: [PATCH] Correctly handle null pointers returned from Rust representing None --- java_strings.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java_strings.py b/java_strings.py index f6bf763d..d4931cd9 100644 --- a/java_strings.py +++ b/java_strings.py @@ -106,7 +106,7 @@ import java.util.LinkedList; class CommonBase { long ptr; LinkedList ptrs_to = new LinkedList(); - protected CommonBase(long ptr) { this.ptr = ptr; } + protected CommonBase(long ptr) { assert ptr > 1024; this.ptr = ptr; } } """ @@ -1226,6 +1226,9 @@ import java.util.Arrays; else: out_java_struct += (info.arg_name) out_java_struct += (");\n") + if return_type_info.java_ty == "long" and return_type_info.java_hu_ty != "long": + out_java_struct += "\t\tif (ret < 1024) { return null; }\n" + if return_type_info.to_hu_conv is not None: if not takes_self: out_java_struct += ("\t\t" + return_type_info.to_hu_conv.replace("\n", "\n\t\t").replace("this", -- 2.39.5