mirror of
https://github.com/enso-org/enso.git
synced 2024-12-22 18:01:38 +03:00
9fd1ab9092
Generate TS bindings and lazy deserialization for the parser types. # Important Notes - The new API is imported into `ffi.ts`, but not yet used. - I have tested the generated code in isolation, but cannot commit tests as we are not currently able to load WASM modules when running in `vitest`.
36 lines
971 B
TypeScript
36 lines
971 B
TypeScript
export type Schema = {
|
|
types: Types
|
|
serialization: Serialization
|
|
}
|
|
export type TypeId = string
|
|
export type Types = {
|
|
[id: TypeId]: Type
|
|
}
|
|
export type Type = {
|
|
name: string
|
|
fields: Fields
|
|
parent?: string
|
|
}
|
|
export type Fields = {
|
|
[name: string]: TypeRef
|
|
}
|
|
export type TypeRef = Class | Primitive | Sequence | Option | Result
|
|
export type Class = { class: 'type'; id: TypeId }
|
|
export type Primitive = { class: 'primitive'; type: PrimitiveType }
|
|
export type Sequence = { class: 'sequence'; type: TypeRef }
|
|
export type Option = { class: 'option'; type: TypeRef }
|
|
export type Result = { class: 'result'; type0: TypeRef; type1: TypeRef }
|
|
export type PrimitiveType = 'bool' | 'u32' | 'u64' | 'i32' | 'i64' | 'char' | 'string'
|
|
|
|
export type Serialization = {
|
|
[id: TypeId]: Layout
|
|
}
|
|
export type Layout = {
|
|
discriminants?: DiscriminantMap
|
|
fields: [name: string, offset: number][]
|
|
size: number
|
|
}
|
|
export type DiscriminantMap = {
|
|
[discriminant: number]: TypeId
|
|
}
|