]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/RouteHop.ts
Handle `uintptr_t`s better in JNI bindings
[ldk-java] / ts / structs / RouteHop.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export default class RouteHop extends CommonBase {
9                 constructor(_dummy: object, ptr: number) {
10                     super(ptr);
11                 }
12
13                 
14                 protected finalize() {
15                     super.finalize();
16
17                     if (this.ptr != 0) {
18                         bindings.RouteHop_free(this.ptr);
19                     }
20                 }
21         public RouteHop clone() {
22                 number ret = bindings.RouteHop_clone(this.ptr);
23                 const ret_hu_conv: RouteHop = new RouteHop(null, ret);
24                 ret_hu_conv.ptrs_to.add(this);
25                 return ret_hu_conv;
26         }
27
28         public Uint8Array get_pubkey() {
29                 Uint8Array ret = bindings.RouteHop_get_pubkey(this.ptr);
30                 return ret;
31         }
32
33         public void set_pubkey(Uint8Array val) {
34                 bindings.RouteHop_set_pubkey(this.ptr, val);
35         }
36
37         public NodeFeatures get_node_features() {
38                 number ret = bindings.RouteHop_get_node_features(this.ptr);
39                 const ret_hu_conv: NodeFeatures = new NodeFeatures(null, ret);
40                 ret_hu_conv.ptrs_to.add(this);
41                 return ret_hu_conv;
42         }
43
44         public void set_node_features(NodeFeatures val) {
45                 bindings.RouteHop_set_node_features(this.ptr, val == null ? 0 : val.ptr & ~1);
46                 this.ptrs_to.add(val);
47                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
48                 // an object to pass exclusive ownership to the function being called.
49                 // In most cases, we avoid this being visible in GC'd languages by cloning the object
50                 // at the FFI layer, creating a new object which Rust can claim ownership of
51                 // However, in some cases (eg here), there is no way to clone an object, and thus
52                 // we actually have to pass full ownership to Rust.
53                 // Thus, after this call, val is reset to null and is now a dummy object.
54                 val.ptr = 0;
55         }
56
57         public number get_short_channel_id() {
58                 number ret = bindings.RouteHop_get_short_channel_id(this.ptr);
59                 return ret;
60         }
61
62         public void set_short_channel_id(number val) {
63                 bindings.RouteHop_set_short_channel_id(this.ptr, val);
64         }
65
66         public ChannelFeatures get_channel_features() {
67                 number ret = bindings.RouteHop_get_channel_features(this.ptr);
68                 const ret_hu_conv: ChannelFeatures = new ChannelFeatures(null, ret);
69                 ret_hu_conv.ptrs_to.add(this);
70                 return ret_hu_conv;
71         }
72
73         public void set_channel_features(ChannelFeatures val) {
74                 bindings.RouteHop_set_channel_features(this.ptr, val == null ? 0 : val.ptr & ~1);
75                 this.ptrs_to.add(val);
76                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
77                 // an object to pass exclusive ownership to the function being called.
78                 // In most cases, we avoid this being visible in GC'd languages by cloning the object
79                 // at the FFI layer, creating a new object which Rust can claim ownership of
80                 // However, in some cases (eg here), there is no way to clone an object, and thus
81                 // we actually have to pass full ownership to Rust.
82                 // Thus, after this call, val is reset to null and is now a dummy object.
83                 val.ptr = 0;
84         }
85
86         public number get_fee_msat() {
87                 number ret = bindings.RouteHop_get_fee_msat(this.ptr);
88                 return ret;
89         }
90
91         public void set_fee_msat(number val) {
92                 bindings.RouteHop_set_fee_msat(this.ptr, val);
93         }
94
95         public number get_cltv_expiry_delta() {
96                 number ret = bindings.RouteHop_get_cltv_expiry_delta(this.ptr);
97                 return ret;
98         }
99
100         public void set_cltv_expiry_delta(number val) {
101                 bindings.RouteHop_set_cltv_expiry_delta(this.ptr, val);
102         }
103
104         public static RouteHop constructor_new(Uint8Array pubkey_arg, NodeFeatures node_features_arg, number short_channel_id_arg, ChannelFeatures channel_features_arg, number fee_msat_arg, number cltv_expiry_delta_arg) {
105                 number ret = bindings.RouteHop_new(pubkey_arg, node_features_arg == null ? 0 : node_features_arg.ptr & ~1, short_channel_id_arg, channel_features_arg == null ? 0 : channel_features_arg.ptr & ~1, fee_msat_arg, cltv_expiry_delta_arg);
106                 const ret_hu_conv: RouteHop = new RouteHop(null, ret);
107                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
108                 ret_hu_conv.ptrs_to.add(node_features_arg);
109                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
110                 // an object to pass exclusive ownership to the function being called.
111                 // In most cases, we avoid ret_hu_conv being visible in GC'd languages by cloning the object
112                 // at the FFI layer, creating a new object which Rust can claim ownership of
113                 // However, in some cases (eg here), there is no way to clone an object, and thus
114                 // we actually have to pass full ownership to Rust.
115                 // Thus, after ret_hu_conv call, node_features_arg is reset to null and is now a dummy object.
116                 node_features_arg.ptr = 0;
117                 ret_hu_conv.ptrs_to.add(channel_features_arg);
118                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
119                 // an object to pass exclusive ownership to the function being called.
120                 // In most cases, we avoid ret_hu_conv being visible in GC'd languages by cloning the object
121                 // at the FFI layer, creating a new object which Rust can claim ownership of
122                 // However, in some cases (eg here), there is no way to clone an object, and thus
123                 // we actually have to pass full ownership to Rust.
124                 // Thus, after ret_hu_conv call, channel_features_arg is reset to null and is now a dummy object.
125                 channel_features_arg.ptr = 0;
126                 return ret_hu_conv;
127         }
128
129 }