76 lines
2.5 KiB
TypeScript
76 lines
2.5 KiB
TypeScript
import * as _ from "@preserves/core";
|
|
import * as _i_Actor from "../actor";
|
|
|
|
export const $BoxState = Symbol.for("BoxState");
|
|
export const $SetBox = Symbol.for("SetBox");
|
|
|
|
export const BoxState = _.Record.makeConstructor<{"_field0": number}, _ptr>()($BoxState, ["_field0"]);
|
|
|
|
export type BoxState = _.Record<(typeof $BoxState), [number], _ptr>;
|
|
|
|
export const SetBox = _.Record.makeConstructor<{"_field0": number}, _ptr>()($SetBox, ["_field0"]);
|
|
|
|
export type SetBox = _.Record<(typeof $SetBox), [number], _ptr>;
|
|
|
|
export type _ptr = _i_Actor.Ref;
|
|
|
|
export type _val = _.Value<_ptr>;
|
|
|
|
|
|
export function isBoxState(v: any): v is BoxState {
|
|
return (
|
|
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
|
|
_.is(v.label, $BoxState) &&
|
|
((v.length === 1) && typeof v[0] === 'number')
|
|
);
|
|
}
|
|
|
|
export function asBoxState(v: any): BoxState {
|
|
if (!isBoxState(v)) {throw new TypeError(`Invalid BoxState: ${_.stringify(v)}`);} else {return v;};
|
|
}
|
|
|
|
export function decodeBoxState(d: _.TypedDecoder<_ptr>): BoxState | undefined {
|
|
let result;
|
|
if (d.openRecord()) {
|
|
let _tmp0: any;
|
|
_tmp0 = _.asLiteral(d.nextSymbol(), $BoxState);
|
|
if (_tmp0 !== void 0) {
|
|
let _tmp1, _tmp2: any;
|
|
_tmp2 = d.nextSignedInteger();
|
|
if (_tmp2 !== void 0) {if (d.closeCompound()) _tmp1 = [_tmp2];};
|
|
if (_tmp1 !== void 0) result = _.Record<(typeof $BoxState), [number]>(_tmp0 as any, _tmp1 as any);
|
|
};
|
|
};
|
|
return result;
|
|
}
|
|
|
|
export function isSetBox(v: any): v is SetBox {
|
|
return (
|
|
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
|
|
_.is(v.label, $SetBox) &&
|
|
((v.length === 1) && typeof v[0] === 'number')
|
|
);
|
|
}
|
|
|
|
export function asSetBox(v: any): SetBox {
|
|
if (!isSetBox(v)) {throw new TypeError(`Invalid SetBox: ${_.stringify(v)}`);} else {return v;};
|
|
}
|
|
|
|
export function decodeSetBox(d: _.TypedDecoder<_ptr>): SetBox | undefined {
|
|
let result;
|
|
if (d.openRecord()) {
|
|
let _tmp3: any;
|
|
_tmp3 = _.asLiteral(d.nextSymbol(), $SetBox);
|
|
if (_tmp3 !== void 0) {
|
|
let _tmp4, _tmp5: any;
|
|
_tmp5 = d.nextSignedInteger();
|
|
if (_tmp5 !== void 0) {if (d.closeCompound()) _tmp4 = [_tmp5];};
|
|
if (_tmp4 !== void 0) result = _.Record<(typeof $SetBox), [number]>(_tmp3 as any, _tmp4 as any);
|
|
};
|
|
};
|
|
return result;
|
|
}
|
|
|
|
export const _decodePtr = (d: _.TypedDecoder<_ptr>) => {let result; result = _i_Actor.decodeRef(d); return result;};
|
|
|