clone traits before passing to jcalls and map to human types
[ldk-java] / src / main / java / org / ldk / structs / SocketDescriptor.java
index 9c4f9e7b251d69148aca10dddf1f0f20f59152c9..9670c9da7ea5d15f1951e5fdf4530407921c8cde 100644 (file)
@@ -22,11 +22,13 @@ public class SocketDescriptor extends CommonBase {
        public static interface SocketDescriptorInterface {
                long send_data(byte[] data, boolean resume_read);
                void disconnect_socket();
-               boolean eq(long other_arg);
+               boolean eq(SocketDescriptor other_arg);
                long hash();
        }
-       public SocketDescriptor(SocketDescriptorInterface arg) {
-               this(new bindings.LDKSocketDescriptor() {
+       private static class LDKSocketDescriptorHolder { SocketDescriptor held; }
+       public static SocketDescriptor new_impl(SocketDescriptorInterface arg) {
+               final LDKSocketDescriptorHolder impl_holder = new LDKSocketDescriptorHolder();
+               impl_holder.held = new SocketDescriptor(new bindings.LDKSocketDescriptor() {
                        @Override public long send_data(byte[] data, boolean resume_read) {
                                long ret = arg.send_data(data, resume_read);
                                return ret;
@@ -35,7 +37,9 @@ public class SocketDescriptor extends CommonBase {
                                arg.disconnect_socket();
                        }
                        @Override public boolean eq(long other_arg) {
-                               boolean ret = arg.eq(other_arg);
+                               SocketDescriptor ret_hu_conv = new SocketDescriptor(null, other_arg);
+                               ret_hu_conv.ptrs_to.add(this);
+                               boolean ret = arg.eq(ret_hu_conv);
                                return ret;
                        }
                        @Override public long hash() {
@@ -43,6 +47,7 @@ public class SocketDescriptor extends CommonBase {
                                return ret;
                        }
                });
+               return impl_holder.held;
        }
        public long send_data(byte[] data, boolean resume_read) {
                long ret = bindings.SocketDescriptor_send_data(this.ptr, data, resume_read);
@@ -58,4 +63,12 @@ public class SocketDescriptor extends CommonBase {
                return ret;
        }
 
+       public static SocketDescriptor constructor_clone(SocketDescriptor orig) {
+               long ret = bindings.SocketDescriptor_clone(orig == null ? 0 : orig.ptr);
+               SocketDescriptor ret_hu_conv = new SocketDescriptor(null, ret);
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               ret_hu_conv.ptrs_to.add(orig);
+               return ret_hu_conv;
+       }
+
 }