ed0c0ed028
This adds some initial features for generating the ambient namespace files (the TS equivalent of .h files) for the C++ binding files. There are a few tests and it works on the sample code in tskit. I split the bindings/ folder into bindings/ and interface/ (for C++ and TS code, respectively). This can be tested locally by running make generate && make debug && make serve and verifying that everything compiles and runs in the browser. One thing I changed for easier parsing was making a @type annotation required, with an @optional tag for making a field or constant optional. Change-Id: If9c5a664e84fac4c734277cddd7774989a1f7bf8 Bug: skia:11826 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407476 Reviewed-by: Nathaniel Nifong <nifong@google.com> Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
declare namespace public_api {
|
|
export interface CanvasKit {
|
|
publicExtension(myRects: InputFlattenedRectArray): number;
|
|
sayHello(x: number, y: number): void;
|
|
publicFunction(input: string): void;
|
|
withObject(obj: CompoundObj): void;
|
|
|
|
readonly Extension: ExtensionConstructor;
|
|
readonly Something: SomethingConstructor;
|
|
}
|
|
|
|
export interface ExtensionConstructor {
|
|
new(): Extension;
|
|
new(name: string): Extension;
|
|
}
|
|
|
|
export interface SomethingConstructor {
|
|
new(name: string): Something;
|
|
}
|
|
|
|
export interface Extension extends EmbindObject<Extension> {
|
|
getProp(): string;
|
|
setProp(p: string): void;
|
|
}
|
|
|
|
export interface Something extends EmbindObject<Something> {
|
|
getName(): string;
|
|
setName(name: string): void;
|
|
}
|
|
|
|
export interface CompoundObj {
|
|
alpha: number;
|
|
beta: string;
|
|
gamma?: number;
|
|
}
|
|
|
|
export type InputFlattenedRectArray = Float32Array | number[];
|
|
export type TypedArray = Float32Array | Int32Array;
|
|
|
|
export interface EmbindObject<T extends EmbindObject<T>> {
|
|
clone(): T;
|
|
delete(): void;
|
|
deleteAfter(): void;
|
|
isAliasOf(other: any): boolean;
|
|
isDeleted(): boolean;
|
|
}
|
|
}
|