Use AutoCloseable for structs named Locked*
[ldk-java] / src / main / java / org / ldk / structs / QueryChannelRange.java
index 64ba67b9b72f3407f1a3e193b4d9179f7c3bcada..9d15fee3512292d2c6967668eb63e52da63fc776 100644 (file)
@@ -7,44 +7,45 @@ public class QueryChannelRange extends CommonBase {
        QueryChannelRange(Object _dummy, long ptr) { super(ptr); }
        @Override @SuppressWarnings("deprecation")
        protected void finalize() throws Throwable {
-               bindings.QueryChannelRange_free(ptr); super.finalize();
+               super.finalize();
+               bindings.QueryChannelRange_free(ptr);
        }
 
        public QueryChannelRange(QueryChannelRange orig) {
-               super(bindings.QueryChannelRange_clone(orig.ptr & ~1));
+               super(bindings.QueryChannelRange_clone(orig == null ? 0 : orig.ptr & ~1));
                this.ptrs_to.add(orig);
        }
 
        public byte[] get_chain_hash(QueryChannelRange this_ptr) {
-               byte[] ret = bindings.QueryChannelRange_get_chain_hash(this_ptr.ptr & ~1);
+               byte[] ret = bindings.QueryChannelRange_get_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1);
                this.ptrs_to.add(this_ptr);
                return ret;
        }
 
        public void set_chain_hash(QueryChannelRange this_ptr, byte[] val) {
-               bindings.QueryChannelRange_set_chain_hash(this_ptr.ptr & ~1, val);
+               bindings.QueryChannelRange_set_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
                this.ptrs_to.add(this_ptr);
        }
 
        public int get_first_blocknum(QueryChannelRange this_ptr) {
-               int ret = bindings.QueryChannelRange_get_first_blocknum(this_ptr.ptr & ~1);
+               int ret = bindings.QueryChannelRange_get_first_blocknum(this_ptr == null ? 0 : this_ptr.ptr & ~1);
                this.ptrs_to.add(this_ptr);
                return ret;
        }
 
        public void set_first_blocknum(QueryChannelRange this_ptr, int val) {
-               bindings.QueryChannelRange_set_first_blocknum(this_ptr.ptr & ~1, val);
+               bindings.QueryChannelRange_set_first_blocknum(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
                this.ptrs_to.add(this_ptr);
        }
 
        public int get_number_of_blocks(QueryChannelRange this_ptr) {
-               int ret = bindings.QueryChannelRange_get_number_of_blocks(this_ptr.ptr & ~1);
+               int ret = bindings.QueryChannelRange_get_number_of_blocks(this_ptr == null ? 0 : this_ptr.ptr & ~1);
                this.ptrs_to.add(this_ptr);
                return ret;
        }
 
        public void set_number_of_blocks(QueryChannelRange this_ptr, int val) {
-               bindings.QueryChannelRange_set_number_of_blocks(this_ptr.ptr & ~1, val);
+               bindings.QueryChannelRange_set_number_of_blocks(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
                this.ptrs_to.add(this_ptr);
        }
 
@@ -52,6 +53,9 @@ public class QueryChannelRange extends CommonBase {
                super(bindings.QueryChannelRange_new(chain_hash_arg, first_blocknum_arg, number_of_blocks_arg));
        }
 
-       // Skipped QueryChannelRange_read
+       public QueryChannelRange(byte[] ser) {
+               super(bindings.QueryChannelRange_read(ser));
+       }
+
        // Skipped QueryChannelRange_write
 }