novy-syndicate/src/gen/box-protocol.ts

66 lines
2.1 KiB
TypeScript
Raw Normal View History

2021-03-11 17:00:45 +00:00
import * as _ from "@preserves/core";
import * as _i_Actor from "../runtime/actor";
2021-03-11 17:00:45 +00:00
export const $BoxState = Symbol.for("BoxState");
export const $SetBox = Symbol.for("SetBox");
2021-03-23 11:18:57 +00:00
export type _ptr = _i_Actor.Ref;
2021-03-11 17:00:45 +00:00
2021-03-23 11:18:57 +00:00
export type _val = _.Value<_ptr>;
2021-03-11 17:00:45 +00:00
2021-03-23 11:18:57 +00:00
export type BoxState = {"value": number};
2021-03-11 17:00:45 +00:00
2021-03-23 11:18:57 +00:00
export type SetBox = {"value": number};
2021-03-11 17:00:45 +00:00
2021-03-23 11:18:57 +00:00
export const _toPtr = (v: _val) => {let result: undefined | _ptr; result = _i_Actor.toRef(v); return result;};
2021-03-11 17:00:45 +00:00
2021-03-23 18:18:26 +00:00
export function BoxState(value: number): BoxState {return {"value": value};}
2021-03-11 17:00:45 +00:00
2021-03-23 18:18:26 +00:00
export function SetBox(value: number): SetBox {return {"value": value};}
2021-03-11 17:00:45 +00:00
2021-03-23 11:18:57 +00:00
export function asBoxState(v: _val): BoxState {
let result = toBoxState(v);
if (result === void 0) throw new TypeError(`Invalid BoxState: ${_.stringify(v)}`);
return result;
2021-03-11 17:00:45 +00:00
}
2021-03-23 11:18:57 +00:00
export function toBoxState(v: _val): undefined | BoxState {
let result: undefined | BoxState;
if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) {
let _tmp0: (null) | undefined;
_tmp0 = _.is(v.label, $BoxState) ? null : void 0;
if (_tmp0 !== void 0) {
2021-03-23 11:18:57 +00:00
let _tmp1: (number) | undefined;
_tmp1 = typeof v[0] === 'number' ? v[0] : void 0;
if (_tmp1 !== void 0) {result = {"value": _tmp1};};
};
};
return result;
2021-03-12 19:49:18 +00:00
}
2021-03-23 11:18:57 +00:00
export function fromBoxState(_v: BoxState): _val {return _.Record($BoxState, [_v["value"]]);}
2021-03-11 17:00:45 +00:00
2021-03-23 11:18:57 +00:00
export function asSetBox(v: _val): SetBox {
let result = toSetBox(v);
if (result === void 0) throw new TypeError(`Invalid SetBox: ${_.stringify(v)}`);
return result;
2021-03-11 17:00:45 +00:00
}
2021-03-23 11:18:57 +00:00
export function toSetBox(v: _val): undefined | SetBox {
let result: undefined | SetBox;
if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) {
let _tmp0: (null) | undefined;
_tmp0 = _.is(v.label, $SetBox) ? null : void 0;
if (_tmp0 !== void 0) {
let _tmp1: (number) | undefined;
_tmp1 = typeof v[0] === 'number' ? v[0] : void 0;
if (_tmp1 !== void 0) {result = {"value": _tmp1};};
};
};
return result;
2021-03-12 19:49:18 +00:00
}
2021-03-23 11:18:57 +00:00
export function fromSetBox(_v: SetBox): _val {return _.Record($SetBox, [_v["value"]]);}
2021-03-12 19:49:18 +00:00