X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=java_strings.py;h=3827005a2707dbd00a7eb0ca1ecdeb339f13df0d;hb=6d094e745feaf94c1059555cd1c997965a34bc36;hp=a83671db48a27c1d23cd9e3875d5736765afca88;hpb=f95cc8ba7d61d65aa37e6448e6a083edc6e72fc1;p=ldk-java diff --git a/java_strings.py b/java_strings.py index a83671db..3827005a 100644 --- a/java_strings.py +++ b/java_strings.py @@ -103,9 +103,10 @@ public class version { self.util_fn_pfx = """package org.ldk.structs; import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; import java.util.Arrays; import javax.annotation.Nullable; -import org.ldk.enums.*; public class UtilMethods { """ @@ -163,6 +164,7 @@ void __attribute__((constructor)) spawn_stderr_redirection() { self.c_file_pfx = self.c_file_pfx + """#define MALLOC(a, _) malloc(a) #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); } #define CHECK_ACCESS(p) +#define CHECK_INNER_FIELD_ACCESS_OR_NULL(v) """ if not DEBUG: self.c_file_pfx += """#define DO_ASSERT(a) (void)(a) @@ -319,7 +321,7 @@ void __wrap_free(void* ptr) { __real_free(ptr); } -static void CHECK_ACCESS(void* ptr) { +static void CHECK_ACCESS(const void* ptr) { DO_ASSERT(!pthread_mutex_lock(&allocation_mtx)); allocation* it = allocation_ll; while (it->ptr != ptr) { @@ -336,6 +338,13 @@ static void CHECK_ACCESS(void* ptr) { } DO_ASSERT(!pthread_mutex_unlock(&allocation_mtx)); } +#define CHECK_INNER_FIELD_ACCESS_OR_NULL(v) \\ + if (v.is_owned && v.inner != NULL) { \\ + const void *p = __unmangle_inner_ptr(v.inner); \\ + if (p != NULL) { \\ + CHECK_ACCESS(p); \\ + } \\ + } void* __real_realloc(void* ptr, size_t newlen); void* __wrap_realloc(void* ptr, size_t len) { @@ -1192,6 +1201,8 @@ import javax.annotation.Nullable; out_java_struct += "\tpublic static " + return_type_info.java_hu_ty + " with_default(" else: out_java_struct += "\tpublic static " + return_type_info.java_hu_ty + " " + meth_n + "(" + elif meth_n == "clone_ptr": + out_java_struct += ("\t" + return_type_info.java_hu_ty + " " + meth_n + "(") else: out_java_struct += ("\tpublic " + return_type_info.java_hu_ty + " " + meth_n + "(") for idx, arg in enumerate(argument_types):