Skip to content

Commit 587ee73

Browse files
committed
[Java] Drop unused util methods
1 parent 6607e50 commit 587ee73

File tree

1 file changed

+3
-98
lines changed

1 file changed

+3
-98
lines changed

java_strings.py

Lines changed: 3 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ def __init__(self, DEBUG: bool, target: Target, **kwargs):
3939
import java.nio.file.StandardCopyOption;
4040
4141
public class bindings {
42-
public static class VecOrSliceDef {
43-
public long dataptr;
44-
public long datalen;
45-
public long stride;
46-
public VecOrSliceDef(long dataptr, long datalen, long stride) {
47-
this.dataptr = dataptr; this.datalen = datalen; this.stride = stride;
48-
}
49-
}
5042
static {
5143
try {
5244
// Try to load natively first, this works on Android and in testing.
@@ -69,32 +61,20 @@ def __init__(self, DEBUG: bool, target: Target, **kwargs):
6961
throw new IllegalArgumentException(e);
7062
}
7163
}
72-
init(java.lang.Enum.class, VecOrSliceDef.class);
64+
init(java.lang.Enum.class);
7365
init_class_cache();
7466
if (!get_lib_version_string().equals(version.get_ldk_java_bindings_version()))
7567
throw new IllegalArgumentException("Compiled LDK library and LDK class failes do not match");
7668
// Fetching the LDK versions from C also checks that the header and binaries match
7769
System.err.println("Loaded LDK-Java Bindings " + version.get_ldk_java_bindings_version() + " with LDK " + get_ldk_version() + " and LDK-C-Bindings " + get_ldk_c_bindings_version());
7870
}
79-
static native void init(java.lang.Class c, java.lang.Class slicedef);
71+
static native void init(java.lang.Class c);
8072
static native void init_class_cache();
8173
static native String get_lib_version_string();
8274
8375
public static native String get_ldk_c_bindings_version();
8476
public static native String get_ldk_version();
8577
86-
public static native boolean deref_bool(long ptr);
87-
public static native long deref_long(long ptr);
88-
public static native void free_heap_ptr(long ptr);
89-
public static native byte[] read_bytes(long ptr, long len);
90-
public static native byte[] get_u8_slice_bytes(long slice_ptr);
91-
public static native long bytes_to_u8_vec(byte[] bytes);
92-
public static native long new_txpointer_copy_data(byte[] txdata);
93-
public static native void txpointer_free(long ptr);
94-
public static native byte[] txpointer_get_buffer(long ptr);
95-
public static native long vec_slice_len(long vec);
96-
public static native long new_empty_slice_vec();
97-
9878
"""
9979
self.bindings_version_file = """package org.ldk.impl;
10080
@@ -431,84 +411,9 @@ class CommonBase {
431411
"""
432412
self.c_file_pfx = self.c_file_pfx + """
433413
static jmethodID ordinal_meth = NULL;
434-
static jmethodID slicedef_meth = NULL;
435-
static jclass slicedef_cls = NULL;
436-
JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
414+
JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class) {
437415
ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
438416
CHECK(ordinal_meth != NULL);
439-
slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
440-
CHECK(slicedef_meth != NULL);
441-
slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
442-
CHECK(slicedef_cls != NULL);
443-
}
444-
445-
JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
446-
return *((bool*)ptr);
447-
}
448-
JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
449-
return *((long*)ptr);
450-
}
451-
JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
452-
FREE((void*)ptr);
453-
}
454-
JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
455-
jbyteArray ret_arr = (*env)->NewByteArray(env, len);
456-
(*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
457-
return ret_arr;
458-
}
459-
JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
460-
LDKu8slice *slice = (LDKu8slice*)slice_ptr;
461-
jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
462-
(*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
463-
return ret_arr;
464-
}
465-
JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
466-
LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
467-
vec->datalen = (*env)->GetArrayLength(env, bytes);
468-
vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
469-
(*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
470-
return (uint64_t)vec;
471-
}
472-
JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
473-
LDKTransaction *txdata = (LDKTransaction*)ptr;
474-
LDKu8slice slice;
475-
slice.data = txdata->data;
476-
slice.datalen = txdata->datalen;
477-
return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
478-
}
479-
JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
480-
LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
481-
txdata->datalen = (*env)->GetArrayLength(env, bytes);
482-
txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
483-
txdata->data_is_owned = false;
484-
(*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
485-
return (uint64_t)txdata;
486-
}
487-
JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
488-
LDKTransaction *tx = (LDKTransaction*)ptr;
489-
tx->data_is_owned = true;
490-
Transaction_free(*tx);
491-
FREE((void*)ptr);
492-
}
493-
JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
494-
// Check offsets of a few Vec types are all consistent as we're meant to be generic across types
495-
_Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
496-
_Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
497-
_Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
498-
_Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
499-
LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
500-
return (uint64_t)vec->datalen;
501-
}
502-
JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
503-
// Check sizes of a few Vec types are all consistent as we're meant to be generic across types
504-
_Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
505-
_Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
506-
_Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
507-
_Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
508-
LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
509-
vec->data = NULL;
510-
vec->datalen = 0;
511-
return (uint64_t)vec;
512417
}
513418
514419
// We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)

0 commit comments

Comments
 (0)