X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fstructs%2FLockableScore.ts;h=bc44054d985a66111de2711cdca79d5d43534fa4;hb=1854b5cebef22ace9e9e4dd191f609818df9ce08;hp=8eef837f7f386aef2fb6d51da02ed65d78a8b7aa;hpb=5fd405f7a48aaeca779c45c88ec6b3d3d3dbf0e4;p=ldk-java diff --git a/ts/structs/LockableScore.ts b/ts/structs/LockableScore.ts index 8eef837f..bc44054d 100644 --- a/ts/structs/LockableScore.ts +++ b/ts/structs/LockableScore.ts @@ -5,30 +5,59 @@ import * as bindings from '../bindings' // TODO: figure out location - export default class LockableScore extends CommonBase { - constructor(_dummy: object, ptr: number) { - super(ptr); + export class LockableScore extends CommonBase { + + bindings_instance?: bindings.LDKLockableScore; + + constructor(ptr?: number, arg?: bindings.LDKLockableScore) { + if (Number.isFinite(ptr)) { + super(ptr); + this.bindings_instance = null; + } else { + // TODO: private constructor instantiation + super(bindings.LDKLockableScore_new(arg)); + this.ptrs_to.push(arg); + + } } - protected finalize() { - super.finalize(); - if (this.ptr != 0) { bindings.LockableScore_free(this.ptr); } + super.finalize(); } - public static LockableScore constructor_new(Score score) { - number ret = bindings.LockableScore_new(score == null ? 0 : score.ptr); - const ret_hu_conv: LockableScore = new LockableScore(null, ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(score); - return ret_hu_conv; - } - public Uint8Array write() { - Uint8Array ret = bindings.LockableScore_write(this.ptr); - return ret; + static new_impl(arg: LockableScoreInterface): LockableScore { + const impl_holder: LDKLockableScoreHolder = new LDKLockableScoreHolder(); + let structImplementation = { + // todo: in-line interface filling + lock (): number { + Score ret = arg.lock(); + result: number = ret == null ? 0 : ret.ptr; + impl_holder.held.ptrs_to.add(ret); + return result; + }, + + + }; + impl_holder.held = new LockableScore (null, structImplementation); + } + } + + export interface LockableScoreInterface { + lock(): Score; + + } + + class LDKLockableScoreHolder { + held: LockableScore; + } + public Score lock() { + number ret = bindings.LockableScore_lock(this.ptr); + Score ret_hu_conv = new Score(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } }