Update auto-generated bindings
[ldk-java] / ts / structs / SocketDescriptor.ts
index dcced074e1809b64203592ea4a8637f7b0b33631..d94392555350789337c81e0478945e27d0acc245 100644 (file)
@@ -1,52 +1,77 @@
 
+            
 import CommonBase from './CommonBase';
 import * as bindings from '../bindings' // TODO: figure out location
 
-public class SocketDescriptor extends CommonBase {
-       final bindings.LDKSocketDescriptor bindings_instance;
-       SocketDescriptor(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
-       private SocketDescriptor(bindings.LDKSocketDescriptor arg) {
-               super(bindings.LDKSocketDescriptor_new(arg));
-               this.ptrs_to.add(arg);
-               this.bindings_instance = arg;
-       }
-       @Override @SuppressWarnings("deprecation")
-       protected void finalize() throws Throwable {
-               if (ptr != 0) { bindings.SocketDescriptor_free(ptr); } super.finalize();
-       }
 
-       public static interface SocketDescriptorInterface {
-               long send_data(byte[] data, boolean resume_read);
-               void disconnect_socket();
-               boolean eq(SocketDescriptor other_arg);
-               long hash();
-       }
-       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);
+
+            export class SocketDescriptor extends CommonBase {
+
+                bindings_instance?: bindings.LDKSocketDescriptor;
+
+                constructor(ptr?: number, arg?: bindings.LDKSocketDescriptor) {
+                    if (Number.isFinite(ptr)) {
+                                       super(ptr);
+                                       this.bindings_instance = null;
+                                   } else {
+                                       // TODO: private constructor instantiation
+                                       super(bindings.LDKSocketDescriptor_new(arg));
+                                       this.ptrs_to.push(arg);
+                                       
+                                   }
+                }
+
+                protected finalize() {
+                    if (this.ptr != 0) {
+                        bindings.SocketDescriptor_free(this.ptr);
+                    }
+                    super.finalize();
+                }
+
+                static new_impl(arg: SocketDescriptorInterface): SocketDescriptor {
+                    const impl_holder: LDKSocketDescriptorHolder = new LDKSocketDescriptorHolder();
+                    let structImplementation = <bindings.LDKSocketDescriptor>{
+                        // todo: in-line interface filling
+                        send_data (data: Uint8Array, resume_read: boolean): number {
+                                                       number ret = arg.send_data(data, resume_read);
                                return ret;
-                       }
-                       @Override public void disconnect_socket() {
-                               arg.disconnect_socket();
-                       }
-                       @Override public boolean eq(uint32_t other_arg) {
-                               SocketDescriptor ret_hu_conv = new SocketDescriptor(null, other_arg);
+                                               },
+
+                                               disconnect_socket (): void {
+                                                       arg.disconnect_socket();
+                                               },
+
+                                               eq (other_arg: number): boolean {
+                                                       SocketDescriptor ret_hu_conv = new SocketDescriptor(null, other_arg);
                                ret_hu_conv.ptrs_to.add(this);
-                               boolean ret = arg.eq(ret_hu_conv);
+                                                       boolean ret = arg.eq(ret_hu_conv);
                                return ret;
-                       }
-                       @Override public long hash() {
-                               long ret = arg.hash();
+                                               },
+
+                                               hash (): number {
+                                                       number ret = arg.hash();
                                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);
+                                               },
+
+                                               
+                    };
+                    impl_holder.held = new SocketDescriptor (null, structImplementation);
+                }
+            }
+
+            export interface SocketDescriptorInterface {
+                send_data(data: Uint8Array, resume_read: boolean): number;
+                               disconnect_socket(): void;
+                               eq(other_arg: SocketDescriptor): boolean;
+                               hash(): number;
+                               
+            }
+
+            class LDKSocketDescriptorHolder {
+                held: SocketDescriptor;
+            }
+       public number send_data(Uint8Array data, boolean resume_read) {
+               number ret = bindings.SocketDescriptor_send_data(this.ptr, data, resume_read);
                return ret;
        }
 
@@ -54,13 +79,18 @@ public class SocketDescriptor extends CommonBase {
                bindings.SocketDescriptor_disconnect_socket(this.ptr);
        }
 
-       public long hash() {
-               long ret = bindings.SocketDescriptor_hash(this.ptr);
+       public number hash() {
+               number ret = bindings.SocketDescriptor_hash(this.ptr);
+               return ret;
+       }
+
+       public number clone_ptr() {
+               number ret = bindings.SocketDescriptor_clone_ptr(this.ptr);
                return ret;
        }
 
        public SocketDescriptor clone() {
-               uint32_t ret = bindings.SocketDescriptor_clone(this.ptr);
+               number ret = bindings.SocketDescriptor_clone(this.ptr);
                SocketDescriptor ret_hu_conv = new SocketDescriptor(null, ret);
                ret_hu_conv.ptrs_to.add(this);
                return ret_hu_conv;