2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
5 export default class COption_TypeZ extends CommonBase {
6 protected constructor(_dummy: object, ptr: number) { super(ptr); }
9 if (this.ptr != 0) { bindings.COption_TypeZ_free(this.ptr); }
11 static constr_from_ptr(ptr: number): COption_TypeZ {
12 const raw_val: bindings.LDKCOption_TypeZ = bindings.LDKCOption_TypeZ_ref_from_ptr(ptr);
13 if (raw_val instanceof bindings.LDKCOption_TypeZ.Some) {
14 return new Some(this.ptr, raw_val);
16 if (raw_val instanceof bindings.LDKCOption_TypeZ.None) {
17 return new None(this.ptr, raw_val);
19 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
23 export class Some extends COption_TypeZ {
25 private constructor(ptr: number, obj: bindings.LDKCOption_TypeZ.Some) {
27 const some: number = obj.some;
28 Type ret_hu_conv = new Type(null, some);
29 ret_hu_conv.ptrs_to.add(this);
30 this.some = ret_hu_conv;
33 export class None extends COption_TypeZ {
34 private constructor(ptr: number, obj: bindings.LDKCOption_TypeZ.None) {
38 public static Option_TypeZ constructor_some(Type o) {
39 number ret = bindings.COption_TypeZ_some(o == null ? 0 : o.ptr);
40 Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret);
41 ret_hu_conv.ptrs_to.add(ret_hu_conv);
42 ret_hu_conv.ptrs_to.add(o);
46 public static Option_TypeZ constructor_none() {
47 number ret = bindings.COption_TypeZ_none();
48 Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret);
49 ret_hu_conv.ptrs_to.add(ret_hu_conv);
53 public number clone_ptr() {
54 number ret = bindings.COption_TypeZ_clone_ptr(this.ptr);
58 public Option_TypeZ clone() {
59 number ret = bindings.COption_TypeZ_clone(this.ptr);
60 Option_TypeZ ret_hu_conv = Option_TypeZ.constr_from_ptr(ret);
61 ret_hu_conv.ptrs_to.add(this);