Update auto-generated bindings
[ldk-java] / ts / structs / CustomMessageHandler.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export class CustomMessageHandler extends CommonBase {
9
10                 bindings_instance?: bindings.LDKCustomMessageHandler;
11
12                 constructor(ptr?: number, arg?: bindings.LDKCustomMessageHandler, customMessageReader?: bindings.LDKCustomMessageReader) {
13                     if (Number.isFinite(ptr)) {
14                                         super(ptr);
15                                         this.bindings_instance = null;
16                                     } else {
17                                         // TODO: private constructor instantiation
18                                         super(bindings.LDKCustomMessageHandler_new(arg, customMessageReader));
19                                         this.ptrs_to.push(arg);
20                                         this.ptrs_to.push(customMessageReader);
21
22                                     }
23                 }
24
25                 protected finalize() {
26                     if (this.ptr != 0) {
27                         bindings.CustomMessageHandler_free(this.ptr);
28                     }
29                     super.finalize();
30                 }
31
32                 static new_impl(arg: CustomMessageHandlerInterface, customMessageReader_impl: CustomMessageReader.CustomMessageReaderInterface): CustomMessageHandler {
33                     const impl_holder: LDKCustomMessageHandlerHolder = new LDKCustomMessageHandlerHolder();
34                     let structImplementation = <bindings.LDKCustomMessageHandler>{
35                         // todo: in-line interface filling
36                         handle_custom_message (msg: number, sender_node_id: Uint8Array): number {
37                                                         Type ret_hu_conv = new Type(null, msg);
38                                 ret_hu_conv.ptrs_to.add(this);
39                                                         Result_NoneLightningErrorZ ret = arg.handle_custom_message(ret_hu_conv, sender_node_id);
40                                 result: number = ret == null ? 0 : ret.clone_ptr();
41                                 return result;
42                                                 },
43
44                                                 get_and_clear_pending_msg (): number[] {
45                                                         TwoTuple_PublicKeyTypeZ[] ret = arg.get_and_clear_pending_msg();
46                                 result: number[] = ret != null ? Arrays.stream(ret).map(ret_conv_25 -> ret_conv_25 == null ? 0 : ret_conv_25.clone_ptr()).toArray(number[]::new) : null;
47                                 return result;
48                                                 },
49
50                                                 
51                     };
52                     impl_holder.held = new CustomMessageHandler (null, structImplementation, CustomMessageReader.new_impl(CustomMessageReader_impl).bindings_instance);
53                 }
54             }
55
56             export interface CustomMessageHandlerInterface {
57                 handle_custom_message(msg: Type, sender_node_id: Uint8Array): Result_NoneLightningErrorZ;
58                                 get_and_clear_pending_msg(): TwoTuple_PublicKeyTypeZ[];
59                                 
60             }
61
62             class LDKCustomMessageHandlerHolder {
63                 held: CustomMessageHandler;
64             }
65         public Result_NoneLightningErrorZ handle_custom_message(Type msg, Uint8Array sender_node_id) {
66                 number ret = bindings.CustomMessageHandler_handle_custom_message(this.ptr, msg == null ? 0 : msg.ptr, InternalUtils.check_arr_len(sender_node_id, 33));
67                 Result_NoneLightningErrorZ ret_hu_conv = Result_NoneLightningErrorZ.constr_from_ptr(ret);
68                 this.ptrs_to.add(msg);
69                 return ret_hu_conv;
70         }
71
72         public TwoTuple_PublicKeyTypeZ[] get_and_clear_pending_msg() {
73                 number[] ret = bindings.CustomMessageHandler_get_and_clear_pending_msg(this.ptr);
74                 TwoTuple_PublicKeyTypeZ[] ret_conv_25_arr = new TwoTuple_PublicKeyTypeZ[ret.length];
75                 for (int z = 0; z < ret.length; z++) {
76                         number ret_conv_25 = ret[z];
77                         TwoTuple_PublicKeyTypeZ ret_conv_25_hu_conv = new TwoTuple_PublicKeyTypeZ(null, ret_conv_25);
78                         ret_conv_25_hu_conv.ptrs_to.add(this);
79                         ret_conv_25_arr[z] = ret_conv_25_hu_conv;
80                 }
81                 return ret_conv_25_arr;
82         }
83
84 }