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>
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
/// <reference path="load.ts" />
|
|
/// <reference path="memory.ts" />
|
|
/// <reference path="../bindings/extension.d.ts" />
|
|
/// <reference path="public_api.d.ts" />
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
namespace Extension {
|
|
// Module is the C++ module with the private (and some public) bindings on it.
|
|
declare const Module: extension.Bindings;
|
|
declare const CanvasKit: public_api.CanvasKit;
|
|
load.afterLoad(() => {
|
|
/**
|
|
* publicExtension takes the number of rects and returns how
|
|
* many of them have the point (5, 5) in them.
|
|
* @param myRects
|
|
* @ts publicExtension(myRects: InputFlattenedRectArray): void;
|
|
*/
|
|
CanvasKit.publicExtension = (myRects: public_api.InputFlattenedRectArray) => {
|
|
const rPtr = memory.copy1dArray(myRects, 'HEAPF32');
|
|
const num = Module._privateExtension(rPtr, myRects.length / 4);
|
|
memory.freeIfNecessary(rPtr, myRects);
|
|
return num;
|
|
};
|
|
|
|
CanvasKit.withObject = (obj: public_api.CompoundObj) => {
|
|
obj.gamma ||= 1.0;
|
|
Module._withObject(obj);
|
|
};
|
|
});
|
|
}
|