UNPKG

@jsonjoy.com/json-type

Version:

High-performance JSON Pointer implementation

31 lines (30 loc) 1.88 kB
import { Codegen } from '@jsonjoy.com/codegen'; import { JsExpression } from '@jsonjoy.com/codegen/lib/util/JsExpression'; import type { BinaryJsonEncoder } from '@jsonjoy.com/json-pack/lib/types'; import type { AnyType, ArrType, BinType, BoolType, ConType, MapType, NumType, OrType, RefType, StrType, Type } from '../../type'; import { AbstractCodegen } from '../AbstractCodege'; import type { CompiledBinaryEncoder, SchemaPath } from '../types'; export declare abstract class AbstractBinaryCodegen<Encoder extends BinaryJsonEncoder> extends AbstractCodegen<CompiledBinaryEncoder> { readonly type: Type; protected abstract encoder: Encoder; readonly codegen: Codegen<CompiledBinaryEncoder>; constructor(type: Type, name?: string); getBigIntStr(arr: Uint8Array, offset: number): string; private codegenBlob; js(js: string): void; gen(callback: (encoder: Encoder) => void): Uint8Array; blob(arr: Uint8Array): void; compile(): CompiledBinaryEncoder; protected abstract linkGet(): void; protected onAny(path: SchemaPath, r: JsExpression, type: AnyType): void; protected onCon(path: SchemaPath, r: JsExpression, type: ConType): void; protected onBool(path: SchemaPath, r: JsExpression, type: BoolType): void; protected onNum(path: SchemaPath, r: JsExpression, type: NumType): void; protected onStr(path: SchemaPath, r: JsExpression, type: StrType): void; protected onBin(path: SchemaPath, r: JsExpression, type: BinType): void; protected onArr(path: SchemaPath, val: JsExpression, type: ArrType): void; protected onMap(path: SchemaPath, val: JsExpression, type: MapType): void; protected onOr(path: SchemaPath, r: JsExpression, type: OrType<Type[]>): void; protected abstract genEncoder(type: Type): CompiledBinaryEncoder; protected onRef(path: SchemaPath, r: JsExpression, type: RefType): void; }