3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
8 export class EventsProvider extends CommonBase {
10 bindings_instance?: bindings.LDKEventsProvider;
12 constructor(ptr?: number, arg?: bindings.LDKEventsProvider) {
13 if (Number.isFinite(ptr)) {
15 this.bindings_instance = null;
17 // TODO: private constructor instantiation
18 super(bindings.LDKEventsProvider_new(arg));
19 this.ptrs_to.push(arg);
24 protected finalize() {
26 bindings.EventsProvider_free(this.ptr);
31 static new_impl(arg: EventsProviderInterface): EventsProvider {
32 const impl_holder: LDKEventsProviderHolder = new LDKEventsProviderHolder();
33 let structImplementation = <bindings.LDKEventsProvider>{
34 // todo: in-line interface filling
35 get_and_clear_pending_events (): number[] {
36 Event[] ret = arg.get_and_clear_pending_events();
37 result: number[] = Arrays.stream(ret).map(ret_conv_7 -> ret_conv_7.ptr).toArray(number[]::new);
44 impl_holder.held = new EventsProvider (null, structImplementation);
48 export interface EventsProviderInterface {
49 get_and_clear_pending_events(): Event[];
53 class LDKEventsProviderHolder {
56 public Event[] get_and_clear_pending_events() {
57 number[] ret = bindings.EventsProvider_get_and_clear_pending_events(this.ptr);
58 Event[] ret_conv_7_arr = new Event[ret.length];
59 for (int h = 0; h < ret.length; h++) {
60 number ret_conv_7 = ret[h];
61 Event ret_conv_7_hu_conv = Event.constr_from_ptr(ret_conv_7);
62 ret_conv_7_hu_conv.ptrs_to.add(this);
63 ret_conv_7_arr[h] = ret_conv_7_hu_conv;
65 return ret_conv_7_arr;