X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FChannelDetails.java;h=4c690d2d67f876adfcb4af2dc113a5c3932fe343;hb=fed2245c60159f6c074c9ed5c0f3ce273ad9841b;hp=740cb20c1a4f6f0cefe84c04b7575381166affda;hpb=2ed9081562d00a8645604b07629e963231d49e0f;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ChannelDetails.java b/src/main/java/org/ldk/structs/ChannelDetails.java index 740cb20c..4c690d2d 100644 --- a/src/main/java/org/ldk/structs/ChannelDetails.java +++ b/src/main/java/org/ldk/structs/ChannelDetails.java @@ -2,106 +2,106 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelDetails extends CommonBase { ChannelDetails(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelDetails_free(ptr); super.finalize(); + super.finalize(); + if (ptr != 0) { bindings.ChannelDetails_free(ptr); } } - public ChannelDetails(ChannelDetails orig) { - super(bindings.ChannelDetails_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + public ChannelDetails clone() { + long ret = bindings.ChannelDetails_clone(this.ptr); + ChannelDetails ret_hu_conv = new ChannelDetails(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - public byte[] get_channel_id(ChannelDetails this_ptr) { - byte[] ret = bindings.ChannelDetails_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_channel_id() { + byte[] ret = bindings.ChannelDetails_get_channel_id(this.ptr); return ret; } - public void set_channel_id(ChannelDetails this_ptr, byte[] val) { - bindings.ChannelDetails_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_id(byte[] val) { + bindings.ChannelDetails_set_channel_id(this.ptr, val); } - public byte[] get_remote_network_id(ChannelDetails this_ptr) { - byte[] ret = bindings.ChannelDetails_get_remote_network_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public byte[] get_remote_network_id() { + byte[] ret = bindings.ChannelDetails_get_remote_network_id(this.ptr); return ret; } - public void set_remote_network_id(ChannelDetails this_ptr, byte[] val) { - bindings.ChannelDetails_set_remote_network_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_remote_network_id(byte[] val) { + bindings.ChannelDetails_set_remote_network_id(this.ptr, val); } - public InitFeatures get_counterparty_features(ChannelDetails this_ptr) { - InitFeatures ret = new InitFeatures(null, bindings.ChannelDetails_get_counterparty_features(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + public InitFeatures get_counterparty_features() { + long ret = bindings.ChannelDetails_get_counterparty_features(this.ptr); + InitFeatures ret_hu_conv = new InitFeatures(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - public void set_counterparty_features(ChannelDetails this_ptr, InitFeatures val) { - bindings.ChannelDetails_set_counterparty_features(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + public void set_counterparty_features(InitFeatures val) { + bindings.ChannelDetails_set_counterparty_features(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); - } - - public long get_channel_value_satoshis(ChannelDetails this_ptr) { - long ret = bindings.ChannelDetails_get_channel_value_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + // Due to rust's strict-ownership memory model, in some cases we need to "move" + // an object to pass exclusive ownership to the function being called. + // In most cases, we avoid this being visible in GC'd languages by cloning the object + // at the FFI layer, creating a new object which Rust can claim ownership of + // However, in some cases (eg here), there is no way to clone an object, and thus + // we actually have to pass full ownership to Rust. + // Thus, after this call, val is reset to null and is now a dummy object. + val.ptr = 0; + } + + public long get_channel_value_satoshis() { + long ret = bindings.ChannelDetails_get_channel_value_satoshis(this.ptr); return ret; } - public void set_channel_value_satoshis(ChannelDetails this_ptr, long val) { - bindings.ChannelDetails_set_channel_value_satoshis(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_channel_value_satoshis(long val) { + bindings.ChannelDetails_set_channel_value_satoshis(this.ptr, val); } - public long get_user_id(ChannelDetails this_ptr) { - long ret = bindings.ChannelDetails_get_user_id(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_user_id() { + long ret = bindings.ChannelDetails_get_user_id(this.ptr); return ret; } - public void set_user_id(ChannelDetails this_ptr, long val) { - bindings.ChannelDetails_set_user_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_user_id(long val) { + bindings.ChannelDetails_set_user_id(this.ptr, val); } - public long get_outbound_capacity_msat(ChannelDetails this_ptr) { - long ret = bindings.ChannelDetails_get_outbound_capacity_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_outbound_capacity_msat() { + long ret = bindings.ChannelDetails_get_outbound_capacity_msat(this.ptr); return ret; } - public void set_outbound_capacity_msat(ChannelDetails this_ptr, long val) { - bindings.ChannelDetails_set_outbound_capacity_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_outbound_capacity_msat(long val) { + bindings.ChannelDetails_set_outbound_capacity_msat(this.ptr, val); } - public long get_inbound_capacity_msat(ChannelDetails this_ptr) { - long ret = bindings.ChannelDetails_get_inbound_capacity_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public long get_inbound_capacity_msat() { + long ret = bindings.ChannelDetails_get_inbound_capacity_msat(this.ptr); return ret; } - public void set_inbound_capacity_msat(ChannelDetails this_ptr, long val) { - bindings.ChannelDetails_set_inbound_capacity_msat(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_inbound_capacity_msat(long val) { + bindings.ChannelDetails_set_inbound_capacity_msat(this.ptr, val); } - public boolean get_is_live(ChannelDetails this_ptr) { - boolean ret = bindings.ChannelDetails_get_is_live(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + public boolean get_is_live() { + boolean ret = bindings.ChannelDetails_get_is_live(this.ptr); return ret; } - public void set_is_live(ChannelDetails this_ptr, boolean val) { - bindings.ChannelDetails_set_is_live(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + public void set_is_live(boolean val) { + bindings.ChannelDetails_set_is_live(this.ptr, val); } }