-static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
-static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
-static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
-static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
- LDKPaymentPurpose_InvoicePayment_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment;"));
- CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
- LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[BJ)V");
- CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
- LDKPaymentPurpose_SpontaneousPayment_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment;"));
- CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
- LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
- CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
-}
-JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
- LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
- switch(obj->tag) {
- case LDKPaymentPurpose_InvoicePayment: {
- int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
- int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
- return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr, obj->invoice_payment.user_payment_id);
- }
- case LDKPaymentPurpose_SpontaneousPayment: {
- int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
- return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
- }
- default: abort();
- }
-}
-static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
-static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
-static jclass LDKClosureReason_HolderForceClosed_class = NULL;
-static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
-static jclass LDKClosureReason_CooperativeClosure_class = NULL;
-static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
-static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
-static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
-static jclass LDKClosureReason_ProcessingError_class = NULL;
-static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
-static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
-static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
-static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
-static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
- LDKClosureReason_CounterpartyForceClosed_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed;"));
- CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
- LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
- CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
- LDKClosureReason_HolderForceClosed_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$HolderForceClosed;"));
- CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
- LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
- CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
- LDKClosureReason_CooperativeClosure_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CooperativeClosure;"));
- CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
- LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
- CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
- LDKClosureReason_CommitmentTxConfirmed_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed;"));
- CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
- LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
- CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
- LDKClosureReason_ProcessingError_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$ProcessingError;"));
- CHECK(LDKClosureReason_ProcessingError_class != NULL);
- LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
- CHECK(LDKClosureReason_ProcessingError_meth != NULL);
- LDKClosureReason_DisconnectedPeer_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer;"));
- CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
- LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
- CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
- LDKClosureReason_OutdatedChannelManager_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager;"));
- CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
- LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
- CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
-}
-JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
- LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
- switch(obj->tag) {
- case LDKClosureReason_CounterpartyForceClosed: {
- LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
- jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
- return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
- }
- case LDKClosureReason_HolderForceClosed: {
- return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
- }
- case LDKClosureReason_CooperativeClosure: {
- return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
- }
- case LDKClosureReason_CommitmentTxConfirmed: {
- return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
- }
- case LDKClosureReason_ProcessingError: {
- LDKStr err_str = obj->processing_error.err;
- jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
- return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
- }
- case LDKClosureReason_DisconnectedPeer: {
- return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
- }
- case LDKClosureReason_OutdatedChannelManager: {
- return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
- }
- default: abort();
- }
-}
-static jclass LDKEvent_FundingGenerationReady_class = NULL;
-static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
-static jclass LDKEvent_PaymentReceived_class = NULL;
-static jmethodID LDKEvent_PaymentReceived_meth = NULL;
-static jclass LDKEvent_PaymentSent_class = NULL;
-static jmethodID LDKEvent_PaymentSent_meth = NULL;
-static jclass LDKEvent_PaymentPathFailed_class = NULL;
-static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
-static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
-static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
-static jclass LDKEvent_SpendableOutputs_class = NULL;
-static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
-static jclass LDKEvent_PaymentForwarded_class = NULL;
-static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
-static jclass LDKEvent_ChannelClosed_class = NULL;
-static jmethodID LDKEvent_ChannelClosed_meth = NULL;
-static jclass LDKEvent_DiscardFunding_class = NULL;
-static jmethodID LDKEvent_DiscardFunding_meth = NULL;
-JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
- LDKEvent_FundingGenerationReady_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
- CHECK(LDKEvent_FundingGenerationReady_class != NULL);
- LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
- CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
- LDKEvent_PaymentReceived_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
- CHECK(LDKEvent_PaymentReceived_class != NULL);
- LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
- CHECK(LDKEvent_PaymentReceived_meth != NULL);
- LDKEvent_PaymentSent_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
- CHECK(LDKEvent_PaymentSent_class != NULL);
- LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
- CHECK(LDKEvent_PaymentSent_meth != NULL);
- LDKEvent_PaymentPathFailed_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentPathFailed;"));
- CHECK(LDKEvent_PaymentPathFailed_class != NULL);
- LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
- CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
- LDKEvent_PendingHTLCsForwardable_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
- CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
- LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
- CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
- LDKEvent_SpendableOutputs_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
- CHECK(LDKEvent_SpendableOutputs_class != NULL);
- LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
- CHECK(LDKEvent_SpendableOutputs_meth != NULL);
- LDKEvent_PaymentForwarded_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentForwarded;"));
- CHECK(LDKEvent_PaymentForwarded_class != NULL);
- LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
- CHECK(LDKEvent_PaymentForwarded_meth != NULL);
- LDKEvent_ChannelClosed_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$ChannelClosed;"));
- CHECK(LDKEvent_ChannelClosed_class != NULL);
- LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
- CHECK(LDKEvent_ChannelClosed_meth != NULL);
- LDKEvent_DiscardFunding_class =
- (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$DiscardFunding;"));
- CHECK(LDKEvent_DiscardFunding_class != NULL);
- LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
- CHECK(LDKEvent_DiscardFunding_meth != NULL);
-}
-JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
- LDKEvent *obj = (LDKEvent*)(ptr & ~1);
- switch(obj->tag) {
- case LDKEvent_FundingGenerationReady: {
- int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
- LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
- int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
- (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
- return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, obj->funding_generation_ready.channel_value_satoshis, output_script_arr, obj->funding_generation_ready.user_channel_id);
- }
- case LDKEvent_PaymentReceived: {
- int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
- uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
- return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
- }
- case LDKEvent_PaymentSent: {
- int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
- int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
- int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
- uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
- return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
- }
- case LDKEvent_PaymentPathFailed: {
- int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
- int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
- uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
- LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
- int64_tArray path_arr = NULL;
- path_arr = (*env)->NewLongArray(env, path_var.datalen);
- int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
- for (size_t k = 0; k < path_var.datalen; k++) {
- LDKRouteHop path_conv_10_var = path_var.data[k];
- uint64_t path_conv_10_ref = 0;
- CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
- CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
- path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
- path_arr_ptr[k] = path_conv_10_ref;
- }
- (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
- uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
- LDKRouteParameters retry_var = obj->payment_path_failed.retry;
- uint64_t retry_ref = 0;
- if ((uint64_t)retry_var.inner > 4096) {
- CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
- CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
- retry_ref = (uint64_t)retry_var.inner & ~1;
- }
- return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, obj->payment_path_failed.rejected_by_dest, network_update_ref, obj->payment_path_failed.all_paths_failed, path_arr, short_channel_id_ref, retry_ref);
- }
- case LDKEvent_PendingHTLCsForwardable: {
- return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
- }
- case LDKEvent_SpendableOutputs: {
- LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
- int64_tArray outputs_arr = NULL;
- outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
- int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
- for (size_t b = 0; b < outputs_var.datalen; b++) {
- uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
- outputs_arr_ptr[b] = outputs_conv_27_ref;
- }
- (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
- return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
- }
- case LDKEvent_PaymentForwarded: {
- uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
- return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
- }
- case LDKEvent_ChannelClosed: {
- int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
- uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
- return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, obj->channel_closed.user_channel_id, reason_ref);
- }
- case LDKEvent_DiscardFunding: {
- int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
- (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
- LDKTransaction transaction_var = obj->discard_funding.transaction;
- int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
- (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
- return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
- }
- default: abort();
- }
-}
-JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
- LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
- ret->datalen = (*env)->GetArrayLength(env, elems);
- if (ret->datalen == 0) {
- ret->data = NULL;
- } else {
- ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
- int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
- for (size_t i = 0; i < ret->datalen; i++) {
- int64_t arr_elem = java_elems[i];
- void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
- CHECK_ACCESS(arr_elem_ptr);
- LDKEvent arr_elem_conv = *(LDKEvent*)(arr_elem_ptr);
- arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
- ret->data[i] = arr_elem_conv;
- }
- (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
- }
- return (uint64_t)ret;
-}