3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
8 export class Type extends CommonBase {
10 bindings_instance?: bindings.LDKType;
12 constructor(ptr?: number, arg?: bindings.LDKType) {
13 if (Number.isFinite(ptr)) {
15 this.bindings_instance = null;
17 // TODO: private constructor instantiation
18 super(bindings.LDKType_new(arg));
19 this.ptrs_to.push(arg);
24 protected finalize() {
26 bindings.Type_free(this.ptr);
31 static new_impl(arg: TypeInterface): Type {
32 const impl_holder: LDKTypeHolder = new LDKTypeHolder();
33 let structImplementation = <bindings.LDKType>{
34 // todo: in-line interface filling
36 number ret = arg.type_id();
40 debug_str (): String {
41 String ret = arg.debug_str();
45 write (): Uint8Array {
46 Uint8Array ret = arg.write();
52 impl_holder.held = new Type (null, structImplementation);
56 export interface TypeInterface {
66 public number type_id() {
67 number ret = bindings.Type_type_id(this.ptr);
71 public String debug_str() {
72 String ret = bindings.Type_debug_str(this.ptr);
76 public Uint8Array write() {
77 Uint8Array ret = bindings.Type_write(this.ptr);
81 public number clone_ptr() {
82 number ret = bindings.Type_clone_ptr(this.ptr);
87 number ret = bindings.Type_clone(this.ptr);
88 Type ret_hu_conv = new Type(null, ret);
89 ret_hu_conv.ptrs_to.add(this);