export class HookParamSpec { name: string; description: string | null; } export class HookParam { name: string; @inline constructor(ps: HookParamSpec) { this.name = ps.name; } @inline get(dflt: T | null = null): T { let a = new ByteArray(data_size()); let r = $hook_param(changetype(a), data_size(), changetype(this.name), this.name.length); if (r == data_size()) return instantiate(a); if (!dflt) rollback("", pack_error_code(r)); return dflt!; } @inline value(dflt: T): T { let a = new ByteArray(sizeof()); let r = $hook_param(changetype(a), sizeof(), changetype(this.name), this.name.length); if (r == sizeof()) return load(changetype(a)); return dflt; } }; export namespace Params { // compiler re-directs all names inside this namespace here @inline function __get(name: string): ByteArray { return hook_param(name); } }