2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
5 public class SocketDescriptor extends CommonBase {
6 final bindings.LDKSocketDescriptor bindings_instance;
7 SocketDescriptor(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
8 private SocketDescriptor(bindings.LDKSocketDescriptor arg) {
9 super(bindings.LDKSocketDescriptor_new(arg));
10 this.ptrs_to.add(arg);
11 this.bindings_instance = arg;
13 @Override @SuppressWarnings("deprecation")
14 protected void finalize() throws Throwable {
15 if (ptr != 0) { bindings.SocketDescriptor_free(ptr); } super.finalize();
18 public static interface SocketDescriptorInterface {
19 long send_data(byte[] data, boolean resume_read);
20 void disconnect_socket();
21 boolean eq(SocketDescriptor other_arg);
24 private static class LDKSocketDescriptorHolder { SocketDescriptor held; }
25 public static SocketDescriptor new_impl(SocketDescriptorInterface arg) {
26 final LDKSocketDescriptorHolder impl_holder = new LDKSocketDescriptorHolder();
27 impl_holder.held = new SocketDescriptor(new bindings.LDKSocketDescriptor() {
28 @Override public long send_data(byte[] data, boolean resume_read) {
29 long ret = arg.send_data(data, resume_read);
32 @Override public void disconnect_socket() {
33 arg.disconnect_socket();
35 @Override public boolean eq(uint32_t other_arg) {
36 SocketDescriptor ret_hu_conv = new SocketDescriptor(null, other_arg);
37 ret_hu_conv.ptrs_to.add(this);
38 boolean ret = arg.eq(ret_hu_conv);
41 @Override public long hash() {
42 long ret = arg.hash();
46 return impl_holder.held;
48 public long send_data(byte[] data, boolean resume_read) {
49 long ret = bindings.SocketDescriptor_send_data(this.ptr, data, resume_read);
53 public void disconnect_socket() {
54 bindings.SocketDescriptor_disconnect_socket(this.ptr);
58 long ret = bindings.SocketDescriptor_hash(this.ptr);
62 public SocketDescriptor clone() {
63 uint32_t ret = bindings.SocketDescriptor_clone(this.ptr);
64 SocketDescriptor ret_hu_conv = new SocketDescriptor(null, ret);
65 ret_hu_conv.ptrs_to.add(this);