X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=java_strings.py;h=cc545e8297f97797dc53ce3b91924c12fe6cf7d9;hb=57c69192cf720e784e837610444e1c762ab0a6fa;hp=1987c10e58db6d3915cdf7e2ba7f8fe1aafb1a2f;hpb=798362a31590a4c5626db086566c083088ef0861;p=ldk-java diff --git a/java_strings.py b/java_strings.py index 1987c10e..cc545e82 100644 --- a/java_strings.py +++ b/java_strings.py @@ -126,7 +126,7 @@ void __attribute__((constructor)) spawn_stderr_redirection() { if not DEBUG: self.c_file_pfx = self.c_file_pfx + """#define MALLOC(a, _) malloc(a) -#define FREE(p) if ((long)(p) > 1024) { free(p); } +#define FREE(p) if ((uint64_t)(p) > 1024) { free(p); } #define DO_ASSERT(a) (void)(a) #define CHECK(a) """ @@ -256,7 +256,7 @@ static void alloc_freed(void* ptr) { __real_free(it); } static void FREE(void* ptr) { - if ((long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys + if ((uint64_t)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys alloc_freed(ptr); __real_free(ptr); } @@ -345,14 +345,14 @@ JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jby vec->datalen = (*env)->GetArrayLength(env, bytes); vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes"); (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data); - return (long)vec; + return (uint64_t)vec; } JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) { LDKTransaction *txdata = (LDKTransaction*)ptr; LDKu8slice slice; slice.data = txdata->data; slice.datalen = txdata->datalen; - return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (long)&slice); + return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice); } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) { LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction"); @@ -360,7 +360,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes"); txdata->data_is_owned = false; (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data); - return (long)txdata; + return (uint64_t)txdata; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) { LDKTransaction *tx = (LDKTransaction*)ptr; @@ -375,7 +375,7 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically"); _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically"); LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr; - return (long)vec->datalen; + return (uint64_t)vec->datalen; } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) { // Check sizes of a few Vec types are all consistent as we're meant to be generic across types @@ -386,7 +386,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNI LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec"); vec->data = NULL; vec->datalen = 0; - return (long)vec; + return (uint64_t)vec; } // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed) @@ -889,7 +889,7 @@ import java.util.Arrays; else: out_c = out_c + ", " + var[1] out_c = out_c + ");\n" - out_c = out_c + "\treturn (long)res_ptr;\n" + out_c = out_c + "\treturn (uint64_t)res_ptr;\n" out_c = out_c + "}\n" return (out_java, out_java_trait, out_c) @@ -1043,8 +1043,12 @@ import java.util.Arrays; if doc_comment is not None: out_java_struct += "\t/**\n\t * " + doc_comment.replace("\n", "\n\t * ") + "\n\t */\n" if not takes_self: - out_java_struct += ( - "\tpublic static " + return_type_info.java_hu_ty + " constructor_" + meth_n + "(") + if meth_n == "new": + out_java_struct += "\tpublic static " + return_type_info.java_hu_ty + " of(" + elif meth_n == "default": + 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 + "(" else: out_java_struct += ("\tpublic " + return_type_info.java_hu_ty + " " + meth_n + "(") for idx, arg in enumerate(argument_types):