UNPKG

rc-js-util

Version:

A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.

106 lines 3.77 kB
import { type TFullSetTypedArrayCtor } from "../array/typed-array/t-typed-array-ctor.js"; import type { IJsUtilBindings } from "../web-assembly/i-js-util-bindings.js"; import { type IEmscriptenWrapper } from "../web-assembly/emscripten/i-emscripten-wrapper.js"; import type { IManagedObject, IPointer } from "../lifecycle/manged-resources.js"; /** * @public * Matches ENumberIdentifier in `RTTI.hpp`. */ export declare enum ENumberIdentifier { U8 = 0,// used for indexing U16 = 1, U32 = 2, U64 = 3,// this is not generally supported... I8 = 4, I16 = 5, I32 = 6, I64 = 7,// this is not generally supported... F32 = 8, F64 = 9 } /** * @public * Given a typed array constructor, get the identifier which matches up with ENumberIdentifier in `RTTI.hpp`. */ export declare function getNumberIdentifier(ctor: TFullSetTypedArrayCtor): ENumberIdentifier; /** * @public * Mirrors the C++ class of the same name. This can be used as a key to get a unique number which can be matched on the C++ side. */ export declare class StableId { readonly name: string; constructor(name: string); } /** * @public * Mirrors the C++ class of the same name. Each category can have multiple kinds of specializations. * * @remarks There should only be one instance of a conceptual class (which should have a unique name) */ export declare class IdCategory extends StableId { } /** * @public * Mirrors the C++ class of the same name. A specialization of a conceptual category. E.g. a number (category) which is a float 32 (specialization). * * @remarks There should only be one instance of a conceptual class (which should have a unique name) */ export declare class IdSpecialization extends StableId { readonly category: IdCategory; constructor(category: IdCategory, specializationName: string); } /** * @public * Supported types of number across C++ and JavaScript. */ export declare const numberCategory: IdCategory; /** * @public * A buffer that can be shared with C++. */ export declare const bufferCategory: IdCategory; /** * @public * Given a Typed array constructor, get back the associated {@link StableId}. */ export declare function getNumberSpecialization(ctor: TFullSetTypedArrayCtor): IdSpecialization; /** * @public * {@link IdSpecialization} for all supported number types. */ export declare const numberSpecializations: { readonly u8: IdSpecialization; readonly u16: IdSpecialization; readonly u32: IdSpecialization; readonly u64: IdSpecialization; readonly i8: IdSpecialization; readonly i16: IdSpecialization; readonly i32: IdSpecialization; readonly i64: IdSpecialization; readonly f32: IdSpecialization; readonly f64: IdSpecialization; }; /** * @public * Provides the number which matches up with the C++ end, given a {@link StableId}. */ export interface IStableStore { initialize(): void; getId(key: IdSpecialization | IdCategory): number; setSpecializations(sharedObjectHandle: IManagedObject & IPointer, specializations: readonly IdSpecialization[]): void; hasId(sharedObjectHandle: IManagedObject & IPointer, specialization: IdSpecialization): boolean; } /** * @public * {@inheritDoc IStableStore} */ export declare class StableIdStore implements IStableStore { private readonly wrapper; constructor(wrapper: IEmscriptenWrapper<IJsUtilBindings>); initialize(): void; getId(key: IdSpecialization | IdCategory): number; setSpecializations(sharedObjectHandle: IManagedObject & IPointer, specializations: readonly IdSpecialization[]): void; hasId(sharedObjectHandle: IManagedObject & IPointer, specialization: IdSpecialization): boolean; private ids; } //# sourceMappingURL=rtti-interop.d.ts.map