]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/Logger.ts
Bindings updates for latest upstream, check in .so
[ldk-java] / ts / structs / Logger.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export class Logger extends CommonBase {
9
10                 bindings_instance?: bindings.LDKLogger;
11
12                 constructor(ptr?: number, arg?: bindings.LDKLogger) {
13                     if (Number.isFinite(ptr)) {
14                                         super(ptr);
15                                         this.bindings_instance = null;
16                                     } else {
17                                         // TODO: private constructor instantiation
18                                         super(bindings.LDKLogger_new(arg));
19                                         this.ptrs_to.push(arg);
20                                         
21                                     }
22                 }
23
24                 protected finalize() {
25                     if (this.ptr != 0) {
26                         bindings.Logger_free(this.ptr);
27                     }
28                     super.finalize();
29                 }
30
31                 static new_impl(arg: LoggerInterface): Logger {
32                     const impl_holder: LDKLoggerHolder = new LDKLoggerHolder();
33                     let structImplementation = <bindings.LDKLogger>{
34                         // todo: in-line interface filling
35                         log (record: String): void {
36                                                         arg.log(record);
37                                                 },
38
39                                                 
40                     };
41                     impl_holder.held = new Logger (null, structImplementation);
42                 }
43             }
44
45             export interface LoggerInterface {
46                 log(record: String): void;
47                                 
48             }
49
50             class LDKLoggerHolder {
51                 held: Logger;
52             }
53 }